kaffe-1.0.b1: fix for calloc macro breaks prototypes

Simon J. Gerraty sjg at netboss.cdn.telstra.com.au
Tue Jul 14 23:52:15 PDT 1998


In a quick attempt to compile kaffe on Solaris 2.6 using gcc-2.7.2
The following macro:

kaffe-1.0.b1/include/jmalloc.h:25:#define    calloc(A, B)    __malloc((A)*(B))

results in:

gmake[3]: Entering directory `/var/obj/kaffe/libraries/clib/awt'
gcc -g -O2 -I/share/src/kaffe-1.0.b1/libraries/clib/awt -I../../../include -I/share/src/kaffe-1.0.b1/libraries/clib/awt/../../../include -I../../../config -I/share/src/kaffe-1.0.b1/libraries/clib/awt/../../../config -I/share/src/kaffe-1.0.b1/libraries/clib/awt/X -I/usr/openwin/include  -c -fPIC /share/src/kaffe-1.0.b1/libraries/clib/awt/X/tlk.c -o X/tlk.o
In file included from /share/src/kaffe-1.0.b1/libraries/clib/awt/X/toolkit.h:16,
                 from /share/src/kaffe-1.0.b1/libraries/clib/awt/X/tlk.c:15:
/usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.7.2/include/stdlib.h:112: parse error before `('

The following patch gets us past that - until we die for lack of
jpeglib.h

gcc -g -O2 -I/share/src/kaffe-1.0.b1/libraries/clib/awt -I../../../include -I/share/src/kaffe-1.0.b1/libraries/clib/awt/../../../include -I../../../config -I/share/src/kaffe-1.0.b1/libraries/clib/awt/../../../config -I/share/src/kaffe-1.0.b1/libraries/clib/awt/X -I/usr/openwin/include  -c -fPIC /share/src/kaffe-1.0.b1/libraries/clib/awt/X/img.c -o X/img.o
/share/src/kaffe-1.0.b1/libraries/clib/awt/X/img.c:15: jpeglib.h: No such file or directory
gmake[3]: *** [X/img.o] Error 1
gmake[3]: Leaving directory `/var/obj/kaffe/libraries/clib/awt'
gmake[2]: *** [all] Error 1

Note that we had to lose the () around A and B in the calloc macro...
Otherwise we get even more errors.

Hope that helps.

--sjg

*** include/jmalloc.h.~1~	Tue Jul 14 14:34:12 1998
--- include/jmalloc.h	Wed Jul 15 16:41:55 1998
***************
*** 15,20 ****
--- 15,21 ----
  #if !defined(KAFFEH)
  
  extern void*	__malloc(size_t);
+ extern void*	__calloc(size_t, size_t);
  extern void	__free(void*);
  
  #undef malloc
***************
*** 22,28 ****
  #undef free
  
  #define	malloc(A)	__malloc(A)
! #define	calloc(A, B)	__malloc((A)*(B))
  #define	free(A)		__free(A)
  
  #endif
--- 23,29 ----
  #undef free
  
  #define	malloc(A)	__malloc(A)
! #define	calloc(A, B)	__calloc(A, B)
  #define	free(A)		__free(A)
  
  #endif
*** kaffe/kaffevm/gc.c.~1~	Tue Jul 14 14:34:14 1998
--- kaffe/kaffevm/gc.c	Wed Jul 15 16:40:54 1998
***************
*** 18,23 ****
--- 18,29 ----
  	return ((*Kaffe_GarbageCollectorInterface._malloc)(sz, GC_ALLOC_FIXED));
  }
  
+ void*
+ __calloc(size_t n, size_t sz)
+ {
+ 	return ((*Kaffe_GarbageCollectorInterface._malloc)((sz * n), GC_ALLOC_FIXED));
+ }
+ 
  void
  __free(void* mem)
  {


More information about the kaffe mailing list