$TERM is now set to dumb.
[bpt/emacs.git] / src / alloc.c
index f24d77f..8aea81a 100644 (file)
@@ -6,7 +6,7 @@ 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 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -131,7 +131,7 @@ static pthread_mutex_t alloc_mutex;
   do                                                    \
     {                                                   \
       if (pthread_equal (pthread_self (), main_thread)) \
-        sigblock (sigmask (SIGIO));                     \
+        BLOCK_INPUT;                                   \
       pthread_mutex_lock (&alloc_mutex);                \
     }                                                   \
   while (0)
@@ -140,7 +140,7 @@ static pthread_mutex_t alloc_mutex;
     {                                                   \
       pthread_mutex_unlock (&alloc_mutex);              \
       if (pthread_equal (pthread_self (), main_thread)) \
-        sigunblock (sigmask (SIGIO));                   \
+        UNBLOCK_INPUT;                                 \
     }                                                   \
   while (0)
 
@@ -266,7 +266,7 @@ Lisp_Object Vmemory_full;
    remapping on more recent systems because this is less important
    nowadays than in the days of small memories and timesharing.  */
 
-EMACS_INT pure[PURESIZE / sizeof (EMACS_INT)] = {1,};
+EMACS_INT pure[(PURESIZE + sizeof (EMACS_INT) - 1) / sizeof (EMACS_INT)] = {1,};
 #define PUREBEG (char *) pure
 
 #else /* HAVE_SHM */
@@ -341,7 +341,9 @@ Lisp_Object Vgc_elapsed;    /* accumulated elapsed time in GC  */
 EMACS_INT gcs_done;            /* accumulated GCs  */
 
 static void mark_buffer P_ ((Lisp_Object));
+extern void mark_terminals P_ ((void));
 extern void mark_kboards P_ ((void));
+extern void mark_ttys P_ ((void));
 extern void mark_backtrace P_ ((void));
 static void gc_sweep P_ ((void));
 static void mark_glyph_matrix P_ ((struct glyph_matrix *));
@@ -1179,8 +1181,6 @@ emacs_blocked_free (ptr, ptr2)
      void *ptr;
      const void *ptr2;
 {
-  EMACS_INT bytes_used_now;
-
   BLOCK_INPUT_ALLOC;
 
 #ifdef GC_MALLOC_CHECK
@@ -1236,7 +1236,8 @@ emacs_blocked_malloc (size, ptr)
   BLOCK_INPUT_ALLOC;
   __malloc_hook = old_malloc_hook;
 #ifdef DOUG_LEA_MALLOC
-    mallopt (M_TOP_PAD, malloc_hysteresis * 4096);
+  /* Segfaults on my system.  --lorentey */
+  /* mallopt (M_TOP_PAD, malloc_hysteresis * 4096); */
 #else
     __malloc_extra_blocks = malloc_hysteresis;
 #endif
@@ -1756,6 +1757,8 @@ init_strings ()
   string_blocks = NULL;
   n_string_blocks = 0;
   string_free_list = NULL;
+  empty_unibyte_string = make_pure_string ("", 0, 0, 0);
+  empty_multibyte_string = make_pure_string ("", 0, 0, 1);
 }
 
 
@@ -2479,6 +2482,9 @@ make_uninit_string (length)
      int length;
 {
   Lisp_Object val;
+
+  if (!length)
+    return empty_unibyte_string;
   val = make_uninit_multibyte_string (length, length);
   STRING_SET_UNIBYTE (val);
   return val;
@@ -2497,6 +2503,8 @@ make_uninit_multibyte_string (nchars, nbytes)
 
   if (nchars < 0)
     abort ();
+  if (!nbytes)
+    return empty_multibyte_string;
 
   s = allocate_string ();
   allocate_string_data (s, nchars, nbytes);
@@ -3615,9 +3623,9 @@ mem_insert (start, end, type)
 {
   struct mem_node *c, *parent, *x;
 
-  if (start < min_heap_address)
+  if (min_heap_address == NULL || start < min_heap_address)
     min_heap_address = start;
-  if (end > max_heap_address)
+  if (max_heap_address == NULL || end > max_heap_address)
     max_heap_address = end;
 
   /* See where in the tree a node for START belongs.  In this
@@ -4256,9 +4264,14 @@ mark_maybe_pointer (p)
 {
   struct mem_node *m;
 
-  /* Quickly rule out some values which can't point to Lisp data.  We
-     assume that Lisp data is aligned on even addresses.  */
-  if ((EMACS_INT) p & 1)
+  /* Quickly rule out some values which can't point to Lisp data.  */
+  if ((EMACS_INT) p %
+#ifdef USE_LSB_TAG
+      8 /* USE_LSB_TAG needs Lisp data to be aligned on multiples of 8.  */
+#else
+      2 /* We assume that Lisp data is aligned on even addresses.  */
+#endif
+      )
     return;
 
   m = mem_find (p);
@@ -5160,7 +5173,9 @@ returns nil, because real GC can't be done.  */)
       mark_object (bind->symbol);
       mark_object (bind->old_value);
     }
+  mark_terminals ();
   mark_kboards ();
+  mark_ttys ();
 
 #ifdef USE_GTK
   {
@@ -5595,6 +5610,7 @@ mark_object (arg)
          mark_object (ptr->menu_bar_vector);
          mark_object (ptr->buffer_predicate);
          mark_object (ptr->buffer_list);
+         mark_object (ptr->buried_buffer_list);
          mark_object (ptr->menu_bar_window);
          mark_object (ptr->tool_bar_window);
          mark_face_cache (ptr->face_cache);