aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 0e68817629c..a120ce9b61f 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -49,10 +49,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
49#include <setjmp.h> 49#include <setjmp.h>
50#include <verify.h> 50#include <verify.h>
51 51
52/* GC_CHECK_MARKED_OBJECTS means do sanity checks on allocated objects.
53 Doable only if GC_MARK_STACK. */
54#if ! GC_MARK_STACK
55# undef GC_CHECK_MARKED_OBJECTS
56#endif
57
52/* GC_MALLOC_CHECK defined means perform validity checks of malloc'd 58/* GC_MALLOC_CHECK defined means perform validity checks of malloc'd
53 memory. Can do this only if using gmalloc.c. */ 59 memory. Can do this only if using gmalloc.c and if not checking
60 marked objects. */
54 61
55#if defined SYSTEM_MALLOC || defined DOUG_LEA_MALLOC 62#if (defined SYSTEM_MALLOC || defined DOUG_LEA_MALLOC \
63 || defined GC_CHECK_MARKED_OBJECTS)
56#undef GC_MALLOC_CHECK 64#undef GC_MALLOC_CHECK
57#endif 65#endif
58 66
@@ -82,6 +90,8 @@ extern POINTER_TYPE *sbrk ();
82 90
83extern size_t _bytes_used; 91extern size_t _bytes_used;
84extern size_t __malloc_extra_blocks; 92extern size_t __malloc_extra_blocks;
93extern void *_malloc_internal (size_t);
94extern void _free_internal (void *);
85 95
86#endif /* not DOUG_LEA_MALLOC */ 96#endif /* not DOUG_LEA_MALLOC */
87 97
@@ -314,7 +324,6 @@ static Lisp_Object Vdead;
314#ifdef GC_MALLOC_CHECK 324#ifdef GC_MALLOC_CHECK
315 325
316enum mem_type allocated_mem_type; 326enum mem_type allocated_mem_type;
317static int dont_register_blocks;
318 327
319#endif /* GC_MALLOC_CHECK */ 328#endif /* GC_MALLOC_CHECK */
320 329
@@ -390,9 +399,11 @@ static int live_float_p (struct mem_node *, void *);
390static int live_misc_p (struct mem_node *, void *); 399static int live_misc_p (struct mem_node *, void *);
391static void mark_maybe_object (Lisp_Object); 400static void mark_maybe_object (Lisp_Object);
392static void mark_memory (void *, void *); 401static void mark_memory (void *, void *);
402#if GC_MARK_STACK || defined GC_MALLOC_CHECK
393static void mem_init (void); 403static void mem_init (void);
394static struct mem_node *mem_insert (void *, void *, enum mem_type); 404static struct mem_node *mem_insert (void *, void *, enum mem_type);
395static void mem_insert_fixup (struct mem_node *); 405static void mem_insert_fixup (struct mem_node *);
406#endif
396static void mem_rotate_left (struct mem_node *); 407static void mem_rotate_left (struct mem_node *);
397static void mem_rotate_right (struct mem_node *); 408static void mem_rotate_right (struct mem_node *);
398static void mem_delete (struct mem_node *); 409static void mem_delete (struct mem_node *);
@@ -942,9 +953,6 @@ lisp_free (POINTER_TYPE *block)
942/* The entry point is lisp_align_malloc which returns blocks of at most 953/* The entry point is lisp_align_malloc which returns blocks of at most
943 BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary. */ 954 BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary. */
944 955
945/* Use posix_memalloc if the system has it and we're using the system's
946 malloc (because our gmalloc.c routines don't have posix_memalign although
947 its memalloc could be used). */
948#if defined (HAVE_POSIX_MEMALIGN) && defined (SYSTEM_MALLOC) 956#if defined (HAVE_POSIX_MEMALIGN) && defined (SYSTEM_MALLOC)
949#define USE_POSIX_MEMALIGN 1 957#define USE_POSIX_MEMALIGN 1
950#endif 958#endif
@@ -1001,7 +1009,7 @@ struct ablocks
1001 struct ablock blocks[ABLOCKS_SIZE]; 1009 struct ablock blocks[ABLOCKS_SIZE];
1002}; 1010};
1003 1011
1004/* Size of the block requested from malloc or memalign. */ 1012/* Size of the block requested from malloc or posix_memalign. */
1005#define ABLOCKS_BYTES (sizeof (struct ablocks) - BLOCK_PADDING) 1013#define ABLOCKS_BYTES (sizeof (struct ablocks) - BLOCK_PADDING)
1006 1014
1007#define ABLOCK_ABASE(block) \ 1015#define ABLOCK_ABASE(block) \
@@ -1223,6 +1231,10 @@ static void (*old_free_hook) (void*, const void*);
1223# define BYTES_USED _bytes_used 1231# define BYTES_USED _bytes_used
1224#endif 1232#endif
1225 1233
1234#ifdef GC_MALLOC_CHECK
1235static int dont_register_blocks;
1236#endif
1237
1226static size_t bytes_used_when_reconsidered; 1238static size_t bytes_used_when_reconsidered;
1227 1239
1228/* Value of _bytes_used, when spare_memory was freed. */ 1240/* Value of _bytes_used, when spare_memory was freed. */
@@ -1302,7 +1314,7 @@ emacs_blocked_malloc (size_t size, const void *ptr)
1302 { 1314 {
1303 fprintf (stderr, "Malloc returned %p which is already in use\n", 1315 fprintf (stderr, "Malloc returned %p which is already in use\n",
1304 value); 1316 value);
1305 fprintf (stderr, "Region in use is %p...%p, %u bytes, type %d\n", 1317 fprintf (stderr, "Region in use is %p...%p, %td bytes, type %d\n",
1306 m->start, m->end, (char *) m->end - (char *) m->start, 1318 m->start, m->end, (char *) m->end - (char *) m->start,
1307 m->type); 1319 m->type);
1308 abort (); 1320 abort ();
@@ -5826,7 +5838,7 @@ mark_buffer (Lisp_Object buf)
5826} 5838}
5827 5839
5828/* Mark the Lisp pointers in the terminal objects. 5840/* Mark the Lisp pointers in the terminal objects.
5829 Called by the Fgarbage_collector. */ 5841 Called by Fgarbage_collect. */
5830 5842
5831static void 5843static void
5832mark_terminals (void) 5844mark_terminals (void)