Wild Life: memory.c Source File

Wild Life 2.30

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Macros
memory.c
Go to the documentation of this file.
1
6 /* Copyright 1991 Digital Equipment Corporation.
7 ** All Rights Reserved.
8 *****************************************************************/
9
10 #include "defs.h"
11
12 static long delta;
13
14 #ifdef prlDEBUG
15 static long amount_used;
16 #endif
17
18 #ifdef CLIFE
19 long pass;
20 #else
21 static long pass;
22 #endif /* CLIFE */
23
24 #define LONELY 1
25
26 static struct tms last_garbage_time;
27 static float gc_time, life_time;
28
29
30
31 // #define ALIGNUP(X) { (X) = (GENERIC)( ((long) (X) + (ALIGN-1)) & ~(ALIGN-1) ); }
32
41 char *GetStrOption(char *name,char *def)
42 {
43 int i;
44 char *result=def;
45 int l=strlen(name);
46
47 for(i=1; i<arg_c; i++)
48 if(arg_v[i][0]=='-' && (int)strlen(arg_v[i])>=l+1)
49 if(!strncmp(arg_v[i]+1,name,l))
50 if(arg_v[i][l+1]=='=')
51 result=arg_v[i]+l+2;
52 else
53 result=arg_v[i]+l+1;
54
55 return result;
56 }
57
64 int GetBoolOption(char *name)
65 {
66 char *s;
67 s=GetStrOption(name,"off");
68 return strcmp(s,"off");
69 }
70
78 int GetIntOption(char *name,int def)
79 {
80 char *s;
81 char buffer_loc[40];
82
83 (void)snprintf(buffer_loc,40,"%d",def);
84 s=GetStrOption(name,buffer_loc);
85 return atof(s);
86 }
87
94 void pchoices() /* RM: Oct 28 1993 For debugging. */
95 {
96 ptr_choice_point c;
97 printf("stack pointer is: %lx\n",(unsigned long)stack_pointer);
98 for(c=choice_stack;c;c=c->next)
99 printf("\tc=%lx\ts=%lx\tg=%lx\tu=%lx\n",(unsigned long)c,(unsigned long)c->stack_top,(unsigned long)c->goal_stack,(unsigned long)c->undo_point);
100 }
101
102 /****************************************************************************/
103
104 /* GC sanity checks */
105
106 /* Keep for release versions, unless the garbage collector is very robust */
107 /* #define GCTEST */
108
109 /* Remove for release versions */
110 /* #define GCVERBOSE */
111
112 #ifndef GCTEST
113 #undef assert
114 #define assert(N)
115 #endif
116
122 void print_undo_stack()
123 {
124 ptr_stack u=undo_stack;
125
126 while (u) {
127 if ((GENERIC)u->aaaa_3<mem_base || (GENERIC)u->aaaa_3>mem_limit ||
128 (GENERIC)u->next<mem_base || (GENERIC)u->next>mem_limit) {
129 printf("UNDO: type:%ld a:%lx b:%lx next:%lx\n",u->type,(unsigned long)u->aaaa_3,(unsigned long)u->bbbb_3,(unsigned long)u->next);
130 (void)fflush(stdout);
131 }
132 u=u->next;
133 }
134 }
135
143 long bounds_undo_stack()
144 {
145 ptr_stack u=undo_stack;
146
147 while (u) {
148 if ( (GENERIC)u<mem_base
149 || (GENERIC)u>mem_limit
150 || (!VALID_ADDRESS(u->aaaa_3) && !(u->type & undo_action))
151 ) {
152 if ((GENERIC)u<mem_base || (GENERIC)u>mem_limit) {
153 printf("\nUNDO: u=%lx\n",(long)u);
154 }
155 else {
156 printf("\nUNDO: u:%lx type:%ld a:%lx b:%lx next:%lx\n",
157 (unsigned long)u,(unsigned long)u->type,(unsigned long)u->aaaa_3,(unsigned long)u->bbbb_3,(unsigned long)u->next);
158 }
159 (void)fflush(stdout);
160 return FALSE;
161 }
162 u=u->next;
163 }
164
165 return TRUE;
166 }
167
168
169 /****************************************************************************/
170
171 /* Forward declarations */
172 static void check_psi_list();
173 static void check_resid_list(); /* 21.9 */
174 static void check_choice();
175 static void check_undo_stack();
176
177
178
179
189 void fail_all()
190 {
191 output_stream=stdout;
192 choice_stack=NULL;
193 goal_stack=NULL;
194 undo_stack=NULL;
195 (void)abort_life(TRUE);
196 /* printf("\n*** Abort\n"); */
197 stdin_cleareof();
198 (void)open_input_file("stdin");
199 }
200
201
202
203
204 /******************************************************************************
205
206 GARBAGE COLLECTING.
207
208 */
209
210
211
212 /* RM: Jan 29 1993 Replaced with PVR's version of 26.1 */
213
223 static void compress()
224 {
225 GENERIC addr, new_addr;
226 long len, i;
227
228 /* Compressing the stack: */
229
230 addr=new_addr=mem_base;
231 while (addr<=stack_pointer) {
232 len = *(addr+delta);
233 if (len) {
234 /* There are lots of these: */
235 /* if (len==LONELY) printf("Isolated LONELY at %lx\n",addr); */
236 if (len==LONELY) len=ALIGN;
237 else if (len & (ALIGN-1)) len=len-(len & (ALIGN-1))+ALIGN;
238 /* if (len & (ALIGN-1)) len=len-(len & (ALIGN-1))+ALIGN; 12.6 */
239 assert((len & (ALIGN-1))==0);
240 len /= sizeof(*addr);
241 assert(len>0);
242
243 for (i=0; i<len; i++) {
244 *new_addr = *addr;
245 if (i>0) {
246 if (*(addr+delta)>=len)
247 assert(i>0 ? *(addr+delta)<len : TRUE);
248 }
249 assert(VALID_ADDRESS(new_addr));
250 *(addr+delta) = (long)new_addr + 1; /* Set low bit */
251 #ifdef prlDEBUG
252 if (*(addr+delta) & 1 == 0)
253 printf ("compress: could be a bug ...\n");
254 #endif
255 addr++;
256 new_addr++;
257 }
258 }
259 else
260 addr++;
261 }
262 other_pointer=stack_pointer; /* 10.6 this var. is unused */
263 stack_pointer=new_addr;
264
265 /* Compressing the heap: */
266
267 addr=new_addr=mem_limit;
268 addr--; /* PVR fix: adding this statement avoids accessing beyond */
269 /* the memory's edge, which causes a segmentation fault on*/
270 /* SPARC. */
271 while (addr>=heap_pointer) {
272 skip_addr:
273 len= *(addr+delta);
274 if (len) {
275 if (len!=LONELY) {
276
277 if (len & (ALIGN-1)) len=len-(len & (ALIGN-1))+ALIGN;
278 assert((len & (ALIGN-1))==0);
279 len /= sizeof (*addr);
280 assert(len>0);
281
282 } else { /* len==LONELY */
283 GENERIC a;
284
285 if (len & (ALIGN-1)) len=len-(len & (ALIGN-1))+ALIGN;
286 assert((len & (ALIGN-1))==0);
287 len /= sizeof (*addr);
288 assert(len==1);
289
290 /* Check if the LONELY field is actually part of a block. */
291 /* If so, skip to the beginning of the block. */
292 a=addr;
293 do {
294 a--;
295 } while (a>=heap_pointer &&
296 (*(a+delta)==0 || *(a+delta)==LONELY));
297 if (a>=heap_pointer && *(a+delta)/sizeof(*a)+a>addr) {
298 addr=a;
299 goto skip_addr;
300 }
301 }
302
303 /* Move a block or an isolated LONELY field. */
304 addr += len;
305 for (i=0; i<len; i++) {
306 addr--;
307 new_addr--;
308 *new_addr = *addr;
309 assert(VALID_ADDRESS(new_addr));
310 *(addr+delta) = (long)new_addr + 1;
311 }
312 }
313 addr--;
314 }
315 heap_pointer=new_addr;
316 }
317
318 #define UNCHECKED(P) (! *((GENERIC)(P)+delta))
319
336 #ifdef CLIFE
337 long unchecked (GENERIC *p, long len)
338 #else
339 static long unchecked (GENERIC *p, long len)
340 #endif /* CLIFE */
341 {
342 GENERIC addr;
343 long result=FALSE, value;
344
345 assert(len>0);
346 if ((unsigned long)*p>MAX_BUILT_INS) {
347 #ifdef GCTEST
348 if (!VALID_ADDRESS(*p)) {
349 printf("p=%lx,*p=%lx\n",p,*p);
350 }
351 #endif
352 assert(VALID_ADDRESS(*p));
353 addr = *p + delta;
354 value = *addr;
355 switch (pass) {
356 case 1:
357 #ifdef GCTEST
358 if (FALSE /* len>100 || value>100 13.8 */) {
359 /* This does in fact happen */
360 printf("len=%ld,value=%ld\n",len,value);
361 fflush(stdout);
362 }
363 #endif
364 /* if (!value) */
365 if (!value || value==LONELY) {
366 /* Pointer not yet explored */
367 result=TRUE;
368 *addr=len;
369 #ifdef prlDEBUG
370 amount_used+=len;
371 #endif
372 }
373 else if (value < len && len != LONELY) {
374 Errorline("in garbage collection, %d < %d.\n", value, len);
375 }
376 else if (value > len && len != LONELY) {
377 Errorline("in garbage collection, %d > %d.\n", value, len);
378 }
379 break;
380 case 2:
381 if (value & 1) { /* If low bit set */
382 value--; /* Reset low bit */
383 *addr=value;
384 #ifdef prlDEBUG
385 amount_used+=len;
386 #endif
387 result=TRUE;
388 }
389 if (!VALID_ADDRESS(value))
390 assert(VALID_ADDRESS(value));
391 *p = (GENERIC) value;
392 break;
393 }
394 }
395 return result;
396 }
397
406 static void check_string (GENERIC *s)
407 {
408 GENERIC addr;
409 long value;
410 long bytes;
411
412 if ((unsigned long) *s > MAX_BUILT_INS) {
413 switch (pass) {
414 case 1:
415 bytes=strlen((char *)*s)+1;
416 /* if (bytes==LONELY) {
417 fprintf(stderr,"Caught an empty string!\n");
418 fflush(stderr);
419 } */
420 /* Make sure there's no conflict with LONELY (this occurs for an */
421 /* empty string, which still needs a single byte of storage). */
422 /* This does occasionally happen. */
423 (void)unchecked((GENERIC *)s, (bytes==LONELY)?bytes+1:bytes); // added cast DJD 12/8/2016
424 break;
425 case 2:
426 addr=(*s+delta);
427 value= *addr;
428 if (value & 1) { /* If low bit set */
429 value--;
430 *s=(GENERIC)value;
431 *addr=value;
432 #ifdef prlDEBUG
433 amount_used+=strlen(*s)+1;
434 #endif
435 }
436 *s=(GENERIC)value;
437 break;
438 }
439 }
440 }
441
442 /* DENYS: BYTEDATA */
451 static void check_bytedata(GENERIC *s)
452 {
453 GENERIC addr;
454 long value;
455 if ((unsigned long) *s > MAX_BUILT_INS) {
456 unsigned long bytes = *((unsigned long *) *s);
457 unsigned long size = bytes + sizeof(bytes);
458 switch (pass) {
459 case 1:
460 (void)unchecked((GENERIC *)s,size);
461 break;
462 case 2:
463 addr=(*s+delta);
464 value= *addr;
465 if (value & 1) {
466 value--;
467 *s=(GENERIC) value;
468 *addr=value;
469 #ifdef prlDEBUG
470 amount_used+=size;
471 #endif
472 }
473 *s=(GENERIC)value;
474 break;
475 }
476 }
477 }
478
487 static void check_code(ptr_int_list *c)
488 {
489 while (unchecked((GENERIC *)c,sizeof(int_list))) // added cast DJD 12/8/2016
490 c= &((*c)->next);
491 }
492
501 static void check_pair_list(ptr_pair_list *p)
502 {
503 while (unchecked((GENERIC *)p,sizeof(pair_list))) { // added cast DJD 12/8/2016
504 check_psi_term(&((*p)->aaaa_2));
505 check_psi_term(&((*p)->bbbb_2));
506 p= &((*p)->next);
507 }
508 }
509
518 static void check_triple_list(ptr_triple_list *p)
519 {
520 while (unchecked((GENERIC *)p,sizeof(triple_list))) { // added cast DJD 12/8/2016
521 check_psi_term(&((*p)->aaaa_4));
522 check_psi_term(&((*p)->bbbb_4));
523 check_definition(&((*p)->cccc_4));
524 p= &((*p)->next);
525 }
526 }
527
536 static void check_kids(ptr_int_list *c)
537 {
538 while (unchecked((GENERIC *) c,sizeof(int_list))) { // added cast DJD 12/8/2016
539 check_definition((ptr_definition *)&((*c)->value_1));
540 c= &((*c)->next);
541 }
542 }
543
552 static void check_operator_data(ptr_operator_data *op)
553 {
554 while (unchecked((GENERIC *) op,sizeof(operator_data))) { // added cast DJD 12/8/2016
555 op = &((*op)->next);
556 }
557 }
558
559 static void check_module();
560 // void check_hash_table(); /* RM: Feb 3 1993 */
561 static void check_keyword(); /* RM: Jan 12 1993 */
562
571 static void check_module_list(ptr_int_list *c) /* RM: Jan 12 1993 */
572 {
573 while (unchecked((GENERIC *)c,sizeof(int_list))) { // added cast DJD 12/8/2016
574 check_module(&((*c)->value_1));
575 c= &((*c)->next);
576 }
577 }
578
579
588 static void check_module_tree(ptr_node *n) /* RM: Jan 13 1993 */
589 {
590 if (unchecked((GENERIC *)n,sizeof(node))) { // added cast DJD 12/8/2016
591 check_module_tree(&((*n)->left));
592 check_string((GENERIC *)&((*n)->key)); // added cast DJD 12/8/2016
593 check_module(&((*n)->data));
594 check_module_tree(&((*n)->right));
595 }
596 }
597
606 static void check_module(ptr_module *m) /* RM: Jan 12 1993 */
607 {
608 if(unchecked((GENERIC *)m,sizeof(struct wl_module))) { // added cast DJD 12/8/2016
609 check_string((GENERIC *)&((*m)->module_name)); // added cast DJD 12/8/2016
610 check_string((GENERIC *)&((*m)->source_file)); // added cast DJD 12/8/2016
611 check_module_list(&((*m)->open_modules));
612 check_module_list(&((*m)->inherited_modules));
613 check_hash_table((*m)->symbol_table);
614 }
615 }
616
626 void check_hash_table(ptr_hash_table table) /* RM: Feb 3 1993 */
627 {
628 long i;
629
630 for(i=0;i<table->size;i++)
631 if(table->data[i])
632 check_keyword((ptr_keyword *)&(table->data[i]));
633 }
634
643 static void check_keyword(ptr_keyword *k) /* RM: Jan 12 1993 */
644 {
645 if(unchecked((GENERIC *)k,sizeof(struct wl_keyword))) { // added cast DJD 12/8/2016
646 check_module(&((*k)->module));
647 check_string((GENERIC *)&((*k)->symbol)); // added cast DJD 12/8/2016
648 check_string((GENERIC *)&((*k)->combined_name)); // added cast DJD 12/8/2016
649 check_definition(&((*k)->definition));
650 }
651 }
652
663 void check_definition(ptr_definition *d)
664 {
665 if(unchecked((GENERIC *)d,sizeof(definition))) { // added cast DJD 12/8/2016
666
667 check_keyword((ptr_keyword *)&((*d)->keyword)); /* RM: Jan 12 1993 */ // added cast DJD 12/8/2016
668
669 #ifdef prlDEBUG
670 printf("%lx %20s %ld\n",*d,(*d)->keyword->symbol,amount_used);
671 #endif
672
673 check_code((ptr_int_list *)&((*d)->code)); // added cast DJD 12/8/2016
674 check_pair_list((ptr_pair_list *)&((*d)->rule)); // added cast DJD 12/8/2016
675 check_triple_list(&((*d)->properties));
676
677 if ((*d)->type_def==(def_type)type_it) {
678 check_kids(&((*d)->parents));
679 check_kids(&((*d)->children));
680 }
681
682 check_psi_term(&((*d)->global_value)); /* RM: Feb 9 1993 */
683 check_psi_term(&((*d)->init_value)); /* RM: Mar 23 1993 */
684
685 check_operator_data(&((*d)->op_data)); /* PVR 5.6 */
686
687 #ifdef CLIFE
688 check_block_def(&((*d)->block_def)); /* RM: Jan 27 1993 */
689 #endif /* CLIFE */
690 }
691 }
692
700 void check_definition_list() /* RM: Feb 15 1993 */
701 {
702 ptr_definition *d;
703
704 d= &first_definition;
705
706 while(*d) {
707 check_definition(d);
708 d= &((*d)->next);
709 }
710 }
711
721 static void check_def_code(ptr_definition *d)
722 {
723 if (unchecked((GENERIC *)d,sizeof(definition))) // added cast DJD 12/8/2016
724 check_code((ptr_int_list *)&((*d)->code)); // added cast DJD 12/8/2016
725 /* p = &((*d)->properties); */
726 /* check_def_prop(p); */
727 }
728
738 static void check_def_rest(ptr_definition *d)
739 {
740 if (*d) {
741 check_keyword((ptr_keyword *)&((*d)->keyword)); /* RM: Jan 12 1993 */ // added cast DJD 12/8/2016
742 check_pair_list((ptr_pair_list *)&((*d)->rule)); // added cast DJD 12/8/2016
743 check_triple_list(&((*d)->properties));
744
745 if ((*d)->type_def==(def_type)type_it) {
746 check_kids(&((*d)->parents));
747 check_kids(&((*d)->children));
748 }
749 check_operator_data(&((*d)->op_data)); /* PVR 5.6 */
750 #ifdef CLIFE
751 check_block_def(&((*d)->block_def)); /*CB 25/01/93 */
752 #endif /* CLIFE */
753 }
754 }
755
765 static void check_symbol(ptr_node *n)
766 {
767 if (unchecked((GENERIC *)n,sizeof(node))) { // added cast DJD 12/8/2016
768 check_symbol(&((*n)->left));
769 check_string((GENERIC *)&((*n)->key)); // added cast DJD 12/8/2016
770 check_keyword((ptr_keyword *)&((*n)->data)); /* RM: Jan 12 1993 */ // added cast DJD 12/8/2016
771 check_symbol(&((*n)->right));
772 }
773 }
774
783 static void check_type_disj(ptr_int_list *p)
784 {
785 while (unchecked((GENERIC *)p,sizeof(int_list))) { // added cast DJD 12/8/2016
786 check_definition((struct wl_definition **)&((*p)->value_1));
787 p= &((*p)->next);
788 }
789 }
790
801 static void check_goal_stack(ptr_goal *g)
802 {
803 while (unchecked((GENERIC *)g,sizeof(goal))) { // added cast DJD 12/8/2016
804
805 switch ((*g)->type) {
806
807 case fail:
808 break;
809
810 case unify:
811 case unify_noeval: /* PVR 5.6 */
812 check_psi_term(&((*g)->aaaa_1));
813 check_psi_term(&((*g)->bbbb_1));
814 break;
815
816 case prove:
817 check_psi_term(&((*g)->aaaa_1));
818 if ((unsigned long)(*g)->bbbb_1!=DEFRULES) check_pair_list((ptr_pair_list *)&((*g)->bbbb_1)); // added cast DJD 12/8/2016
819 check_pair_list((ptr_pair_list *)&((*g)->cccc_1)); // added cast DJD 12/8/2016
820 break;
821
822 case disj:
823 check_psi_term(&((*g)->aaaa_1));
824 check_psi_term(&((*g)->bbbb_1));
825 break;
826
827 case what_next:
828 /* check_choice(&((*g)->bbbb_1)); */
829 break;
830
831 case eval:
832 check_psi_term(&((*g)->aaaa_1));
833 check_psi_term(&((*g)->bbbb_1));
834 check_pair_list((ptr_pair_list *)&((*g)->cccc_1)); // added cast DJD 12/8/2016
835 break;
836
837 case load:
838 check_psi_term(&((*g)->aaaa_1));
839 check_string((GENERIC *)&((*g)->cccc_1)); // added cast DJD 12/8/2016
840 break;
841
842 case match:
843 check_psi_term(&((*g)->aaaa_1));
844 check_psi_term(&((*g)->bbbb_1));
845 check_resid_block((struct wl_resid_block **)&((*g)->cccc_1));
846 break;
847
848 case general_cut:
849 /* assert((GENERIC)(*g)->aaaa_3 <= (GENERIC)choice_stack); 12.7 17.7 */
850 if (pass==1 && (ptr_choice_point)(*g)->aaaa_1>choice_stack)
851 (*g)->aaaa_1=(ptr_psi_term)choice_stack;
852 (void)unchecked((GENERIC *)&((*g)->aaaa_1),LONELY); // added cast DJD 12/8/2016
853 break;
854
855 case eval_cut:
856 check_psi_term(&((*g)->aaaa_1));
857 /* assert((GENERIC)(*g)->bbbb_1 <= (GENERIC)choice_stack); 12.7 17.7 */
858 if (pass==1 && (ptr_choice_point)(*g)->bbbb_1>choice_stack)
859 (*g)->bbbb_1=(ptr_psi_term)choice_stack;
860 (void)unchecked((GENERIC *)&((*g)->bbbb_1),LONELY); // added cast DJD 12/8/2016
861 check_resid_block((struct wl_resid_block **)&((*g)->cccc_1));
862 break;
863
864 case freeze_cut:
865 case implies_cut:
866 check_psi_term(&((*g)->aaaa_1));
867 /* assert((GENERIC)(*g)->bbbb_1 <= (GENERIC)choice_stack); 12.7 17.7 */
868 if (pass==1 && (ptr_choice_point)(*g)->bbbb_1>choice_stack)
869 (*g)->bbbb_1=(ptr_psi_term)choice_stack;
870 (void)unchecked((GENERIC *)&((*g)->bbbb_1),LONELY); // added cast DJD 12/8/2016
871 check_resid_block((struct wl_resid_block **)&((*g)->cccc_1));
872 break;
873
874 case type_disj:
875 check_psi_term(&((*g)->aaaa_1));
876 check_type_disj((ptr_int_list *)&((*g)->bbbb_1)); // added cast DJD 12/8/2016
877 break;
878
879 case clause:
880 check_psi_term(&((*g)->aaaa_1));
881 check_psi_term(&((*g)->bbbb_1));
882 (void)unchecked((GENERIC *)&((*g)->cccc_1),LONELY); // added cast DJD 12/8/2016
883 /* check_pair_list((*g)->cccc_1); */ /* 6.8 */
884 break;
885
886 case del_clause:
887 check_psi_term(&((*g)->aaaa_1));
888 check_psi_term(&((*g)->bbbb_1));
889 (void)unchecked((GENERIC *)&((*g)->cccc_1),LONELY); // added cast DJD 12/8/2016
890 /* check_pair_list((*g)->cccc_1); */ /* 6.8 */
891 break;
892
893 case retract:
894 (void)unchecked((GENERIC *)&((*g)->aaaa_1),LONELY); // added cast DJD 12/8/2016
895 /* check_pair_list((*g)->aaaa_1); */ /* 6.8 */
896 /*PVR*/ /* check_choice(&((*g)->bbbb_1)); 9.6 */
897 break;
898
899 default:
900 Errorline("in garbage collection, bad goal on stack.\n");
901 }
902
903 g= &((*g)->next);
904 }
905 }
906
915 static void check_resid(ptr_residuation *r)
916 {
917 ptr_int_list code;
918 ptr_list *l;
919
920 while (unchecked((GENERIC *)r,sizeof(residuation))) { // added cast DJD 12/8/2016
921
922 if ((*r)->sortflag) /* 22.9 */
923 check_definition((struct wl_definition **)&((*r)->bestsort));
924 else
925 check_code((ptr_int_list *)&((*r)->bestsort)); /* 21.9 */ // added cast DJD 12/8/2016
926
927 /* Handling of the value field (6.10) */
928 code = (*r)->sortflag ? ((ptr_definition)((*r)->bestsort))->code
929 : (ptr_int_list)(*r)->bestsort;
930 /* Copied (almost) verbatim from check_psi_term: */
931 if ((*r)->value_2) {
932 if (code==alist->code) { /* RM: Dec 15 1992 Will be removed */
933 l=(ptr_list *) &((*r)->value_2);
934 if (l)
935 printf("Found an old list!!\n");
936 }
937 else if (sub_CodeType(code,real->code))
938 (void)unchecked((GENERIC *)&((*r)->value_2),sizeof(REAL)); // added cast DJD 12/8/2016
939 else if (sub_CodeType(code,quoted_string->code))
940 check_string((GENERIC *)&((*r)->value_2)); // added cast DJD 12/8/2016
941 /* DENYS: BYTEDATA */
942 else if (sub_CodeType(code,sys_bytedata->code))
943 check_bytedata(&((*r)->value_2));
944 else if (sub_CodeType(code,cut->code)) {
945 if (pass==1 && (*r)->value_2>(GENERIC)choice_stack)
946 (*r)->value_2=(GENERIC)choice_stack;
947 (void)unchecked((GENERIC *)&((*r)->value_2),LONELY); // added cast DJD 12/8/2016
948 }
949 else if (sub_CodeType(code,variable->code)) /* 8.8 */
950 check_string((GENERIC *)&((*r)->value_2)); // added cast DJD 12/8/2016
951 }
952
953 check_goal_stack((ptr_goal *)&((*r)->goal)); // added cast DJD 12/8/2016
954 r= &((*r)->next);
955 }
956 }
957
966 void check_resid_block(ptr_resid_block *rb)
967 {
968 if (*rb) {
969 if (unchecked((GENERIC *)rb,sizeof(resid_block))) { // added cast DJD 12/8/2016
970 check_goal_stack((ptr_goal *)&((*rb)->ra)); // added cast DJD 12/8/2016
971 check_resid_list(&((*rb)->rv)); /* 21.9 */
972 /* unchecked(&((*rb)->rl),LONELY); 12.6 */ /* 10.6 */
973 (void)unchecked((GENERIC *)&((*rb)->md),LONELY); /* 10.6 */ // added cast DJD 12/8/2016
974 /* check_goal_stack(&((*rb)->rl)); 10.6 */
975 /* check_psi_term(&((*rb)->md)); 10.6 */
976 }
977 }
978 }
979
988 void check_psi_term(ptr_psi_term *t)
989 {
990 ptr_list *l;
991
992 while (unchecked((GENERIC *)t,sizeof(psi_term))) { // added cast DJD 12/8/2016
993
994 /* A psi-term on the heap has no residuation list. */
995 if (pass==1 && (GENERIC)(*t)>=heap_pointer && (GENERIC)(*t)<mem_limit) {
996 assert((*t)->resid==NULL);
997 }
998 check_definition(&((*t)->type));
999 check_attr(&((*t)->attr_list));
1000
1001 if ((*t)->value_3) {
1002
1003 if ((*t)->type==alist) { /* RM: Dec 15 1992 Should be removed */
1004 l=(ptr_list *) &((*t)->value_3);
1005 if (l)
1006 printf("Found an old list!\n");
1007 }
1008 else
1009
1010 if (sub_type((*t)->type,real))
1011 (void)unchecked((GENERIC *)&((*t)->value_3),sizeof(REAL)); // added cast DJD 12/8/2016
1012 else if (sub_type((*t)->type,quoted_string))
1013 check_string((GENERIC *)&((*t)->value_3)); // added cast DJD 12/8/2016
1014 /* DENYS: BYTEDATA */
1015 else if (sub_type((*t)->type,sys_bytedata))
1016 check_bytedata(&((*t)->value_3));
1017 #ifdef CLIFE
1018 else if ((*t)->type->type==block) { /* RM: Jan 27 1993 */
1019 check_block_value(&((*t)->value_3));
1020 }
1021 #endif /* CLIFE */
1022 else if ((*t)->type==cut) { /* RM: Oct 28 1993 */
1023 /* assert((*t)->value_3 <= (GENERIC)choice_stack); 12.7 17.7 */
1024 if (pass==1 && (*t)->value_3>(GENERIC)choice_stack)
1025 (*t)->value_3=(GENERIC)choice_stack;
1026 (void)unchecked((GENERIC *)&((*t)->value_3),LONELY); // added cast DJD 12/8/2016
1027 }
1028 else if (sub_type((*t)->type,variable)) /* 8.8 */
1029 check_string((GENERIC *)&((*t)->value_3)); // added cast DJD 12/8/2016
1030 else if ((*t)->type!=stream)
1031 Errorline("non-NULL value field in garbage collector, type='%s', value=%d.\n",
1032 (*t)->type->keyword->combined_name,
1033 (*t)->value_3);
1034 }
1035
1036 /* check_psi_term(&((*t)->coref)); 9.6 */
1037 if ((*t)->resid)
1038 check_resid((ptr_residuation *)&((*t)->resid)); // added cast DJD 12/8/2016
1039
1040 t = &((*t)->coref);
1041 }
1042 }
1043
1055 void check_attr(ptr_node *n)
1056 {
1057 while (unchecked((GENERIC *)n,sizeof(node))) { // added cast DJD 12/8/2016
1058 check_attr(&((*n)->left));
1059 check_string((GENERIC *)&((*n)->key)); // added cast DJD 12/8/2016
1060 check_psi_term((struct wl_psi_term **)&((*n)->data));
1061
1062 n = &((*n)->right);
1063 /* check_attr(&((*n)->right)); 9.6 */
1064 }
1065 }
1066
1079 void check_gamma_code()
1080 {
1081 long i;
1082
1083 if (unchecked((GENERIC *)&gamma_table,type_count*sizeof(ptr_definition))) { // added cast DJD 12/8/2016
1084 for (i=0;i<type_count;i++)
1085 check_def_code(&(gamma_table[i]));
1086 }
1087 }
1088
1096 static void check_gamma_rest()
1097 {
1098 long i;
1099
1100 for (i=0;i<type_count;i++)
1101 check_def_rest(&(gamma_table[i]));
1102 }
1103
1114 static void check_undo_stack(ptr_stack *s)
1115 {
1116 while (unchecked((GENERIC *)s,sizeof(stack))) { // added cast DJD 12/8/2016
1117
1118 switch((*s)->type) {
1119
1120 case psi_term_ptr:
1121 check_psi_term((struct wl_psi_term **)&((*s)->bbbb_3));
1122 break;
1123
1124 case resid_ptr:
1125 check_resid((ptr_residuation *)&((*s)->bbbb_3)); // added cast DJD 12/8/2016
1126 break;
1127
1128 case int_ptr:
1129 /* int_ptr's are used to trail time_stamps, so they can get large. */
1130 break;
1131
1132 case def_ptr:
1133 check_definition((struct wl_definition **)&((*s)->bbbb_3));
1134 break;
1135
1136 case code_ptr:
1137 check_code((ptr_int_list *)&((*s)->bbbb_3)); // added cast DJD 12/8/2016
1138 break;
1139
1140 case goal_ptr:
1141 check_goal_stack((ptr_goal *)&((*s)->bbbb_3)); // added cast DJD 12/8/2016
1142 break;
1143
1144 case cut_ptr: /* 22.9 */
1145 break;
1146 #ifdef CLIFE
1147 case block_ptr: /* CB: Jan 28 1993 */
1148 check_block_value(&((*s)->bbbb_3));
1149 break;
1150
1151 #endif /* CLIFE */
1152 /* All undo actions here */
1153 case destroy_window:
1154 case show_window:
1155 case hide_window:
1156 /* No pointers to follow */
1157 break;
1158 }
1159
1160 s= &((*s)->next);
1161 }
1162 }
1163
1170 static void check_choice_structs(ptr_choice_point *c)
1171 {
1172 while(unchecked((GENERIC *)c,sizeof(choice_point))) { // added cast DJD 12/8/2016
1173 c= &((*c)->next);
1174 }
1175 }
1176
1185 static void check_choice(ptr_choice_point *c)
1186 {
1187 while(*c) {
1188 check_undo_stack(&((*c)->undo_point)); /* 17.7 */
1189 check_goal_stack((ptr_goal *)&((*c)->goal_stack)); // added cast DJD 12/8/2016
1190 c= &((*c)->next);
1191 }
1192 }
1193
1203 static void check_special_addresses()
1204 {
1205 ptr_choice_point c;
1206 ptr_stack p;
1207 // ptr_goal g;
1208
1209 c=choice_stack;
1210 while(c) {
1211 /* unchecked(&(c->undo_point),LONELY); 17.7 */
1212 (void)unchecked((GENERIC *)&(c->stack_top),LONELY); // added cast DJD 12/8/2016
1213 c=c->next;
1214 }
1215
1216 p=undo_stack;
1217 while (p) {
1218 if (!(p->type & undo_action)) {
1219 /* Only update an address if it's within the Life data space! */
1220 if (VALID_RANGE(p->aaaa_3)) (void)unchecked((GENERIC *)&(p->aaaa_3),LONELY); // added cast DJD 12/8/2016
1221 if (p->type==cut_ptr) (void)unchecked((GENERIC *)&(p->bbbb_3),LONELY); /* 22.9 */ // added cast DJD 12/8/2016
1222 }
1223 p=p->next;
1224 }
1225 }
1226
1236 static void check_psi_list(ptr_int_list *l)
1237 {
1238 while(unchecked((GENERIC *)l,sizeof(int_list))) { // added cast DJD 12/8/2016
1239 check_psi_term((struct wl_psi_term **)&((*l)->value_1));
1240 l= &((*l)->next);
1241 }
1242 }
1243
1253 static void check_resid_list(ptr_resid_list *l)
1254 {
1255 while(unchecked((GENERIC *)l,sizeof(resid_list))) { // added cast DJD 12/8/2016
1256 check_psi_term(&((*l)->var));
1257 check_psi_term(&((*l)->othervar));
1258 l= &((*l)->next);
1259 }
1260 }
1261
1271 static void check_var(ptr_node *n)
1272 {
1273 if (unchecked((GENERIC *)n,sizeof(node))) { // added cast DJD 12/8/2016
1274 check_var(&((*n)->left));
1275 check_string((GENERIC *)&((*n)->key)); // added cast DJD 12/8/2016
1276 check_psi_term((struct wl_psi_term **)&((*n)->data));
1277 check_var(&((*n)->right));
1278 }
1279 }
1280
1300 static void check()
1301 {
1302 #ifdef prlDEBUG
1303 amount_used=0;
1304 #endif
1305
1306 /* First of all, get all the codes right so that data type-checking remains
1307 coherent.
1308
1309 Kids and Parents cannot be checked because the built-in types have codes
1310 which might have been moved.
1311 */
1312 /* print_undo_stack(); */
1313
1314
1315 check_choice_structs(&choice_stack); /* RM: Oct 28 1993 */
1316
1317 assert((pass==1?bounds_undo_stack():TRUE));
1318 check_gamma_code();
1319
1320 /* Now, check the rest of the definitions and all global roots */
1321
1322 check_gamma_rest();
1323
1324 assert((pass==1?bounds_undo_stack():TRUE));
1325
1326 check_definition(&abortsym); /* 26.1 */
1327 check_definition(&aborthooksym); /* 26.1 */
1328
1329 check_definition(&add_module1); /* RM: Mar 12 1993 */
1330 check_definition(&add_module2);
1331 check_definition(&add_module3);
1332
1333 check_definition(&and);
1334 check_definition(&apply);
1335 check_definition(&boolean);
1336 check_definition(&boolpredsym);
1337 check_definition(&built_in);
1338 check_definition(&colonsym);
1339 check_definition(&commasym);
1340 check_definition(&comment);
1341 /* check_definition(&conjunction); 19.8 */
1342 check_definition(&constant);
1343 check_definition(&cut);
1344 check_definition(&disjunction);
1345 check_definition(&disj_nil); /* RM: Feb 16 1993 */
1346 check_definition(&eof);
1347 check_definition(&eqsym);
1348 check_definition(&lf_false);
1349 check_definition(&funcsym);
1350 check_definition(&functor);
1351 check_definition(&iff);
1352 check_definition(&integer);
1353 check_definition(&alist);
1354 check_definition(&life_or); /* RM: Apr 6 1993 */
1355 check_definition(&minus_symbol); /* RM: Jun 21 1993 */
1356 check_definition(&nil); /* RM: Dec 9 1992 */
1357 check_definition(&nothing);
1358 check_definition(&predsym);
1359 check_definition(&quote);
1360 check_definition(&quoted_string);
1361 check_definition(&real);
1362 check_definition(&stream);
1363 check_definition(&succeed);
1364 check_definition(&such_that);
1365 check_definition(&top);
1366 check_definition(&lf_true);
1367 check_definition(&timesym);
1368 check_definition(&tracesym); /* 26.1 */
1369 check_definition(&typesym);
1370 check_definition(&variable);
1371 check_definition(&opsym);
1372 check_definition(&loadsym);
1373 check_definition(&dynamicsym);
1374 check_definition(&staticsym);
1375 check_definition(&encodesym);
1376 check_definition(&listingsym);
1377 /* check_definition(&provesym); */
1378 check_definition(&delay_checksym);
1379 check_definition(&eval_argsym);
1380 check_definition(&inputfilesym);
1381 check_definition(&call_handlersym);
1382 check_definition(&xf_sym);
1383 check_definition(&fx_sym);
1384 check_definition(&yf_sym);
1385 check_definition(&fy_sym);
1386 check_definition(&xfx_sym);
1387 check_definition(&xfy_sym);
1388 check_definition(&yfx_sym);
1389 check_definition(&nullsym);
1390
1391 /* RM: Jul 7 1993 */
1392 check_definition(&final_dot);
1393 check_definition(&final_question);
1394
1395 check_sys_definitions();
1396
1397 #ifdef X11
1398 check_definition(&xevent);
1399 check_definition(&xmisc_event);
1400 check_definition(&xkeyboard_event);
1401 check_definition(&xbutton_event);
1402 check_definition(&xconfigure_event);
1403 check_definition(&xmotion_event);
1404 check_definition(&xenter_event);
1405 check_definition(&xleave_event);
1406 check_definition(&xexpose_event);
1407 check_definition(&xdestroy_event);
1408 check_definition(&xdisplay);
1409 check_definition(&xdrawable);
1410 check_definition(&xwindow);
1411 check_definition(&xpixmap);
1412 check_definition(&xgc);
1413 check_definition(&xdisplaylist);
1414 #endif
1415
1416 /* check_psi_term(&empty_list); 5.8 */
1417
1418 check_string((GENERIC *)&one); // added cast DJD 12/8/2016
1419 check_string((GENERIC *)&two); // added cast DJD 12/8/2016
1420 check_string((GENERIC *)&three); // added cast DJD 12/8/2016
1421 check_string((GENERIC *)&year_attr); // added cast DJD 12/8/2016
1422 check_string((GENERIC *)&month_attr); // added cast DJD 12/8/2016
1423 check_string((GENERIC *)&day_attr); // added cast DJD 12/8/2016
1424 check_string((GENERIC *)&hour_attr); // added cast DJD 12/8/2016
1425 check_string((GENERIC *)&minute_attr); // added cast DJD 12/8/2016
1426 check_string((GENERIC *)&second_attr); // added cast DJD 12/8/2016
1427 check_string((GENERIC *)&weekday_attr); // added cast DJD 12/8/2016
1428
1429 check_psi_term(&input_state);
1430 check_psi_term(&stdin_state);
1431 check_psi_term(&error_psi_term);
1432 check_psi_term(&saved_psi_term);
1433 check_psi_term(&old_saved_psi_term);
1434 check_psi_term(&null_psi_term);
1435 check_psi_term(&old_state); /* RM: Feb 17 1993 */
1436
1437 assert((pass==1?bounds_undo_stack():TRUE));
1438 #ifdef X11
1439 check_psi_term(&xevent_list);
1440 check_psi_term(&xevent_existing);
1441 #endif
1442
1443 check_choice(&choice_stack);
1444 /* check_choice(&prompt_choice_stack); 12.7 */
1445
1446
1447 /* RM: Feb 3 1993 */
1448 /* check_symbol(&symbol_table); */
1449 /* check_definition(&first_definition); */
1450 check_definition_list(); /* RM: Feb 15 1993 */
1451
1452
1453 /*** MODULES ***/
1454 /* RM: Jan 13 1993 */
1455
1456 check_module_tree(&module_table);
1457 check_module(&sys_module);
1458 check_module(&bi_module);
1459 check_module(&user_module); /* RM: Jan 27 1993 */
1460 check_module(&no_module);
1461 check_module(&x_module);
1462 check_module(&syntax_module);
1463 check_module(&current_module);
1464
1465 /*** End ***/
1466
1467
1468
1469 check_var(&var_tree);
1470
1471 check_goal_stack((ptr_goal *)&goal_stack); // added cast DJD 12/8/2016
1472 check_goal_stack((ptr_goal *)&aim); /* 7.10 */ // added cast DJD 12/8/2016
1473
1474 if (TRUE /*resid_aim 10.6 */) check_resid_list(&resid_vars); /* 21.9 */
1475
1476 check_goal_stack((ptr_goal *)&resid_aim); // added cast DJD 12/8/2016
1477
1478 assert((pass==1?bounds_undo_stack():TRUE));
1479 check_undo_stack(&undo_stack);
1480
1481 assert((pass==1?bounds_undo_stack():TRUE));
1482 check_special_addresses();
1483
1484 assert((pass==1?bounds_undo_stack():TRUE));
1485 }
1486
1493 void print_gc_info(long timeflag)
1494 {
1495 fprintf(stderr," [%ld%% free (%ldK), %ld%% heap, %ld%% stack",
1496 (100*((unsigned long)heap_pointer-(unsigned long)stack_pointer)+mem_size/2)/mem_size,
1497 ((unsigned long)heap_pointer-(unsigned long)stack_pointer+512)/1024,
1498 (100*((unsigned long)mem_limit-(unsigned long)heap_pointer)+mem_size/2)/mem_size,
1499 (100*((unsigned long)stack_pointer-(unsigned long)mem_base)+mem_size/2)/mem_size);
1500 if (timeflag) {
1501 fprintf(stderr,", %1.3fs cpu (%ld%%)",
1502 gc_time,
1503 (unsigned long)(0.5+100*gc_time/(life_time+gc_time)));
1504 }
1505 fprintf(stderr,"]\n");
1506 }
1507
1508
1530 void garbage()
1531 {
1532 GENERIC addr;
1533 struct tms garbage_start_time,garbage_end_time;
1534 long start_number_cells, end_number_cells;
1535
1536 start_number_cells = (stack_pointer-mem_base) + (mem_limit-heap_pointer);
1537
1538 (void)times(&garbage_start_time);
1539
1540 /* Time elapsed since last garbage collection */
1541 life_time=(garbage_start_time.tms_utime - last_garbage_time.tms_utime)/60.0;
1542
1543
1544 if (verbose) {
1545 fprintf(stderr,"*** Garbage Collect "); /* RM: Jan 26 1993 */
1546 fprintf(stderr,"\n*** Begin");
1547 print_gc_info(FALSE);
1548 (void)fflush(stderr);
1549 }
1550
1551 /* reset the other base */
1552 for (addr = other_base; addr < other_limit; addr ++)
1553 *addr = 0;
1554
1555 pass=1;
1556
1557 check();
1558 #ifdef GCVERBOSE
1559 fprintf(stderr,"- Done pass 1 ");
1560 #endif
1561
1562 assert(bounds_undo_stack());
1563 compress();
1564 #ifdef GCVERBOSE
1565 fprintf(stderr,"- Done compress ");
1566 #endif
1567
1568 pass=2;
1569
1570 check();
1571 assert(bounds_undo_stack());
1572 #ifdef GCVERBOSE
1573 fprintf(stderr,"- Done pass 2\n");
1574 #endif
1575
1576 clear_copy();
1577
1578 printed_pointers=NULL;
1579 pointer_names=NULL;
1580
1581 (void)times(&garbage_end_time);
1582 gc_time=(garbage_end_time.tms_utime - garbage_start_time.tms_utime)/60.0;
1583 garbage_time+=gc_time;
1584
1585 if (verbose) {
1586 fprintf(stderr,"*** End ");
1587 print_gc_info(TRUE); /* RM: Jan 26 1993 */
1588 stack_info(stderr);
1589 (void)fflush(stderr);
1590 }
1591
1592 last_garbage_time=garbage_end_time;
1593
1594 end_number_cells = (stack_pointer-mem_base) + (mem_limit-heap_pointer);
1595 assert(end_number_cells<=start_number_cells);
1596
1597 ignore_eff=FALSE;
1598
1599 }
1600
1601 /****************************************************************************
1602 MEMORY ALLOCATION ROUTINES.
1603 */
1604
1616 GENERIC heap_alloc (long s)
1617 {
1618 if (s & (ALIGN-1))
1619 s = s - (s & (ALIGN-1))+ALIGN;
1620 /* assert(s % sizeof(*heap_pointer) == 0); */
1621 s /= sizeof (*heap_pointer);
1622
1623 heap_pointer -= s;
1624
1625 if (stack_pointer>heap_pointer)
1626 Errorline("the heap overflowed into the stack.\n");
1627
1628 return heap_pointer;
1629 }
1630
1642 GENERIC stack_alloc(long s)
1643 {
1644 GENERIC r;
1645
1646 r = stack_pointer;
1647
1648 if (s & (ALIGN-1))
1649 s = s - (s & (ALIGN-1)) + ALIGN;
1650 /* assert(s % sizeof(*stack_pointer) == 0); */
1651 s /= sizeof (*stack_pointer);
1652
1653 stack_pointer += s;
1654
1655 if (stack_pointer>heap_pointer)
1656 Errorline("the stack overflowed into the heap.\n");
1657
1658 return r;
1659 }
1660
1671 void init_memory ()
1672 {
1673 alloc_words=GetIntOption("memory",ALLOC_WORDS);
1674 mem_size=alloc_words * WORD;
1675
1676 mem_base = (GENERIC) malloc(mem_size);
1677 other_base = (GENERIC) malloc(mem_size);
1678
1679 if (mem_base && other_base) {
1680 /* Rewrote some rather poor code... RM: Mar 1 1994 */
1681 ALIGNUP(mem_base);
1682 stack_pointer = mem_base;
1683
1684 mem_limit=mem_base+alloc_words-2;
1685 ALIGNUP(mem_limit);
1686 heap_pointer = mem_limit;
1687
1688 ALIGNUP(other_base);
1689 other_pointer = other_base;
1690
1691 other_limit=other_base+alloc_words-2;
1692 ALIGNUP(other_limit);
1693
1694 delta = other_base - mem_base;
1695 buffer = (char *) malloc (PRINT_BUFFER); /* The printing buffer */
1696
1697 /* RM: Oct 22 1993 */
1698 /* Fill the memory with rubbish data */
1699 /*
1700 {
1701 int i;
1702
1703 for(i=0;i<alloc_words;i++) {
1704 mem_base[i]= -1234;
1705 other_base[i]= -1234;
1706 }
1707 }
1708 */
1709 }
1710 else
1711 Errorline("Wild_life could not allocate sufficient memory to run.\n\n");
1712 }
1713
1723 long memory_check ()
1724 {
1725 long success=TRUE;
1726
1727 if (heap_pointer-stack_pointer < GC_THRESHOLD) {
1728 if(verbose) fprintf(stderr,"\n"); /* RM: Feb 1 1993 */
1729 garbage();
1730 /* Abort if didn't recover at least GC_THRESHOLD/10 of memory */
1731 if (heap_pointer-stack_pointer < GC_THRESHOLD+GC_THRESHOLD/10) {
1732 fprintf(stderr,"*********************\n");
1733 fprintf(stderr,"*** OUT OF MEMORY ***\n");
1734 fprintf(stderr,"*********************\n");
1735 fail_all();
1736 success=FALSE;
1737 }
1738 }
1739 return success;
1740 }
1741
1742
1743
stack_pointer
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
WORD
#define WORD
Memory Word Size.
Definition: def_const.h:63
VALID_ADDRESS
#define VALID_ADDRESS(A)
Definition: def_macro.h:137
prove
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
check_type_disj
static void check_type_disj(ptr_int_list *p)
check_type_disj
Definition: memory.c:783
disjunction
ptr_definition disjunction
symbol in bi module
Definition: def_glob.h:249
wl_hash_table::data
ptr_keyword * data
Definition: def_struct.h:139
check_undo_stack
static void check_undo_stack()
printed_pointers
ptr_node printed_pointers
Definition: def_glob.h:1007
alist
ptr_definition alist
symbol in bi module
Definition: def_glob.h:319
memory_check
long memory_check()
memory_check
Definition: memory.c:1723
garbage_time
float garbage_time
total time on garbage collections - seconds
Definition: def_glob.h:76
stack_alloc
GENERIC stack_alloc(long s)
stack_alloc
Definition: memory.c:1642
succeed
ptr_definition succeed
symbol in bi module
Definition: def_glob.h:389
check_resid_list
static void check_resid_list()
check_bytedata
static void check_bytedata(GENERIC *s)
check_bytedata
Definition: memory.c:451
ALLOC_WORDS
#define ALLOC_WORDS
number of words to allocate if -memory=nnnnn not on command line
Definition: def_config.h:26
check
static void check()
check
Definition: memory.c:1300
xf_sym
ptr_definition xf_sym
symbol in bi module
Definition: def_glob.h:515
clear_copy
void clear_copy()
clear_copy
Definition: copy.c:53
heap_pointer
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
stdin_state
ptr_psi_term stdin_state
Definition: def_glob.h:857
apply
ptr_definition apply
symbol in bi module
Definition: def_glob.h:178
check_resid
static void check_resid(ptr_residuation *r)
check_resid
Definition: memory.c:915
lf_false
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
nothing
ptr_definition nothing
symbol in bi module
Definition: def_glob.h:347
integer
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
eqsym
ptr_definition eqsym
symbol in syntax module
Definition: def_glob.h:270
functor
ptr_definition functor
symbol in bi module
Definition: def_glob.h:298
wl_choice_point
Definition: def_struct.h:246
quote
ptr_definition quote
symbol in syntax module
Definition: def_glob.h:361
user_module
ptr_module user_module
Default module for user input.
Definition: def_glob.h:694
wl_hash_table
Definition: def_struct.h:136
final_question
ptr_definition final_question
symbol in syntax module
Definition: def_glob.h:615
wl_operator_data
Definition: def_struct.h:73
goal_stack
ptr_goal goal_stack
Definition: def_glob.h:1025
show_window
#define show_window
To backtrack on show window.
Definition: def_const.h:456
mem_limit
GENERIC mem_limit
starting point of heap - mem_base aligned
Definition: def_glob.h:62
type_count
long type_count
Definition: def_glob.h:1021
xdisplaylist
ptr_definition xdisplaylist
Definition: def_glob.h:1040
gc_time
static float gc_time
Definition: memory.c:27
VALID_RANGE
#define VALID_RANGE(A)
Definition: def_macro.h:127
def_ptr
#define def_ptr
values of type_ptr
Definition: def_const.h:404
wl_goal
Definition: def_struct.h:237
fail_all
void fail_all()
fail_all
Definition: memory.c:189
first_definition
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
xevent_list
ptr_psi_term xevent_list
Definition: def_glob.h:1037
check_goal_stack
static void check_goal_stack(ptr_goal *g)
check_goal_stack
Definition: memory.c:801
alloc_words
int alloc_words
number of words to allocate - from either command lind or ALLOC_WORDS define
Definition: def_glob.h:34
xbutton_event
ptr_definition xbutton_event
Definition: def_glob.h:1040
check_operator_data
static void check_operator_data(ptr_operator_data *op)
check_operator_data
Definition: memory.c:552
current_module
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
delay_checksym
ptr_definition delay_checksym
symbol in bi module
Definition: def_glob.h:487
cut
ptr_definition cut
symbol in syntax module
Definition: def_glob.h:242
verbose
long verbose
Definition: def_glob.h:914
two
char * two
Definition: def_glob.h:892
iff
ptr_definition iff
symbol in bi module
Definition: def_glob.h:305
wl_stack::bbbb_3
GENERIC * bbbb_3
Definition: def_struct.h:233
delta
static long delta
Definition: memory.c:12
wl_module
Definition: def_struct.h:105
general_cut
#define general_cut
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1114
timesym
ptr_definition timesym
symbol in bi module
Definition: def_glob.h:417
syntax_module
ptr_module syntax_module
Module for minimal Prolog syntax.
Definition: def_glob.h:715
check_string
static void check_string(GENERIC *s)
check_string
Definition: memory.c:406
implies_cut
#define implies_cut
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1107
comment
ptr_definition comment
symbol in bi module
Definition: def_glob.h:227
wl_hash_table::size
int size
Definition: def_struct.h:137
defs.h
includes
wl_psi_term
Definition: def_struct.h:177
listingsym
ptr_definition listingsym
symbol in bi module
Definition: def_glob.h:480
check_special_addresses
static void check_special_addresses()
check_special_addresses
Definition: memory.c:1203
wl_stack
Definition: def_struct.h:230
DEFRULES
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
fx_sym
ptr_definition fx_sym
symbol in bi module
Definition: def_glob.h:522
pass
static long pass
Definition: memory.c:21
destroy_window
#define destroy_window
To backtrack on window creation.
Definition: def_const.h:449
wl_triple_list
Definition: def_struct.h:211
stream
ptr_definition stream
symbol in bi module
Definition: def_glob.h:382
xexpose_event
ptr_definition xexpose_event
Definition: def_glob.h:1040
wl_choice_point::stack_top
GENERIC stack_top
Definition: def_struct.h:251
wl_residuation
Definition: def_struct.h:168
call_handlersym
ptr_definition call_handlersym
symbol in bi module
Definition: def_glob.h:508
wl_definition::keyword
ptr_keyword keyword
Definition: def_struct.h:147
wl_pair_list
Definition: def_struct.h:204
check_pair_list
static void check_pair_list(ptr_pair_list *p)
check_pair_list
Definition: memory.c:501
ptr_psi_term
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
dynamicsym
ptr_definition dynamicsym
symbol in bi module
Definition: def_glob.h:459
opsym
ptr_definition opsym
symbol in bi module
Definition: def_glob.h:445
cut_ptr
#define cut_ptr
values of type_ptr 22.9
Definition: def_const.h:425
NULL
#define NULL
Definition: def_const.h:533
var_tree
ptr_node var_tree
Definition: def_glob.h:1005
add_module3
ptr_definition add_module3
symbol in bi module for feature_values
Definition: def_glob.h:157
input_state
ptr_psi_term input_state
Definition: def_glob.h:856
add_module2
ptr_definition add_module2
symbol in bi module for str2psi
Definition: def_glob.h:150
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ignore_eff
long ignore_eff
Definition: def_glob.h:677
check_module
static void check_module()
heap_alloc
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
three
char * three
Definition: def_glob.h:893
wl_keyword::symbol
char * symbol
Definition: def_struct.h:118
funcsym
ptr_definition funcsym
symbol in syntax module
Definition: def_glob.h:291
xgc
ptr_definition xgc
Definition: def_glob.h:1040
resid_aim
ptr_goal resid_aim
Definition: def_glob.h:865
wl_choice_point::next
ptr_choice_point next
Definition: def_struct.h:250
eval_argsym
ptr_definition eval_argsym
symbol in bi module
Definition: def_glob.h:494
other_limit
GENERIC other_limit
only used for the half-space garbage collector
Definition: def_glob.h:104
xmotion_event
ptr_definition xmotion_event
Definition: def_glob.h:1040
unchecked
static long unchecked(GENERIC *p, long len)
unchecked
Definition: memory.c:339
and
ptr_definition and
symbol in syntax module
Definition: def_glob.h:171
resid_vars
ptr_resid_list resid_vars
Definition: def_glob.h:866
ptr_list
struct wl_list * ptr_list
Definition: def_struct.h:66
xmisc_event
ptr_definition xmisc_event
Definition: def_glob.h:1040
abort_life
long abort_life(int nlflag)
abort_life
Definition: built_ins.c:2259
eval
#define eval
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1086
pointer_names
ptr_node pointer_names
Definition: def_glob.h:1008
null_psi_term
ptr_psi_term null_psi_term
Used to represent an empty parse token.
Definition: def_glob.h:656
check_symbol
static void check_symbol(ptr_node *n)
check_symbol
Definition: memory.c:765
check_choice
static void check_choice()
other_pointer
GENERIC other_pointer
NOT USED - according to comment.
Definition: def_glob.h:111
built_in
ptr_definition built_in
symbol in bi module
Definition: def_glob.h:199
sys_bytedata
ptr_definition sys_bytedata
symbol in sys module
Definition: def_glob.h:983
old_state
ptr_psi_term old_state
used in token.c to save state to restore it later
Definition: def_glob.h:663
sub_type
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
check_definition
void check_definition(ptr_definition *d)
check_definition
Definition: memory.c:663
wl_int_list
Definition: def_struct.h:84
real
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
print_gc_info
void print_gc_info(long timeflag)
print_gc_info
Definition: memory.c:1493
type_it
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
inputfilesym
ptr_definition inputfilesym
symbol in bi module
Definition: def_glob.h:501
yf_sym
ptr_definition yf_sym
symbol in bi module
Definition: def_glob.h:529
hide_window
#define hide_window
To backtrack on hide window.
Definition: def_const.h:463
undo_stack
ptr_stack undo_stack
Definition: def_glob.h:1027
check_kids
static void check_kids(ptr_int_list *c)
check_kids
Definition: memory.c:536
Errorline
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
GENERIC
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
buffer
char * buffer
buffer used only in print.c - there is local with same name in xpred.c
Definition: def_glob.h:781
check_def_code
static void check_def_code(ptr_definition *d)
check_def_code
Definition: memory.c:721
variable
ptr_definition variable
symbol in bi module
Definition: def_glob.h:438
check_resid_block
void check_resid_block(ptr_resid_block *rb)
check_resid_block
Definition: memory.c:966
check_choice_structs
static void check_choice_structs(ptr_choice_point *c)
check_choice_structs
Definition: memory.c:1170
final_dot
ptr_definition final_dot
symbol in syntax module
Definition: def_glob.h:608
wl_stack::type
type_ptr type
Definition: def_struct.h:231
colonsym
ptr_definition colonsym
symbol in syntax module
Definition: def_glob.h:213
freeze_cut
#define freeze_cut
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1100
xkeyboard_event
ptr_definition xkeyboard_event
Definition: def_glob.h:1040
arg_c
int arg_c
set from argc in either life.c or lib.c
Definition: def_glob.h:20
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
xwindow
ptr_definition xwindow
Definition: def_glob.h:1040
name
char * name
Definition: def_glob.h:966
minus_symbol
ptr_definition minus_symbol
symbol in syntax module
Definition: def_glob.h:333
ALIGNUP
#define ALIGNUP(X)
Definition: def_macro.h:299
eof
ptr_definition eof
symbol in syntax module
Definition: def_glob.h:263
gamma_table
ptr_definition * gamma_table
Definition: def_glob.h:950
what_next
#define what_next
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1079
PRINT_BUFFER
#define PRINT_BUFFER
Size of print buffer.
Definition: def_const.h:211
match
#define match
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1121
other_base
GENERIC other_base
mem_size memory allocated in init_memory by malloc
Definition: def_glob.h:98
life_time
static float life_time
Definition: memory.c:27
constant
ptr_definition constant
symbol in bi module
Definition: def_glob.h:235
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
wl_resid_list
Definition: def_struct.h:94
abortsym
ptr_definition abortsym
symbol in bi module
Definition: def_glob.h:126
add_module1
ptr_definition add_module1
symbol in bi module for features
Definition: def_glob.h:143
check_triple_list
static void check_triple_list(ptr_triple_list *p)
check_triple_list
Definition: memory.c:518
staticsym
ptr_definition staticsym
symbol in bi module
Definition: def_glob.h:466
code_ptr
#define code_ptr
values of type_ptr
Definition: def_const.h:411
print_undo_stack
void print_undo_stack()
print_undo_stack
Definition: memory.c:122
clause
#define clause
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1135
ptr_definition
struct wl_definition * ptr_definition
Definition: def_struct.h:59
wl_keyword
Definition: def_struct.h:116
such_that
ptr_definition such_that
symbol in syntax module
Definition: def_glob.h:396
typesym
ptr_definition typesym
symbol in syntax module
Definition: def_glob.h:431
nil
ptr_definition nil
symbol in bi module
Definition: def_glob.h:340
check_psi_term
void check_psi_term(ptr_psi_term *t)
check_psi_term
Definition: memory.c:988
check_module_list
static void check_module_list(ptr_int_list *c)
check_module_list
Definition: memory.c:571
xfy_sym
ptr_definition xfy_sym
symbol in bi module
Definition: def_glob.h:550
fail
#define fail
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1044
aim
ptr_goal aim
Definition: def_glob.h:1024
disj_nil
ptr_definition disj_nil
symbol in syntax module
Definition: def_glob.h:256
weekday_attr
char * weekday_attr
Definition: def_glob.h:900
wl_resid_block
Definition: def_struct.h:261
xpixmap
ptr_definition xpixmap
Definition: def_glob.h:1040
one
char * one
Definition: def_glob.h:891
retract
#define retract
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1149
check_code
static void check_code(ptr_int_list *c)
check_code
Definition: memory.c:487
xenter_event
ptr_definition xenter_event
Definition: def_glob.h:1040
xevent
ptr_definition xevent
Definition: def_glob.h:1040
unify
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
commasym
ptr_definition commasym
symbol in syntax module
Definition: def_glob.h:220
init_memory
void init_memory()
init_memory ()
Definition: memory.c:1671
wl_stack::aaaa_3
GENERIC * aaaa_3
Definition: def_struct.h:232
GetBoolOption
int GetBoolOption(char *name)
GetBoolOption.
Definition: memory.c:64
arg_v
char * arg_v[ARGNN]
set from argv in either life.c or lib.c
Definition: def_glob.h:27
load
#define load
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1156
check_definition_list
void check_definition_list()
check_definition_list
Definition: memory.c:700
wl_definition
Definition: def_struct.h:145
compress
static void compress()
compress
Definition: memory.c:223
GetStrOption
char * GetStrOption(char *name, char *def)
GetStrOption.
Definition: memory.c:41
bi_module
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
saved_psi_term
ptr_psi_term saved_psi_term
Definition: def_glob.h:851
sys_module
ptr_module sys_module
Definition: def_glob.h:735
error_psi_term
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
unify_noeval
#define unify_noeval
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1065
top
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
garbage
void garbage()
garbage
Definition: memory.c:1530
yfx_sym
ptr_definition yfx_sym
symbol in bi module
Definition: def_glob.h:557
xdisplay
ptr_definition xdisplay
Definition: def_glob.h:1040
del_clause
#define del_clause
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1142
eval_cut
#define eval_cut
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1093
check_gamma_code
void check_gamma_code()
check_gamma_code
Definition: memory.c:1079
check_var
static void check_var(ptr_node *n)
check_var
Definition: memory.c:1271
module_table
ptr_node module_table
The table of modules.
Definition: def_glob.h:722
loadsym
ptr_definition loadsym
symbol in bi module
Definition: def_glob.h:452
stack_info
void stack_info(FILE *outfile)
stack_info
Definition: error.c:77
sub_CodeType
long sub_CodeType(ptr_int_list c1, ptr_int_list c2)
sub_CodeType
Definition: types.c:1618
undo_action
#define undo_action
Fast checking for an undo action.
Definition: def_const.h:484
check_hash_table
void check_hash_table(ptr_hash_table table)
check_hash_table
Definition: memory.c:626
minute_attr
char * minute_attr
Definition: def_glob.h:898
GC_THRESHOLD
#define GC_THRESHOLD
Garbage collection threshold (1/8 of MEM_SIZE is reasonable).
Definition: def_const.h:117
nullsym
ptr_definition nullsym
symbol in bi module
Definition: def_glob.h:564
xdestroy_event
ptr_definition xdestroy_event
Definition: def_glob.h:1040
no_module
ptr_module no_module
???
Definition: def_glob.h:701
output_stream
FILE * output_stream
Definition: def_glob.h:1017
check_module_tree
static void check_module_tree(ptr_node *n)
check_module_tree
Definition: memory.c:588
disj
#define disj
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1072
MAX_BUILT_INS
#define MAX_BUILT_INS
Maximum number of built_ins.
Definition: def_const.h:154
mem_base
GENERIC mem_base
mem_size memory allocated in init_memory by malloc
Definition: def_glob.h:48
year_attr
char * year_attr
Definition: def_glob.h:894
encodesym
ptr_definition encodesym
symbol in bi module
Definition: def_glob.h:473
fy_sym
ptr_definition fy_sym
symbol in bi module
Definition: def_glob.h:536
mem_size
int mem_size
number of words from memory = alloc_words * sizeof word
Definition: def_glob.h:41
GetIntOption
int GetIntOption(char *name, int def)
GetIntOption.
Definition: memory.c:78
pchoices
void pchoices()
pchoices
Definition: memory.c:94
wl_definition::code
ptr_int_list code
Definition: def_struct.h:150
second_attr
char * second_attr
Definition: def_glob.h:899
xleave_event
ptr_definition xleave_event
Definition: def_glob.h:1040
day_attr
char * day_attr
Definition: def_glob.h:896
check_psi_list
static void check_psi_list()
type_disj
#define type_disj
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1128
check_gamma_rest
static void check_gamma_rest()
check_gamma_rest
Definition: memory.c:1096
LONELY
#define LONELY
Definition: memory.c:24
lf_true
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
wl_node
Definition: def_struct.h:197
hour_attr
char * hour_attr
Definition: def_glob.h:897
aborthooksym
ptr_definition aborthooksym
symbol in bi module
Definition: def_glob.h:133
check_sys_definitions
void check_sys_definitions()
check_sys_definitions
Definition: sys.c:2186
xconfigure_event
ptr_definition xconfigure_event
Definition: def_glob.h:1040
stdin_cleareof
void stdin_cleareof()
stdin_cleareof
Definition: token.c:51
xevent_existing
ptr_psi_term xevent_existing
Definition: def_glob.h:1037
boolpredsym
ptr_definition boolpredsym
symbol in bi module
Definition: def_glob.h:192
resid_ptr
#define resid_ptr
values of type_ptr
Definition: def_const.h:390
check_keyword
static void check_keyword()
bounds_undo_stack
long bounds_undo_stack()
bounds_undo_stack
Definition: memory.c:143
check_attr
void check_attr(ptr_node *n)
check_attr
Definition: memory.c:1055
ALIGN
#define ALIGN
Definition: def_const.h:66
goal_ptr
#define goal_ptr
values of type_ptr
Definition: def_const.h:418
xfx_sym
ptr_definition xfx_sym
symbol in bi module
Definition: def_glob.h:543
wl_stack::next
ptr_stack next
Definition: def_struct.h:234
x_module
ptr_module x_module
'ifdef X11' unnecessary
Definition: def_glob.h:708
open_input_file
long open_input_file(char *file)
open_input_file
Definition: token.c:594
last_garbage_time
static struct tms last_garbage_time
Definition: memory.c:26
check_def_rest
static void check_def_rest(ptr_definition *d)
check_def_rest
Definition: memory.c:738
quoted_string
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
choice_stack
ptr_choice_point choice_stack
Definition: def_glob.h:1026
old_saved_psi_term
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:852
predsym
ptr_definition predsym
symbol in syntax module
Definition: def_glob.h:354
month_attr
char * month_attr
Definition: def_glob.h:895
assert
#define assert(N)
Definition: memory.c:114
xdrawable
ptr_definition xdrawable
Definition: def_glob.h:1040
tracesym
ptr_definition tracesym
symbol in bi module
Definition: def_glob.h:424
life_or
ptr_definition life_or
symbol in syntax module
Definition: def_glob.h:326
psi_term_ptr
#define psi_term_ptr
values of type_ptr
Definition: def_const.h:383
int_ptr
#define int_ptr
values of type_ptr
Definition: def_const.h:397