Changes for libtclobjc-1.1b3 to make it work with the gcc-objc-960906 snapshot. To apply the patch, go to the directory libtclobjc-1.1b3 and use this command patch -p1 feeding it the following diffs (below the "cut here") as input. Here is an email describing why the patch is needed: >From address@hidden Sat Sep 7 21:38:13 1996 Date: Sat, 7 Sep 1996 21:13:53 -0400 X-Sender: address@hidden Mime-Version: 1.0 To: Christopher Seawood From: Scott Christley Subject: Re: new gcc-objc snapshot Cc: GCC2 Snapshot , GNU Objective-C Discussion , GNUstep Discussion At 05:39 PM 9/7/96 -0700, Christopher Seawood wrote: >I have a question about one of the changes in the error handling >functions. In , you added: >extern void *(*_objc_malloc)(size_t); >extern void *(*_objc_atomic_malloc)(size_t); >extern void *(*_objc_valloc)(size_t); >extern void *(*_objc_realloc)(void *, size_t); >extern void *(*_objc_calloc)(size_t, size_t); >extern void (*_objc_free)(void *); > >in objc-malloc.m from gstep-base-0.2.6.tar.gz, it's defined as: >void *(*objc_malloc)(size_t size) = __objc_malloc; >void *(*objc_valloc)(size_t size) = __objc_valloc; >void *(*objc_atomic_malloc)(size_t) = __objc_malloc; >void *(*objc_realloc)(void *optr, size_t size) = __objc_realloc; >void *(*objc_calloc)(size_t nelem, size_t size) = __objc_calloc; >void (*objc_free)(void *optr) = __objc_free; > >Are the leading underscores supposed to be there? If so, why? If not, then >I need to recompile gcc (again). :) Yes, this is one of the major changes dealing with memory allocation and freedom. Previously there was no easy way to override the memory functions used by the runtime library; though, it was possible to override how gnustep-base allocated memory. The only way you could override in the runtime library was to change the source code so that everywhere there was a malloc, realloc, free, etc; you replaced it with your function. If you overrode within gnustep-base then that would work for all of the memory that gnustep-base allocated, but any memory that the runtime library allocated would still be through the system malloc, realloc, etc and not your functions. gnustep-base allowed you to override by allowing you to change the function pointers as you indicate for gstep-base-0.2.6.tar.gz void *(*objc_malloc)(size_t size) = __objc_malloc; void *(*objc_valloc)(size_t size) = __objc_valloc; void *(*objc_atomic_malloc)(size_t) = __objc_malloc; void *(*objc_realloc)(void *optr, size_t size) = __objc_realloc; void *(*objc_calloc)(size_t nelem, size_t size) = __objc_calloc; void (*objc_free)(void *optr) = __objc_free; With the new release, these have been *eliminated* completely from gnustep-base! Instead they have been shifted out of gnustep-base and into the runtime library, and in the process they have been renamed. extern void *(*_objc_malloc)(size_t); extern void *(*_objc_atomic_malloc)(size_t); extern void *(*_objc_valloc)(size_t); extern void *(*_objc_realloc)(void *, size_t); extern void *(*_objc_calloc)(size_t, size_t); extern void (*_objc_free)(void *); So in a roundabout answer, YES the underscores are suppose to be there. What I've done in the runtime is define these functions: void *objc_malloc(size_t size); void *objc_atomic_malloc(size_t size); void *objc_valloc(size_t size); void *objc_realloc(void *mem, size_t size); void *objc_calloc(size_t nelem, size_t size); void objc_free(void *mem); You should for now on ALWAYS call these functions to allocate memory. Each of these function will then call the corresponding function pointer (the same name but with a leading underscore) to actually do the memory operation. This change means that you can plug in (say) Boehm's garbage collector by doing these assignments. _objc_malloc = GC_malloc _objc_atomic_malloc = GC_atomic_malloc _objc_valloc = GC_valloc _objc_realloc = GC_realloc _objc_calloc = GC_calloc _objc_free = GC_free And those functions will be used for all runtime library AND gnustep-base memory operations. So does this make sense? If not ask me for more detail. Scott --- cut here --- diff -c libtclobjc-1.1b3/Makefile.in libtclobjc-1.1b3-new/Makefile.in *** libtclobjc-1.1b3/Makefile.in Wed Dec 13 20:13:14 1995 --- libtclobjc-1.1b3-new/Makefile.in Sun Oct 6 19:54:40 1996 *************** *** 96,110 **** @NON_NeXT_EXTRA_SRCS@ \ Tcl.m \ Tk.m \ ! tclObjc.m \ ! objc-malloc.m OBJS = \ @NON_NeXT_EXTRA_OBJS@ \ Tcl.o \ @Tk_o@ \ ! tclObjc.o \ ! objc-malloc.o HDRS = \ Tcl.h \ --- 96,109 ---- @NON_NeXT_EXTRA_SRCS@ \ Tcl.m \ Tk.m \ ! tclObjc.m OBJS = \ @NON_NeXT_EXTRA_OBJS@ \ Tcl.o \ @Tk_o@ \ ! tclObjc.o ! HDRS = \ Tcl.h \ *************** *** 117,123 **** Tcl.m \ Tk.m \ tclObjc.m \ - objc-malloc.m \ xmalloc.c \ checkTcl.m \ checkTk.m \ --- 116,121 ---- *************** *** 126,132 **** Tcl.h \ Tk.h \ tclObjc.h \ - objc-malloc.h \ objc-gnu2next.h \ check.tcl check.tk \ config.tcllib \ --- 124,129 ---- diff -c libtclobjc-1.1b3/tclObjc.m libtclobjc-1.1b3-new/tclObjc.m *** libtclobjc-1.1b3/tclObjc.m Thu Mar 28 23:52:02 1996 --- libtclobjc-1.1b3-new/tclObjc.m Sun Oct 6 19:51:02 1996 *************** *** 44,50 **** #endif #include "tclObjc.h" - #include "objc-malloc.h" #include #if (NeXT) --- 44,49 ---- *************** *** 594,600 **** + newName: (char *)objectName { TclObject *newTclObject = class_create_instance(self); ! OBJC_MALLOC(newTclObject->_tclName, char, strlen(objectName)+1); strcpy(newTclObject->_tclName, objectName); /* Fix this ugliness!!! */ newTclObject->_interp = _TclObject_interp; --- 593,600 ---- + newName: (char *)objectName { TclObject *newTclObject = class_create_instance(self); ! newTclObject->_tclName = (char*) objc_malloc((unsigned)(strlen(objectName)+1) ! * sizeof(char)); strcpy(newTclObject->_tclName, objectName); /* Fix this ugliness!!! */ newTclObject->_interp = _TclObject_interp; *************** *** 603,609 **** - free { ! OBJC_FREE(_tclName); return object_dispose(self); } --- 603,609 ---- - free { ! objc_free(_tclName); return object_dispose(self); }