0.6.12.3:
[sbcl.git] / src / runtime / purify.c
index 677db6d..2b4c72d 100644 (file)
  * files for more information.
  */
 
-/*
- * $Header$
- */
-
 #include <stdio.h>
 #include <sys/types.h>
 #include <stdlib.h>
 #include "gencgc.h"
 #endif
 
-#undef PRINTNOISE
+#define PRINTNOISE
 
 #if defined(ibmrt) || defined(__i386__)
+/* again, what's so special about the x86 that this is differently
+ * visible there than on other platforms? -dan 20010125 
+ */
 static lispobj *dynamic_space_free_pointer;
 #endif
 
@@ -250,14 +249,16 @@ valid_dynamic_space_pointer(lispobj *pointer, lispobj *start_addr)
     case type_ByteCodeClosure:
       if ((int)pointer != ((int)start_addr+type_FunctionPointer)) {
        if (pointer_filter_verbose) {
-         fprintf(stderr,"*Wf2: %x %x %x\n", pointer, start_addr, *start_addr);
+         fprintf(stderr,"*Wf2: %x %x %x\n", (unsigned int) pointer, 
+                 (unsigned int) start_addr, *start_addr);
        }
        return 0;
       }
       break;
     default:
       if (pointer_filter_verbose) {
-       fprintf(stderr,"*Wf3: %x %x %x\n", pointer, start_addr, *start_addr);
+       fprintf(stderr,"*Wf3: %x %x %x\n", (unsigned int) pointer, 
+               (unsigned int) start_addr, *start_addr);
       }
       return 0;
     }
@@ -265,7 +266,8 @@ valid_dynamic_space_pointer(lispobj *pointer, lispobj *start_addr)
   case type_ListPointer:
     if ((int)pointer != ((int)start_addr+type_ListPointer)) {
       if (pointer_filter_verbose)
-       fprintf(stderr,"*Wl1: %x %x %x\n", pointer, start_addr, *start_addr);
+       fprintf(stderr,"*Wl1: %x %x %x\n", (unsigned int) pointer, 
+               (unsigned int) start_addr, *start_addr);
       return 0;
     }
     /* Is it plausible cons? */
@@ -280,20 +282,23 @@ valid_dynamic_space_pointer(lispobj *pointer, lispobj *start_addr)
       break;
     } else {
       if (pointer_filter_verbose) {
-       fprintf(stderr,"*Wl2: %x %x %x\n", pointer, start_addr, *start_addr);
+       fprintf(stderr,"*Wl2: %x %x %x\n", (unsigned int) pointer, 
+               (unsigned int) start_addr, *start_addr);
       }
       return 0;
     }
   case type_InstancePointer:
     if ((int)pointer != ((int)start_addr+type_InstancePointer)) {
       if (pointer_filter_verbose) {
-       fprintf(stderr,"*Wi1: %x %x %x\n", pointer, start_addr, *start_addr);
+       fprintf(stderr,"*Wi1: %x %x %x\n", (unsigned int) pointer, 
+               (unsigned int) start_addr, *start_addr);
       }
       return 0;
     }
     if (TypeOf(start_addr[0]) != type_InstanceHeader) {
       if (pointer_filter_verbose) {
-       fprintf(stderr,"*Wi2: %x %x %x\n", pointer, start_addr, *start_addr);
+       fprintf(stderr,"*Wi2: %x %x %x\n", (unsigned int) pointer, 
+               (unsigned int) start_addr, *start_addr);
       }
       return 0;
     }
@@ -301,14 +306,16 @@ valid_dynamic_space_pointer(lispobj *pointer, lispobj *start_addr)
   case type_OtherPointer:
     if ((int)pointer != ((int)start_addr+type_OtherPointer)) {
       if (pointer_filter_verbose) {
-       fprintf(stderr,"*Wo1: %x %x %x\n", pointer, start_addr, *start_addr);
+       fprintf(stderr,"*Wo1: %x %x %x\n", (unsigned int) pointer, 
+               (unsigned int) start_addr, *start_addr);
       }
       return 0;
     }
     /* Is it plausible?  Not a cons. X should check the headers. */
     if(Pointerp(start_addr[0]) || ((start_addr[0] & 3) == 0)) {
       if (pointer_filter_verbose) {
-       fprintf(stderr,"*Wo2: %x %x %x\n", pointer, start_addr, *start_addr);
+       fprintf(stderr,"*Wo2: %x %x %x\n", (unsigned int) pointer, 
+               (unsigned int) start_addr, *start_addr);
       }
       return 0;
     }
@@ -316,7 +323,8 @@ valid_dynamic_space_pointer(lispobj *pointer, lispobj *start_addr)
     case type_UnboundMarker:
     case type_BaseChar:
       if (pointer_filter_verbose) {
-       fprintf(stderr,"*Wo3: %x %x %x\n", pointer, start_addr, *start_addr);
+       fprintf(stderr,"*Wo3: %x %x %x\n", (unsigned int) pointer, 
+               (unsigned int) start_addr, *start_addr);
       }
       return 0;
 
@@ -326,13 +334,15 @@ valid_dynamic_space_pointer(lispobj *pointer, lispobj *start_addr)
     case type_ByteCodeFunction:
     case type_ByteCodeClosure:
       if (pointer_filter_verbose) {
-       fprintf(stderr,"*Wo4: %x %x %x\n", pointer, start_addr, *start_addr);
+       fprintf(stderr,"*Wo4: %x %x %x\n", (unsigned int) pointer, 
+               (unsigned int) start_addr, *start_addr);
       }
       return 0;
 
     case type_InstanceHeader:
       if (pointer_filter_verbose) {
-       fprintf(stderr,"*Wo5: %x %x %x\n", pointer, start_addr, *start_addr);
+       fprintf(stderr,"*Wo5: %x %x %x\n", (unsigned int) pointer, 
+               (unsigned int) start_addr, *start_addr);
       }
       return 0;
 
