diff -ruN klic-3.003-2002-03-09a/include/klic/gc_macro.h klic-3.003-2002-03-09b/include/klic/gc_macro.h --- klic-3.003-2002-03-09a/include/klic/gc_macro.h Sat Mar 9 13:00:49 2002 +++ klic-3.003-2002-03-09b/include/klic/gc_macro.h Sat Mar 9 16:41:10 2002 @@ -69,7 +69,8 @@ argv[0] = GC_TERM; \ argv[1] = newvar; \ assert(g_allocp >= heapp() + 1); \ - tmp = GC_wakeup_g_new(2, argv, g_allocp); \ + set_heapp(g_allocp); \ + tmp = GC_wakeup_g_new(2, argv); \ g_allocp = heapp(); \ GC_KL1_UNIFY((var), tmp); \ assert(g_allocp == heapp() + 4); \ @@ -141,11 +142,7 @@ #define GCDEF_NEW() \ - q \ - GC_rappend(new) (GC_ARGC,GC_ARGV,g_allocp) \ - long GC_ARGC; \ - q GC_ARGV[]; \ - q *g_allocp; +extern q GC_rappend(new) (long GC_ARGC, q* GC_ARGV) #define GC_DEREF_FOR_NEW(x) \ do{ \ diff -ruN klic-3.003-2002-03-09a/include/klic/gd_macro.h klic-3.003-2002-03-09b/include/klic/gd_macro.h --- klic-3.003-2002-03-09a/include/klic/gd_macro.h Sat Mar 9 14:07:45 2002 +++ klic-3.003-2002-03-09b/include/klic/gd_macro.h Sat Mar 9 16:41:10 2002 @@ -232,11 +232,7 @@ /**************************************************************************/ #define GDDEF_NEW() \ - q \ - GD_rappend(new) (GD_ARGC,GD_ARGV,g_allocp) \ - long GD_ARGC; \ - q GD_ARGV[]; \ - q *g_allocp; +extern q GD_rappend(new) (long GD_ARGC, q* GD_ARGV) #define GD_SUSPEND_NEW(v) \ do{ \ diff -ruN klic-3.003-2002-03-09a/include/klic/generic.h klic-3.003-2002-03-09b/include/klic/generic.h --- klic-3.003-2002-03-09a/include/klic/generic.h Sat Feb 16 11:46:20 2002 +++ klic-3.003-2002-03-09b/include/klic/generic.h Sat Mar 9 16:41:10 2002 @@ -12,17 +12,19 @@ #include /* runtime/generic.c */ -extern q* gd_generic( - q* g_allocp, q g_object, long g_method_functor, q* g_argv ); +extern void gd_generic(q g_object, long g_method_functor, q* g_argv); #define new_generic(name,argc,out,offset) \ do{ \ - (out) = (name)((argc), generic_arg, allocp+offset); \ + set_heapp(allocp + (offset)); \ + (out) = (name)((argc), generic_arg); \ allocp = heapp(); \ }while(0) #define call_generic(obj,funct,offset) \ - (allocp = (q *) gd_generic(allocp+(offset),(obj),(funct),generic_arg)) + ( set_heapp(allocp + (offset)), \ + gd_generic((obj),(funct),generic_arg), \ + allocp = heapp() ) #define guard_generic(object,mf,inargc,label) \ do{ \ diff -ruN klic-3.003-2002-03-09a/include/klic/gg_macro.h klic-3.003-2002-03-09b/include/klic/gg_macro.h --- klic-3.003-2002-03-09a/include/klic/gg_macro.h Sat Mar 9 13:38:38 2002 +++ klic-3.003-2002-03-09b/include/klic/gg_macro.h Sat Mar 9 16:41:10 2002 @@ -51,7 +51,8 @@ assert(g_allocp >= heapp() + 1); \ argv[0] = GG_TERM; \ argv[1] = newvar; \ - tmp = GC_wakeup_g_new(2,argv,g_allocp); \ + set_heapp(g_allocp); \ + tmp = GC_wakeup_g_new(2, argv); \ GG_KL1_UNIFY((var), tmp); \ return(g_allocp); \ }while(0) @@ -121,10 +122,7 @@ G_STD_DECL; GGset_myself_for_new #define GGDEF_NEW() \ - q GG_rappend(new) (GG_ARGC, GG_ARGV, g_allocp) \ - long GG_ARGC; \ - q GG_ARGV[]; \ - q *g_allocp; +extern q GG_rappend(new) (long GG_ARGC, q* GG_ARGV) #define GG_DEREF_FOR_NEW(x) \ do{ \ diff -ruN klic-3.003-2002-03-09a/runtime/gcode.c klic-3.003-2002-03-09b/runtime/gcode.c --- klic-3.003-2002-03-09a/runtime/gcode.c Sat Mar 9 14:13:42 2002 +++ klic-3.003-2002-03-09b/runtime/gcode.c Sat Mar 9 16:41:10 2002 @@ -254,6 +254,7 @@ const struct predicate* predaddr; q predname; int arity; + q* g_allocp = heapp(); if( GD_ARGC != 3 ) GD_ERROR_IN_NEW("Too few or too many arguments"); diff -ruN klic-3.003-2002-03-09a/runtime/ge_exref.c klic-3.003-2002-03-09b/runtime/ge_exref.c --- klic-3.003-2002-03-09a/runtime/ge_exref.c Sat Mar 9 13:40:34 2002 +++ klic-3.003-2002-03-09b/runtime/ge_exref.c Sat Mar 9 16:41:10 2002 @@ -168,8 +168,8 @@ { GG_STD_DECL_FOR_NEW; GG_OBJ_TYPE* new_exref; + q* g_allocp = heapp(); - set_heapp(g_allocp); GGSET_NEWOBJ_FOR_NEW(new_exref, (struct exref_object*)); assert(g_allocp == heapp() + GG_OBJ_SIZE); diff -ruN klic-3.003-2002-03-09a/runtime/ge_readhook.c klic-3.003-2002-03-09b/runtime/ge_readhook.c --- klic-3.003-2002-03-09a/runtime/ge_readhook.c Sat Mar 9 13:07:34 2002 +++ klic-3.003-2002-03-09b/runtime/ge_readhook.c Sat Mar 9 16:41:10 2002 @@ -95,8 +95,8 @@ { GC_STD_DECL_FOR_NEW; GC_OBJ_TYPE* new_read_hook; + q* g_allocp = heapp(); - set_heapp(g_allocp); GCSET_NEWOBJ_FOR_NEW(new_read_hook, GC_OBJ_SIZE(new_read_hook)); assert(g_allocp == heapp() + GC_OBJ_SIZE(new_read_hook)); new_read_hook->node = (long) intval(GC_ARGV[0]); diff -ruN klic-3.003-2002-03-09a/runtime/ge_replyhook.c klic-3.003-2002-03-09b/runtime/ge_replyhook.c --- klic-3.003-2002-03-09a/runtime/ge_replyhook.c Sat Mar 9 13:07:52 2002 +++ klic-3.003-2002-03-09b/runtime/ge_replyhook.c Sat Mar 9 16:41:10 2002 @@ -71,8 +71,8 @@ GC_STD_DECL_FOR_NEW; GC_OBJ_TYPE* new_reply_hook; q var; + q* g_allocp = heapp(); - set_heapp(g_allocp); GCSET_NEWOBJ_FOR_NEW(new_reply_hook, GC_OBJ_SIZE(new_reply_hook)); assert(g_allocp == heapp() + GC_OBJ_SIZE(new_reply_hook)); new_reply_hook->node = intval(GC_ARGV[0]); diff -ruN klic-3.003-2002-03-09a/runtime/gen.kl1 klic-3.003-2002-03-09b/runtime/gen.kl1 --- klic-3.003-2002-03-09a/runtime/gen.kl1 Fri Feb 22 22:27:35 2002 +++ klic-3.003-2002-03-09b/runtime/gen.kl1 Sat Mar 9 16:46:06 2002 @@ -7,11 +7,12 @@ :- inline:" #include /* enter_functor */ +#include /* gd_generic */ #include \"gobj.h\" #include \"g_pointer.h\" #include \"g_termarray.h\" -typedef q* (*gd_func)(); +typedef q (*gd_func)(); ". :- module generic. @@ -26,16 +27,20 @@ (gd_func) ((struct pointer_object*) data_objectp(%1))->pointer; argc = ((struct termarray_object*) data_objectp(%2))->nterm; argv = ((struct termarray_object*) data_objectp(%2))->terms; - %0 = (q) func(argc, argv, allocp); + set_heapp(allocp); + %0 = (q) func(argc, argv); allocp = heapp(); }": [X0-any, Funct+functor, Argv+functor] | X0=X. generic(Funct, Obj) :- inline:" - allocp = gd_generic(allocp, %1, symval(functorp(%0)->functor), - &(functorp(%0)->args[0]) ); + set_heapp(allocp); + gd_generic(%1, symval(functorp(%0)->functor), &(functorp(%0)->args[0])); + allocp = heapp(); ": [Funct+functor, Obj+object] | true . generic(Funct, Obj) :- inline:" { unsigned long funct = enter_functor(symval(%0), 0); - allocp = gd_generic(allocp, %1, funct, 0); + set_heapp(allocp); + gd_generic(%1, funct, 0); + allocp = heapp(); }": [Funct+atom, Obj+object] | true . diff -ruN klic-3.003-2002-03-09a/runtime/generic.c klic-3.003-2002-03-09b/runtime/generic.c --- klic-3.003-2002-03-09a/runtime/generic.c Sat Mar 9 14:04:04 2002 +++ klic-3.003-2002-03-09b/runtime/generic.c Sat Mar 9 16:41:10 2002 @@ -74,8 +74,11 @@ { G_STD_DECL; q newvar; - q newobj = gd_new_pointer(myself, g_allocp); - q newobj2 = gd_new_termarray(argc, argv, heapp()); + q newobj, newobj2; + + set_heapp(g_allocp); + newobj = gd_new_pointer(myself); + newobj2 = gd_new_termarray(argc, argv); g_allocp = heapp(); G_HEAPALLOC(*goalp1, G_SIZE_IN_Q(struct goalrec)-3, (struct goalrec*)); @@ -112,15 +115,15 @@ /**********************************************************************/ -extern q* -gd_generic(g_allocp, g_object, g_method_functor, g_argv) - q* g_allocp; +extern void +gd_generic(g_object, g_method_functor, g_argv) q g_object; long g_method_functor; q* g_argv; { G_STD_DECL; struct data_object* g_obj; + q* g_allocp = heapp(); GD_DEREF_FOR_GENERIC(g_object); if( !isfunctor(g_object) || !isref(functor_of(g_object)) ){ @@ -131,8 +134,6 @@ g_obj = data_objectp(g_object); set_heapp(g_allocp); g_obj->method_table->body_generic(g_obj, g_method_functor, g_argv); - g_allocp = heapp(); - GD_RETURN; } diff -ruN klic-3.003-2002-03-09a/runtime/gfloat.c klic-3.003-2002-03-09b/runtime/gfloat.c --- klic-3.003-2002-03-09a/runtime/gfloat.c Sat Mar 9 14:15:10 2002 +++ klic-3.003-2002-03-09b/runtime/gfloat.c Sat Mar 9 16:41:10 2002 @@ -140,7 +140,8 @@ strcat(buf, ".0"); } } - str = convert_c_string_to_klic_string(buf, g_allocp); + set_heapp(g_allocp); + str = convert_c_string_to_klic_string(buf); g_allocp = heapp(); GD_UNIFY_VALUE(GD_ARGV[0], str); GD_RETURN; @@ -389,6 +390,7 @@ GD_STD_DECL_FOR_NEW; q init = GD_ARGV[0]; GD_OBJ_TYPE* newobj; + q* g_allocp = heapp(); GD_DEREF_FOR_NEW(init); ALIGN(); diff -ruN klic-3.003-2002-03-09a/runtime/ggoal.c klic-3.003-2002-03-09b/runtime/ggoal.c --- klic-3.003-2002-03-09a/runtime/ggoal.c Sat Mar 9 14:15:26 2002 +++ klic-3.003-2002-03-09b/runtime/ggoal.c Sat Mar 9 16:41:10 2002 @@ -357,6 +357,7 @@ struct predicate_object *pred; long pred_arity, argv_arity; long k; + q* g_allocp = heapp(); if (GD_ARGC != 2) { GD_ERROR_IN_NEW("Wrong number of arguments"); diff -ruN klic-3.003-2002-03-09a/runtime/gio.c klic-3.003-2002-03-09b/runtime/gio.c --- klic-3.003-2002-03-09a/runtime/gio.c Sat Mar 9 13:09:43 2002 +++ klic-3.003-2002-03-09b/runtime/gio.c Sat Mar 9 16:41:10 2002 @@ -163,7 +163,8 @@ for( k=0; klinecount++; } } - string = convert_binary_c_string_to_klic_string(buf, n, g_allocp); + set_heapp(g_allocp); + string = convert_binary_c_string_to_klic_string(buf, n); if( G_ISREF(string) ){ GC_FAIL("internal error: string allocation for fread"); } @@ -464,6 +465,7 @@ q var; struct pointer_object* inptr; struct pointer_object* outptr; + q* g_allocp = heapp(); /* * Arguments are: diff -ruN klic-3.003-2002-03-09a/runtime/gmerge.c klic-3.003-2002-03-09b/runtime/gmerge.c --- klic-3.003-2002-03-09a/runtime/gmerge.c Sat Mar 9 13:11:12 2002 +++ klic-3.003-2002-03-09b/runtime/gmerge.c Sat Mar 9 16:41:10 2002 @@ -163,10 +163,10 @@ GC_STD_DECL_FOR_NEW; GC_OBJ_TYPE *newmerger; q var; + q* g_allocp = heapp(); if (GC_ARGC != 1) GC_ERROR_IN_NEW("Arity mismatch"); - set_heapp(g_allocp); GCSET_NEWOBJ_FOR_NEW(newmerger,GC_OBJ_SIZE(newmerger)); assert(g_allocp == heapp() + GC_OBJ_SIZE(newmerger)); newmerger->count = 1; diff -ruN klic-3.003-2002-03-09a/runtime/gmodule.c klic-3.003-2002-03-09b/runtime/gmodule.c --- klic-3.003-2002-03-09a/runtime/gmodule.c Sat Mar 9 14:15:40 2002 +++ klic-3.003-2002-03-09b/runtime/gmodule.c Sat Mar 9 16:41:10 2002 @@ -153,6 +153,7 @@ q atom; const struct modinfo* mp; unsigned char *name; + q* g_allocp = heapp(); GDSET_SYMARG_FOR_NEW(atom,GD_ARGV[0]); name = namestringof(atom); diff -ruN klic-3.003-2002-03-09a/runtime/gmvv.c klic-3.003-2002-03-09b/runtime/gmvv.c --- klic-3.003-2002-03-09a/runtime/gmvv.c Sat Mar 9 14:15:55 2002 +++ klic-3.003-2002-03-09b/runtime/gmvv.c Sat Mar 9 16:41:10 2002 @@ -557,6 +557,7 @@ q *body; long size, k; q init; + q* g_allocp = heapp(); if (GD_ARGC!=1) GD_ERROR_IN_NEW("Too few or too many arguments"); init = GD_ARGV[0]; diff -ruN klic-3.003-2002-03-09a/runtime/gpointer.c klic-3.003-2002-03-09b/runtime/gpointer.c --- klic-3.003-2002-03-09a/runtime/gpointer.c Sat Mar 9 12:52:08 2002 +++ klic-3.003-2002-03-09b/runtime/gpointer.c Sat Mar 9 16:41:10 2002 @@ -52,6 +52,8 @@ { GD_STD_DECL_FOR_NEW; GD_OBJ_TYPE *newobj; + q* g_allocp = heapp(); + if (GD_ARGC != 1) GD_FAIL("Argument mismatch in pointer:new"); G_HEAPALLOC(newobj,GD_OBJ_SIZE(newobj),(GD_OBJ_TYPE *)); assert(g_allocp >= heapp() + GD_OBJ_SIZE(newobj)); @@ -62,11 +64,10 @@ } extern q -gd_new_pointer(arg0, g_allocp) +gd_new_pointer(arg0) q arg0; - q *g_allocp; { q argv[1]; argv[0] = arg0; - return pointer_g_new(1,argv,g_allocp); + return pointer_g_new(1, argv); } diff -ruN klic-3.003-2002-03-09a/runtime/gstring.c klic-3.003-2002-03-09b/runtime/gstring.c --- klic-3.003-2002-03-09a/runtime/gstring.c Sat Mar 9 14:16:18 2002 +++ klic-3.003-2002-03-09b/runtime/gstring.c Sat Mar 9 16:41:10 2002 @@ -620,6 +620,7 @@ unsigned char *body; long size; q init; + q* g_allocp = heapp(); if (GD_ARGC!=1) GD_ERROR_IN_NEW("Too few or too many arguments"); init = GD_ARGV[0]; @@ -760,15 +761,15 @@ } extern q -convert_c_string_to_klic_string(cstr, g_allocp) +convert_c_string_to_klic_string(cstr) char *cstr; - q *g_allocp; { q argv[1]; q str; long len = strlen(cstr); + argv[0] = makeint(len); - str = byte__string_g_new(1,argv,g_allocp); + str = byte__string_g_new(1, argv); if (!G_ISREF(str)) { BCOPY(cstr, ((struct byte_string_object *)functorp(str))->body, len); } @@ -776,15 +777,15 @@ } extern q -convert_binary_c_string_to_klic_string(cstr, len, g_allocp) +convert_binary_c_string_to_klic_string(cstr, len) char *cstr; long len; - q *g_allocp; { q argv[1]; q str; + argv[0] = makeint(len); - str = byte__string_g_new(1,argv,g_allocp); + str = byte__string_g_new(1, argv); if (!G_ISREF(str)) { BCOPY(cstr, ((struct byte_string_object *)functorp(str))->body, len); } @@ -834,9 +835,11 @@ { GD_STD_DECL_FOR_NEW; long elemsize; + q* g_allocp = heapp(); if (GD_ARGC!=2) GD_ERROR_IN_NEW("Too few or too many arguments"); GDSET_INTARG_FOR_NEW(elemsize, GD_ARGV[1]); if (elemsize != 8) GD_ERROR_IN_NEW("Only byte strings are supported now"); - return byte__string_g_new(1,GD_ARGV,g_allocp); + set_heapp(g_allocp); + return byte__string_g_new(1, GD_ARGV); } diff -ruN klic-3.003-2002-03-09a/runtime/gtermarray.c klic-3.003-2002-03-09b/runtime/gtermarray.c --- klic-3.003-2002-03-09a/runtime/gtermarray.c Sat Mar 9 12:53:22 2002 +++ klic-3.003-2002-03-09b/runtime/gtermarray.c Sat Mar 9 16:41:10 2002 @@ -60,6 +60,7 @@ unsigned long size = GD_ARGC; GD_OBJ_TYPE *newobj; int i; + q* g_allocp = heapp(); G_HEAPALLOC(newobj,G_SIZE_IN_Q(GD_OBJ_TYPE)+size-1,(GD_OBJ_TYPE *)); assert(g_allocp >= heapp() + G_SIZE_IN_Q(GD_OBJ_TYPE)+size-1); @@ -73,10 +74,9 @@ } extern q -gd_new_termarray(argc, argv, g_allocp) +gd_new_termarray(argc, argv) unsigned long argc; q argv[]; - q *g_allocp; { - return termarray_g_new(argc,argv,g_allocp); + return termarray_g_new(argc, argv); } diff -ruN klic-3.003-2002-03-09a/runtime/gunix.kl1 klic-3.003-2002-03-09b/runtime/gunix.kl1 --- klic-3.003-2002-03-09a/runtime/gunix.kl1 Mon Feb 25 15:36:44 2002 +++ klic-3.003-2002-03-09b/runtime/gunix.kl1 Sat Mar 9 16:41:10 2002 @@ -78,7 +78,8 @@ #define MakeFilePointer(klicvar, file) \\ do{ \\ - (klicvar) = gd_new_pointer((q) (file), allocp); \\ + set_heapp(allocp); \\ + (klicvar) = gd_new_pointer((q) (file)); \\ allocp = heapp(); \\ }while(0) @@ -151,13 +152,15 @@ #define MakeInBuf(klicvar, fd, size) \\ do{ \\ - (klicvar) = gd_new_pointer((q) make_iobuf((fd), (size), 0), allocp); \\ + set_heapp(allocp); \\ + (klicvar) = gd_new_pointer((q) make_iobuf((fd), (size), 0)); \\ allocp = heapp(); \\ }while(0) #define MakeOutBuf(klicvar, fd, size) \\ do{ \\ - (klicvar) = gd_new_pointer((q) make_iobuf((fd), (size), 1), allocp); \\ + set_heapp(allocp); \\ + (klicvar) = gd_new_pointer((q) make_iobuf((fd), (size), 1)); \\ allocp = heapp(); \\ }while(0) @@ -166,7 +169,8 @@ #define MakeBIOBuf(klicvar, ifd, ofd, size) \\ do{ \\ - (klicvar) = gd_new_pointer((q) make_biobuf((ifd), (ofd), (size)), allocp); \\ + set_heapp(allocp); \\ + (klicvar) = gd_new_pointer((q) make_biobuf((ifd), (ofd), (size))); \\ allocp = heapp(); \\ }while(0) @@ -424,7 +428,8 @@ strcpy(addr->sa_data, path); free(path); %1 = makeint(family); - %2 = gd_new_pointer((q) addr, allocp); + set_heapp(allocp); + %2 = gd_new_pointer((q) addr); allocp = heapp(); }": [Path+object(byte_string), Fam0-int, Addr0-object(pointer)] | Fam=Fam0, Addr=Addr0. @@ -449,7 +454,8 @@ */ addr->sin_port = htons(intval(%1)); %2 = makeint(family); - %3 = gd_new_pointer((q) addr, allocp); + set_heapp(allocp); + %3 = gd_new_pointer((q) addr); allocp = heapp(); }": [HostName+object(byte_string), Port+int, Fam0-int, Addr0-object(pointer)] | @@ -480,7 +486,8 @@ */ addr->sin_port = htons(intval(%4)); %5 = makeint(family); - %6 = gd_new_pointer((q) addr, allocp); + set_heapp(allocp); + %6 = gd_new_pointer((q) addr); allocp = heapp(); }": [B1+int, B2+int, B3+int, B4+int, Port+int, Fam0-int, Addr0-object(pointer)] | @@ -821,7 +828,8 @@ for( k=0, nnl=0; kptr[k] == '\\n' ) nnl++; } - str = BC2KLIC(iob->ptr, toread, allocp); + set_heapp(allocp); + str = BC2KLIC(iob->ptr, toread); if( isref(str) ){ fatal(\"internal error: string allocation failure for fread\"); } @@ -1000,7 +1008,8 @@ for( k=0, nnl=0; kptr[k] == '\\n' ) nnl++; } - str = BC2KLIC(iob->ptr, toread, allocp); + set_heapp(allocp); + str = BC2KLIC(iob->ptr, toread); if( isref(str) ){ fatal(\"internal error: string allocation failure for fread\"); } @@ -1211,7 +1220,8 @@ strcpy(real_template, template); strcat(real_template, \"XXXXXX\"); if( mkstemp(real_template) < 0 ) real_template[0] = '\0'; - %1 = C2KLIC(real_template, allocp); + set_heapp(allocp); + %1 = C2KLIC(real_template); allocp = heapp(); free(template); free(real_template); @@ -1254,7 +1264,8 @@ if( value==NULL ){ %1 = makeint(0); }else{ - %1 = C2KLIC(value, allocp); + set_heapp(allocp); + %1 = C2KLIC(value); allocp = heapp(); } }": [Name+object(byte_string), Value0-bound] | Value = Value0. @@ -1322,7 +1333,8 @@ L = []. make_argv_list(K, N, L) :- Kx = GC_ARGV[0];