#define free overrun_check_free
#endif
-/* If compiled with XMALLOC_BLOCK_INPUT_CHECK, define a symbol
- BLOCK_INPUT_IN_MEMORY_ALLOCATORS that is visible to the debugger.
- If that variable is set, block input while in one of Emacs's memory
- allocation functions. There should be no need for this debugging
- option, since signal handlers do not allocate memory, but Emacs
- formerly allocated memory in signal handlers and this compile-time
- option remains as a way to help debug the issue should it rear its
- ugly head again. */
-#ifdef XMALLOC_BLOCK_INPUT_CHECK
-bool block_input_in_memory_allocators EXTERNALLY_VISIBLE;
-static void
-malloc_block_input (void)
-{
- if (block_input_in_memory_allocators)
- block_input ();
-}
-static void
-malloc_unblock_input (void)
-{
- if (block_input_in_memory_allocators)
- unblock_input ();
-}
-# define MALLOC_BLOCK_INPUT malloc_block_input ()
-# define MALLOC_UNBLOCK_INPUT malloc_unblock_input ()
-#else
-# define MALLOC_BLOCK_INPUT ((void) 0)
-# define MALLOC_UNBLOCK_INPUT ((void) 0)
-#endif
-
-#define MALLOC_PROBE(size) \
- do { \
- if (profiler_memory_running) \
- malloc_probe (size); \
- } while (0)
-
-
/* Like malloc but check for no memory and block interrupt input.. */
void *
{
void *val;
- MALLOC_BLOCK_INPUT;
val = malloc (size);
- MALLOC_UNBLOCK_INPUT;
if (!val && size)
memory_full (size);
- MALLOC_PROBE (size);
return val;
}
{
void *val;
- MALLOC_BLOCK_INPUT;
val = malloc (size);
- MALLOC_UNBLOCK_INPUT;
if (!val && size)
memory_full (size);
memset (val, 0, size);
- MALLOC_PROBE (size);
return val;
}
{
void *val;
- MALLOC_BLOCK_INPUT;
/* We must call malloc explicitly when BLOCK is 0, since some
reallocs don't do this. */
if (! block)
val = malloc (size);
else
val = realloc (block, size);
- MALLOC_UNBLOCK_INPUT;
if (!val && size)
memory_full (size);
- MALLOC_PROBE (size);
return val;
}
{
if (!block)
return;
- MALLOC_BLOCK_INPUT;
+
free (block);
- MALLOC_UNBLOCK_INPUT;
+
/* We don't call refill_memory_reserve here
because in practice the call in r_alloc_free seems to suffice. */
}
{
register void *val;
- MALLOC_BLOCK_INPUT;
-
#ifdef GC_MALLOC_CHECK
allocated_mem_type = type;
#endif
mem_insert (val, (char *) val + nbytes, type);
#endif
- MALLOC_UNBLOCK_INPUT;
if (!val && nbytes)
memory_full (nbytes);
- MALLOC_PROBE (nbytes);
return val;
}
static void
lisp_free (void *block)
{
- MALLOC_BLOCK_INPUT;
free (block);
#if GC_MARK_STACK && !defined GC_MALLOC_CHECK
mem_delete (mem_find (block));
#endif
- MALLOC_UNBLOCK_INPUT;
}
/***** Allocation of aligned blocks of memory to store Lisp data. *****/
eassert (nbytes <= BLOCK_BYTES);
- MALLOC_BLOCK_INPUT;
-
#ifdef GC_MALLOC_CHECK
allocated_mem_type = type;
#endif
#endif
if (base == 0)
- {
- MALLOC_UNBLOCK_INPUT;
- memory_full (ABLOCKS_BYTES);
- }
+ memory_full (ABLOCKS_BYTES);
aligned = (base == abase);
if (!aligned)
{
lisp_malloc_loser = base;
free (base);
- MALLOC_UNBLOCK_INPUT;
memory_full (SIZE_MAX);
}
}
mem_insert (val, (char *) val + nbytes, type);
#endif
- MALLOC_UNBLOCK_INPUT;
-
- MALLOC_PROBE (nbytes);
-
eassert (0 == ((uintptr_t) val) % BLOCK_ALIGN);
return val;
}
struct ablock *ablock = block;
struct ablocks *abase = ABLOCK_ABASE (ablock);
- MALLOC_BLOCK_INPUT;
#if GC_MARK_STACK && !defined GC_MALLOC_CHECK
mem_delete (mem_find (block));
#endif
+
/* Put on free list. */
ablock->x.next_free = free_ablock;
free_ablock = ablock;
#endif
free (ABLOCKS_BASE (abase));
}
- MALLOC_UNBLOCK_INPUT;
}
-
\f
/***********************************************************************
Interval Allocation
{
INTERVAL val;
- MALLOC_BLOCK_INPUT;
-
if (interval_free_list)
{
val = interval_free_list;
val = &interval_block->intervals[interval_block_index++];
}
- MALLOC_UNBLOCK_INPUT;
-
consing_since_gc += sizeof (struct interval);
intervals_consed++;
total_free_intervals--;
{
struct Lisp_String *s;
- MALLOC_BLOCK_INPUT;
-
/* If the free-list is empty, allocate a new string_block, and
add all the Lisp_Strings in it to the free-list. */
if (string_free_list == NULL)
s = string_free_list;
string_free_list = NEXT_FREE_LISP_STRING (s);
- MALLOC_UNBLOCK_INPUT;
-
--total_free_strings;
++total_strings;
++strings_consed;
else
old_data = NULL;
- MALLOC_BLOCK_INPUT;
-
if (nbytes > LARGE_STRING_BYTES)
{
size_t size = offsetof (struct sblock, data) + needed;
data = b->next_free;
b->next_free = (sdata *) ((char *) data + needed + GC_STRING_EXTRA);
- MALLOC_UNBLOCK_INPUT;
-
data->string = s;
s->data = SDATA_DATA (data);
#ifdef GC_CHECK_STRING_BYTES
{
register Lisp_Object val;
- MALLOC_BLOCK_INPUT;
-
if (float_free_list)
{
/* We use the data field for chaining the free list
float_block_index++;
}
- MALLOC_UNBLOCK_INPUT;
-
XFLOAT_INIT (val, float_value);
eassert (!FLOAT_MARKED_P (XFLOAT (val)));
consing_since_gc += sizeof (struct Lisp_Float);
{
register Lisp_Object val;
- MALLOC_BLOCK_INPUT;
-
if (cons_free_list)
{
/* We use the cdr for chaining the free list
cons_block_index++;
}
- MALLOC_UNBLOCK_INPUT;
-
XSETCAR (val, car);
XSETCDR (val, cdr);
eassert (!CONS_MARKED_P (XCONS (val)));
{
struct Lisp_Vector *p;
- MALLOC_BLOCK_INPUT;
+#ifdef DOUG_LEA_MALLOC
+ /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed
+ because mapped region contents are not preserved in
+ a dumped Emacs. */
+ mallopt (M_MMAP_MAX, 0);
+#endif
if (len == 0)
p = XVECTOR (zero_vector);
vector_cells_consed += len;
}
- MALLOC_UNBLOCK_INPUT;
-
return p;
}
CHECK_STRING (name);
- MALLOC_BLOCK_INPUT;
-
if (symbol_free_list)
{
XSETSYMBOL (val, symbol_free_list);
symbol_block_index++;
}
- MALLOC_UNBLOCK_INPUT;
-
p = XSYMBOL (val);
set_symbol_name (val, name);
set_symbol_plist (val, Qnil);
{
Lisp_Object val;
- MALLOC_BLOCK_INPUT;
-
if (marker_free_list)
{
XSETMISC (val, marker_free_list);
marker_block_index++;
}
- MALLOC_UNBLOCK_INPUT;
-
--total_free_markers;
consing_since_gc += sizeof (union Lisp_Misc);
misc_objects_consed++;
{
void *p;
- MALLOC_BLOCK_INPUT;
p = malloc (SPARE_MEMORY);
if (p)
{
free (p);
enough_free_memory = 1;
}
- MALLOC_UNBLOCK_INPUT;
}
if (! enough_free_memory)