/* Block-relocating memory allocator.
- Copyright (C) 1993, 1995, 2000-2013 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1995, 2000-2014 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#else /* not emacs */
#include <stddef.h>
-
-#include <unistd.h>
#include <malloc.h>
#endif /* not emacs */
/* Macros for rounding. Note that rounding to any value is possible
by changing the definition of PAGE. */
#define PAGE (getpagesize ())
-#define ROUNDUP(size) (((size_t) (size) + page_size - 1) \
+#define PAGE_ROUNDUP(size) (((size_t) (size) + page_size - 1) \
& ~((size_t) (page_size - 1)))
#define MEM_ALIGN sizeof (double)
Get some extra, so we can come here less often. */
get = size + extra_bytes - already_available;
- get = (char *) ROUNDUP ((char *) last_heap->end + get)
+ get = (char *) PAGE_ROUNDUP ((char *) last_heap->end + get)
- (char *) last_heap->end;
if (real_morecore (get) != last_heap->end)
else
{
excess = ((char *) last_heap->end
- - (char *) ROUNDUP ((char *) last_heap->end - excess));
+ - (char *) PAGE_ROUNDUP ((char *) last_heap->end - excess));
/* If the system doesn't want that much memory back, leave
the end of the last heap unchanged to reflect that. This
can occur if break_value is still within the original
not always find a space which is contiguous to the previous. */
void *new_bloc_start;
heap_ptr h = first_heap;
- size_t get = ROUNDUP (size);
+ size_t get = PAGE_ROUNDUP (size);
- address = (void *) ROUNDUP (virtual_break_value);
+ address = (void *) PAGE_ROUNDUP (virtual_break_value);
/* Search the list upward for a heap which is large enough. */
while ((char *) h->end < (char *) MEM_ROUNDUP ((char *) address + get))
h = h->next;
if (h == NIL_HEAP)
break;
- address = (void *) ROUNDUP (h->start);
+ address = (void *) PAGE_ROUNDUP (h->start);
}
/* If not found, obtain more space. */
return 0;
if (first_heap == last_heap)
- address = (void *) ROUNDUP (virtual_break_value);
+ address = (void *) PAGE_ROUNDUP (virtual_break_value);
else
- address = (void *) ROUNDUP (last_heap->start);
+ address = (void *) PAGE_ROUNDUP (last_heap->start);
h = last_heap;
}
for (h = first_heap; h; h = h->next)
{
assert (h->prev == ph);
- assert ((void *) ROUNDUP (h->end) == h->end);
+ assert ((void *) PAGE_ROUNDUP (h->end) == h->end);
#if 0 /* ??? The code in ralloc.c does not really try to ensure
the heap start has any sort of alignment.
Perhaps it should. */
if (break_value == NULL)
emacs_abort ();
- extra_bytes = ROUNDUP (50000);
+ extra_bytes = PAGE_ROUNDUP (50000);
#endif
#ifdef DOUG_LEA_MALLOC
#endif
#ifndef SYSTEM_MALLOC
- first_heap->end = (void *) ROUNDUP (first_heap->start);
+ first_heap->end = (void *) PAGE_ROUNDUP (first_heap->start);
/* The extra call to real_morecore guarantees that the end of the
address space is a multiple of page_size, even if page_size is