* floatfns.c (Flogb): Always implement this by calling Flog, even
[bpt/emacs.git] / src / alloc.c
index 9f5cdd0..63463db 100644 (file)
@@ -1,11 +1,11 @@
 /* Storage allocation and gc for GNU Emacs Lisp interpreter.
-   Copyright (C) 1985, 1986, 1988, 1992 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1988, 1992, 1993 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -25,9 +25,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #ifndef standalone
 #include "buffer.h"
 #include "window.h"
-#ifdef MULTI_FRAME
 #include "frame.h"
-#endif /* MULTI_FRAME */
 #endif
 
 #include "syssignal.h"
@@ -116,6 +114,8 @@ static void mark_object (), mark_buffer ();
 static void clear_marks (), gc_sweep ();
 static void compact_strings ();
 \f
+/* Versions of malloc and realloc that print warnings as memory gets full.  */
+
 Lisp_Object
 malloc_warning_1 (str)
      Lisp_Object str;
@@ -181,6 +181,8 @@ xrealloc (block, size)
   return val;
 }
 \f
+/* Interval allocation.  */
+
 #ifdef USE_TEXT_PROPERTIES
 #define INTERVAL_BLOCK_SIZE \
   ((1020 - sizeof (struct interval_block *)) / sizeof (struct interval))
@@ -262,19 +264,22 @@ mark_interval_tree (tree)
   if (XMARKBIT (tree->plist))
     return;
 
-  traverse_intervals (tree, 1, &mark_interval);
+  traverse_intervals (tree, 1, 0, mark_interval);
 }
 
 #define MARK_INTERVAL_TREE(i) \
   { if (!NULL_INTERVAL_P (i)) mark_interval_tree (i); }
 
-#define UNMARK_BALANCE_INTERVALS(i) \
-{                                   \
-   if (! NULL_INTERVAL_P (i))       \
-     {                              \
-       XUNMARK ((Lisp_Object) (i->parent)); \
-       i = balance_intervals (i);           \
-     } \
+/* The oddity in the call to XUNMARK is necessary because XUNMARK
+   expands to an assigment to its argument, and most C compilers don't
+   support casts on the left operand of `='.  */
+#define UNMARK_BALANCE_INTERVALS(i)                            \
+{                                                              \
+   if (! NULL_INTERVAL_P (i))                                  \
+     {                                                         \
+       XUNMARK (* (Lisp_Object *) (&(i)->parent));             \
+       (i) = balance_intervals (i);                            \
+     }                                                                 \
 }
 
 #else  /* no interval use */
@@ -286,6 +291,8 @@ mark_interval_tree (tree)
 
 #endif /* no interval use */
 \f
+/* Floating point allocation.  */
+
 #ifdef LISP_FLOAT_TYPE
 /* Allocation of float cells, just like conses */
 /* We store float cells inside of float_blocks, allocating a new
@@ -885,6 +892,8 @@ make_array (nargs, args)
   }
 }
 \f
+/* Allocation of ropes.  */
+
 /* Note: the user cannot manipulate ropes portably by referring
    to the chars of the string, because combining two chars to make a GLYPH
    depends on endianness.  */
@@ -925,6 +934,7 @@ DEFUN ("rope-elt", Frope_elt, Srope_elt, 2, 2, 0,
 A rope is a string in which each pair of bytes is considered an element.\n\
 See variable `buffer-display-table' for the uses of ropes.")
   (r, n)
+    Lisp_Object r, n;
 {
   CHECK_STRING (r, 0);
   CHECK_NUMBER (n, 1);
@@ -933,6 +943,8 @@ See variable `buffer-display-table' for the uses of ropes.")
   return ((GLYPH *) XSTRING (r)->data)[XFASTINT (n)];
 }
 \f
+/* Pure storage management.  */
+
 /* Must get an error if pure storage is full,
  since if it cannot hold a large string
  it may be able to hold conses that point to that string;
@@ -980,6 +992,12 @@ make_pure_float (num)
 {
   register Lisp_Object new;
 
+  /* Make sure that pureptr is aligned on at least a sizeof (double)
+     boundary.  Some architectures (like the sparc) require this, and
+     I suspect that floats are rare enough that it's no tragedy for
+     those that do.  */
+  pureptr = (pureptr + sizeof (num) - 1) & - sizeof (num);
+
   if (pureptr + sizeof (struct Lisp_Float) > PURESIZE)
     error ("Pure Lisp storage exhausted");
   XSET (new, Lisp_Float, PUREBEG + pureptr);
@@ -1121,6 +1139,8 @@ struct backtrace
 you lose
 #endif
 \f
+/* Garbage collection!  */
+
 int total_conses, total_markers, total_symbols, total_string_size, total_vector_size;
 int total_free_conses, total_free_markers, total_free_symbols;
 #ifdef LISP_FLOAT_TYPE
@@ -1367,8 +1387,9 @@ clear_marks ()
 }
 #endif
 \f
-/* Mark reference to a Lisp_Object.  If the object referred to
-   has not been seen yet, recursively mark all the references contained in it.
+/* Mark reference to a Lisp_Object.
+  If the object referred to has not been seen yet, recursively mark
+  all the references contained in it.
 
    If the object referenced is a short string, the referrencing slot
    is threaded into a chain of such slots, pointed to from
@@ -1486,7 +1507,6 @@ mark_object (objptr)
       {
        register struct frame *ptr = XFRAME (obj);
        register int size = ptr->size;
-       register int i;
 
        if (size & ARRAY_MARK_FLAG) break;   /* Already marked */
        ptr->size |= ARRAY_MARK_FLAG; /* Else mark it */
@@ -1498,6 +1518,8 @@ mark_object (objptr)
        mark_object (&ptr->selected_window);
        mark_object (&ptr->minibuffer_window);
        mark_object (&ptr->param_alist);
+       mark_object (&ptr->scrollbars);
+       mark_object (&ptr->condemned_scrollbars);
       }
       break;
 #endif /* not MULTI_FRAME */
@@ -1588,7 +1610,6 @@ static void
 mark_buffer (buf)
      Lisp_Object buf;
 {
-  Lisp_Object tem;
   register struct buffer *buffer = XBUFFER (buf);
   register Lisp_Object *ptr;
 
@@ -1626,7 +1647,7 @@ mark_buffer (buf)
     mark_object (ptr);
 }
 \f
-/* Find all structures not marked, and free them. */
+/* Sweep: find all structures not marked, and free them. */
 
 static void
 gc_sweep ()
@@ -1885,8 +1906,7 @@ gc_sweep ()
   }
 }
 \f
-/* Compactify strings, relocate references to them, and
-   free any string blocks that become empty.  */
+/* Compactify strings, relocate references, and free empty string blocks.  */
 
 static void
 compact_strings ()
@@ -2015,7 +2035,7 @@ compact_strings ()
 DEFUN ("memory-limit", Fmemory_limit, Smemory_limit, 0, 0, "",
   "Return the address of the last byte Emacs has allocated, divided by 1024.\n\
 This may be helpful in debugging Emacs's memory usage.\n\
-The value is divided by 1024 to make sure it will fit in a lisp integer.")
+We divide the value by 1024 to make sure it fits in a Lisp integer.")
   ()
 {
   Lisp_Object end;