@@ -403,14 +413,16 @@ valid_dynamic_space_pointer(lispobj *pointer, lispobj *start_addr)
 
     default:
       if (pointer_filter_verbose) {
-       fprintf(stderr,"*Wo6: %x %x %x\n", pointer, start_addr, *start_addr);
+       fprintf(stderr,"*Wo6: %x %x %x\n", (unsigned int) pointer, 
+               (unsigned int) start_addr, *start_addr);
       }
       return 0;
     }
     break;
   default:
     if (pointer_filter_verbose) {
-      fprintf(stderr,"*W?: %x %x %x\n", pointer, start_addr, *start_addr);
+      fprintf(stderr,"*W?: %x %x %x\n", (unsigned int) pointer, 
+             (unsigned int) start_addr, *start_addr);
     }
     return 0;
   }
@@ -480,7 +492,7 @@ pscav_i386_stack(void)
              *valid_stack_ra_locations[i],
              (int)(*valid_stack_ra_locations[i])
              - ((int)valid_stack_ra_code_objects[i] - (int)code_obj),
-             valid_stack_ra_code_objects[i], code_obj);
+             (unsigned int) valid_stack_ra_code_objects[i], code_obj);
     }
     *valid_stack_ra_locations[i] =
       ((int)(*valid_stack_ra_locations[i])
@@ -566,7 +578,7 @@ static lispobj ptrans_instance(lispobj thing, lispobj header, boolean constant)
        return (ptrans_boxed(thing, header, 0));
     case 0:
        {
-           /* Substructure: special case for the compact-info-envs, where
+           /* Substructure: special case for the COMPACT-INFO-ENVs, where
             * the instance may have a point to the dynamic space placed
             * into it (e.g. the cache-name slot), but the lists and arrays
             * at the time of a purify can be moved to the RO space. */
@@ -594,6 +606,7 @@ static lispobj ptrans_instance(lispobj thing, lispobj header, boolean constant)
        }
     default:
        gc_abort();
+       return NIL; /* dummy value: return something ... */
     }
 }
 
@@ -686,7 +699,6 @@ apply_code_fixups_during_purify(struct code *old_code, struct code *new_code)
   int nheader_words, ncode_words, nwords;
   void  *constants_start_addr, *constants_end_addr;
   void  *code_start_addr, *code_end_addr;
-  lispobj p;
   lispobj fixups = NIL;
   unsigned  displacement = (unsigned)new_code - (unsigned)old_code;
   struct vector *fixups_vector;
@@ -1147,7 +1159,7 @@ pscav_code(struct code*code)
 static lispobj *pscav(lispobj *addr, int nwords, boolean constant)
 {
     lispobj thing, *thingp, header;
-    int count;
+    int count = 0; /* (0 = dummy init value to stop GCC warning) */
     struct vector *vector;
 
     while (nwords > 0) {
@@ -1421,7 +1433,7 @@ int purify(lispobj static_roots, lispobj read_only_roots)
     fflush(stdout);
 #endif
 #ifndef __i386__
-    pscav((lispobj *)control_stack,
+    pscav((lispobj *)CONTROL_STACK_START,
          current_control_stack_pointer - (lispobj *)CONTROL_STACK_START,
          0);
 #else
@@ -1440,11 +1452,11 @@ int purify(lispobj static_roots, lispobj read_only_roots)
     fflush(stdout);
 #endif
 #if !defined(ibmrt) && !defined(__i386__)
-    pscav(BINDING_STACK_START,
-         current_binding_stack_pointer - (lispobj *)BINDING_STACK_START,
+    pscav( (lispobj *)BINDING_STACK_START,
+         (lispobj *)current_binding_stack_pointer - (lispobj *)BINDING_STACK_START,
          0);
 #else
-    pscav(BINDING_STACK_START,
+    pscav( (lispobj *)BINDING_STACK_START,
          (lispobj *)SymbolValue(BINDING_STACK_POINTER) -
          (lispobj *)BINDING_STACK_START,
          0);
@@ -1459,7 +1471,7 @@ int purify(lispobj static_roots, lispobj read_only_roots)
       fprintf(stderr,
              "scavenging read only space: %d bytes\n",
              read_only_space_size * sizeof(lispobj));
-      pscav(READ_ONLY_SPACE_START, read_only_space_size, 0);
+      pscav( (lispobj *)READ_ONLY_SPACE_START, read_only_space_size, 0);
     }
 #endif
 
@@ -1504,7 +1516,7 @@ int purify(lispobj static_roots, lispobj read_only_roots)
                (os_vm_size_t) DYNAMIC_SPACE_SIZE);
     }
 #else
-    os_zero((os_vm_address_t) DYNAMIC_SPACE_START,
+    os_zero((os_vm_address_t) current_dynamic_space,
             (os_vm_size_t) DYNAMIC_SPACE_SIZE);
 #endif
 
@@ -1541,7 +1553,7 @@ int purify(lispobj static_roots, lispobj read_only_roots)
     SetSymbolValue(STATIC_SPACE_FREE_POINTER, (lispobj)static_free);
 
 #if !defined(ibmrt) && !defined(__i386__)
-    dynamic_space_free_pointer = DYNAMIC_SPACE_START;
+    dynamic_space_free_pointer = current_dynamic_space;
 #else
 #if defined(WANT_CGC) && defined(X86_CGC_ACTIVE_P)
     /* X86 using CGC */