diff src/vm-limit.c @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 3ecd8885ac67
children e38acbeb1cae
line wrap: on
line diff
--- a/src/vm-limit.c	Mon Aug 13 11:33:40 2007 +0200
+++ b/src/vm-limit.c	Mon Aug 13 11:35:02 2007 +0200
@@ -45,7 +45,7 @@
 
 /* Function to call to issue a warning;
    0 means don't issue them.  */
-static void (*warn_function) (CONST char *);
+static void (*warn_function) (const char *);
 
 /* Get more memory space, complaining if we're near the end. */
 
@@ -57,6 +57,7 @@
   POINTER cp;
   unsigned long five_percent;
   unsigned long data_size;
+  void (*save_warn_fun) (const char *);
 
   if (lim_data == 0)
     get_lim_data ();
@@ -67,36 +68,43 @@
   data_size = (char *) cp - (char *) data_space_start;
 
   if (warn_function)
-    switch (warnlevel)
-      {
-      case 0:
-	if (data_size > five_percent * 15)
-	  {
-	    warnlevel++;
-	    (*warn_function) ("Warning: past 75% of memory limit");
-	  }
-	break;
+    {
+      /* temporarily reset the warn_function to 0 or we will get infinite
+	 looping. */
+      save_warn_fun = warn_function;
+      warn_function = 0;
+      switch (warnlevel)
+	{
+	case 0:
+	  if (data_size > five_percent * 15)
+	    {
+	      warnlevel++;
+	      (*save_warn_fun) ("Warning: past 75% of memory limit");
+	    }
+	  break;
 
-      case 1:
-	if (data_size > five_percent * 17)
-	  {
-	    warnlevel++;
-	    (*warn_function) ("Warning: past 85% of memory limit");
-	  }
-	break;
+	case 1:
+	  if (data_size > five_percent * 17)
+	    {
+	      warnlevel++;
+	      (*save_warn_fun) ("Warning: past 85% of memory limit");
+	    }
+	  break;
 
-      case 2:
-	if (data_size > five_percent * 19)
-	  {
-	    warnlevel++;
-	    (*warn_function) ("Warning: past 95% of memory limit");
-	  }
-	break;
+	case 2:
+	  if (data_size > five_percent * 19)
+	    {
+	      warnlevel++;
+	      (*save_warn_fun) ("Warning: past 95% of memory limit");
+	    }
+	  break;
 
-      default:
-	(*warn_function) ("Warning: past acceptable memory limits");
-	break;
-      }
+	default:
+	  (*save_warn_fun) ("Warning: past acceptable memory limits");
+	  break;
+	}
+      warn_function = save_warn_fun;
+    }
 
   /* If we go down below 70% full, issue another 75% warning
      when we go up again.  */
@@ -112,19 +120,30 @@
     warnlevel = 2;
 
   if (EXCEEDS_LISP_PTR (cp))
-    (*warn_function) ("Warning: memory in use exceeds lisp pointer size");
+    {
+      if (warn_function)
+	{
+	  /* temporarily reset the warn_function to 0 or we will get infinite
+	     looping. */
+	  save_warn_fun = warn_function;
+	  warn_function = 0;
+	  (*save_warn_fun)
+	    ("Warning: memory in use exceeds lisp pointer size");
+	  warn_function = save_warn_fun;
+	}
+    }
 }
 
 /* Cause reinitialization based on job parameters;
    also declare where the end of pure storage is. */
 
 void
-memory_warnings (void *start, void (*warnfun) (CONST char *))
+memory_warnings (void *start, void (*warnfun) (const char *))
 {
   extern void (* __after_morecore_hook) (void);	/* From gmalloc.c */
 
   if (start)
-    data_space_start = start;
+    data_space_start = (char*) start;
   else
     data_space_start = start_of_data ();