From 5a1bf534e35ca456f39067c28543761cfba3dce0 Mon Sep 17 00:00:00 2001
From: rtoy <rtoy>
Date: Wed, 7 Jul 2004 20:31:06 +0000
Subject: [PATCH] Fix more compiler warnings:

* alloc.c:  Include gencgc.h to get declaration of alloc().
* gencgc.c:
  o Include string.h for memset.
  o Initialize some vars that gcc complains might be uninitialized
    (but they're not).
  o scav_fdefn isn't used on sparc, so comment it out.
  o valid_dynamic_space_pointer, maybe_adjust_large_object, and
    preserve_pointer are only used on x86, so comment #ifdef them for
    i386.
* os-common.c:
  o Fix a few printf warnings.
  o Cast args to bcopy.
---
 lisp/alloc.c     |  5 +++--
 lisp/gencgc.c    | 27 ++++++++++++++++++++++++---
 lisp/os-common.c |  9 ++++++---
 3 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/lisp/alloc.c b/lisp/alloc.c
index 07b31f03b..6d061ae6a 100644
--- a/lisp/alloc.c
+++ b/lisp/alloc.c
@@ -1,4 +1,4 @@
-/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/alloc.c,v 1.6 2004/05/18 22:37:34 cwang Exp $ */
+/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/alloc.c,v 1.7 2004/07/07 20:31:06 rtoy Exp $ */
 
 #include "lisp.h"
 #include "internals.h"
@@ -29,7 +29,8 @@ Allocation Routines.
 ****************************************************************/
 
 #if defined GENCGC
-#define alloc(nbytes) alloc_pseudo_atomic((nbytes))
+#define alloc(nbytes) alloc_pseudo_atomic(nbytes)
+#include "gencgc.h"
 #elif defined(WANT_CGC)
 extern lispobj *alloc(int bytes);
 #else
diff --git a/lisp/gencgc.c b/lisp/gencgc.c
index eea9a8231..abf84d2cf 100644
--- a/lisp/gencgc.c
+++ b/lisp/gencgc.c
@@ -7,13 +7,14 @@
  *
  * Douglas Crosher, 1996, 1997, 1998, 1999.
  *
- * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/gencgc.c,v 1.56 2004/07/07 15:03:11 rtoy Exp $
+ * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/gencgc.c,v 1.57 2004/07/07 20:31:06 rtoy Exp $
  *
  */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
+#include <string.h>
 #include "lisp.h"
 #include "arch.h"
 #include "internals.h"
@@ -734,6 +735,9 @@ void *current_region_end_addr;
 /* The generation currently being allocated to. X */
 static int  gc_alloc_generation;
 
+extern void do_dynamic_space_overflow_warning(void);
+extern void do_dynamic_space_overflow_error(void);
+
 /* Handle heap overflow here, maybe. */
 static void
 handle_heap_overflow(const char* msg, int size)
@@ -807,6 +811,9 @@ static void gc_alloc_new_region(int nbytes, int unboxed,
   int i;
   int mmask, mflags;
 
+  /* Shut up some compiler warnings */
+  last_page = bytes_found = 0;
+  
 #if 0
   fprintf(stderr, "alloc_new_region for %d bytes from gen %d\n",
 	  nbytes, gc_alloc_generation);
@@ -1238,6 +1245,10 @@ static void *gc_alloc_large(int  nbytes, int unboxed,
   int large = (nbytes >= large_object_size);
   int mmask, mflags;
 
+  
+  /* Shut up some compiler warnings */
+  last_page = bytes_found = 0;
+  
 #if 0
   if (nbytes > 200000)
     fprintf(stderr, "*** alloc_large %d\n", nbytes);
@@ -3234,6 +3245,8 @@ static int size_boxed(lispobj *where)
 	return length;
 }
 
+/* Not needed on sparc because the raw_addr has a function lowtag */
+#ifndef sparc
 static int scav_fdefn(lispobj *where, lispobj object)
 {
   struct fdefn *fdefn;
@@ -3252,6 +3265,7 @@ static int scav_fdefn(lispobj *where, lispobj object)
   else
     return 1;
 }
+#endif
 
 static int scav_unboxed(lispobj *where, lispobj object)
 {
@@ -4569,6 +4583,7 @@ lispobj *search_dynamic_space(lispobj *pointer)
   return search_space(start, pointer + 2 - start, pointer);
 }
 
+#ifdef i386
 static int valid_dynamic_space_pointer(lispobj *pointer)
 {
   lispobj *start_addr;
@@ -4745,7 +4760,7 @@ static int valid_dynamic_space_pointer(lispobj *pointer)
   /* Looks good */
   return TRUE;
 }
-
+#endif
 
 /*
  * Adjust large bignum and vector objects.  This will adjust the
@@ -4756,6 +4771,7 @@ static int valid_dynamic_space_pointer(lispobj *pointer)
  * this is missed, just may delay the moving of objects to unboxed
  * pages, and the freeing of pages.
  */
+#ifdef i386
 static void maybe_adjust_large_object(lispobj *where)
 {
   int first_page;
@@ -4900,7 +4916,7 @@ static void maybe_adjust_large_object(lispobj *where)
 
   return;
 }
-
+#endif
 
 /*
  * Take a possible pointer to a list object and mark the page_table so
@@ -4918,7 +4934,11 @@ static void maybe_adjust_large_object(lispobj *where)
  *
  * Also assumes the current gc_alloc region has been flushed and the
  * tables updated.
+ *
+ * Only needed on x86 because GC is conservative there.  Not needed on
+ * sparc because GC is precise, not conservative.
  */
+#ifdef i386
 static void preserve_pointer(void *addr)
 {
   int addr_page_index = find_page_index(addr);
@@ -5028,6 +5048,7 @@ static void preserve_pointer(void *addr)
 
   return;
 }
+#endif
 
 #ifdef CONTROL_STACKS
 /* Scavenge the thread stack conservative roots. */
diff --git a/lisp/os-common.c b/lisp/os-common.c
index 35f267caa..e589c141f 100644
--- a/lisp/os-common.c
+++ b/lisp/os-common.c
@@ -1,6 +1,6 @@
 /*
 
- $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/os-common.c,v 1.14 2004/07/07 15:03:12 rtoy Exp $
+ $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/os-common.c,v 1.15 2004/07/07 20:31:06 rtoy Exp $
 
  This code was written as part of the CMU Common Lisp project at
  Carnegie Mellon University, and has been placed in the public domain.
@@ -16,6 +16,8 @@
 #include "lisp.h"
 #include "lispregs.h"
 #include "globals.h"
+#include "interr.h"
+#include "arch.h"
 
 /* Except for os_zero, these routines are only called by Lisp code.  These
    routines may also be replaced by os-dependent versions instead.  See
@@ -50,7 +52,8 @@ os_vm_size_t length;
 	addr=os_validate(block_start,block_size);
 
 	if(addr==NULL || addr!=block_start)
-	    fprintf(stderr,"os_zero: block moved, 0x%08p ==> 0x%08p!\n",block_start,addr);
+          fprintf(stderr,"os_zero: block moved, 0x%p ==> 0x%8p!\n",
+                  (void*) block_start, (void*) addr);
     }
 }
 
@@ -94,7 +97,7 @@ os_vm_address_t os_reallocate(os_vm_address_t addr, os_vm_size_t old_len,
 	      os_vm_address_t new=os_allocate(len);
 
 	      if(new!=NULL){
-		bcopy(addr,new,old_len);
+		bcopy((char*)addr, (char*)new,old_len);
 		os_invalidate(addr,old_len);
 		}
 		
-- 
GitLab