finish vm_memalign.c, though it's not a good idea after all and won't be used by default anywhere
svn: r5519
This commit is contained in:
parent
ad2d4cc775
commit
c9e5484762
|
@ -288,7 +288,8 @@ main.@LTO@: $(XSRCDIR)/main.c
|
|||
$(CC) $(CFLAGS) -c $(XSRCDIR)/main.c -o main.@LTO@
|
||||
|
||||
gc2.@LTO@: $(srcdir)/gc2.c $(srcdir)/newgc.c $(srcdir)/compact.c $(srcdir)/newgc.c $(srcdir)/gc2.h \
|
||||
$(srcdir)/vm_osx.c $(srcdir)/vm_mmap.c $(srcdir)/vm_osk.c $(srcdir)/alloc_cache.c \
|
||||
$(srcdir)/vm_osx.c $(srcdir)/vm_mmap.c $(srcdir)/vm_osk.c $(srcdir)/vm.c\
|
||||
$(srcdir)/vm_memalign.c $(srcdir)/alloc_cache.c \
|
||||
$(srcdir)/page_range.c $(srcdir)/protect_range.c $(srcdir)/var_stack.c $(srcdir)/stack_comp.c \
|
||||
$(srcdir)/../utils/splay.c $(srcdir)/my_qsort.c \
|
||||
$(srcdir)/weak.c $(srcdir)/fnls.c $(srcdir)/../include/scheme.h $(srcdir)/../src/schpriv.h
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/*
|
||||
Provides:
|
||||
posix_memalign-based allocator (uses alloc_cache.c)
|
||||
posix_memalign-based allocator
|
||||
determine_max_heap_size() (uses rlimit_heapsize.c)
|
||||
Requires:
|
||||
my_qsort (for alloc_cache.c)
|
||||
LOGICALLY_ALLOCATING_PAGES(len)
|
||||
ACTUALLY_ALLOCATING_PAGES(len)
|
||||
LOGICALLY_FREEING_PAGES(len)
|
||||
|
@ -27,7 +26,6 @@ static int page_size; /* OS page size */
|
|||
static void *malloc_dirty_pages(size_t len, size_t alignment)
|
||||
{
|
||||
void *r;
|
||||
size_t extra = 0;
|
||||
|
||||
if (!page_size)
|
||||
page_size = getpagesize();
|
||||
|
@ -38,13 +36,11 @@ static void *malloc_dirty_pages(size_t len, size_t alignment)
|
|||
if (len & (page_size - 1))
|
||||
len += page_size - (len & (page_size - 1));
|
||||
|
||||
/* Something from the cache, perhaps? */
|
||||
r = find_cached_pages(len, alignment);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (posix_memalign(&r, alignment, len))
|
||||
if (posix_memalign(&r, alignment, len)) {
|
||||
if (errno == EINVAL)
|
||||
printf("Invalid request\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ACTUALLY_ALLOCATING_PAGES(len);
|
||||
LOGICALLY_ALLOCATING_PAGES(len);
|
||||
|
@ -60,11 +56,17 @@ static void *malloc_pages(size_t len, size_t alignment)
|
|||
return p;
|
||||
}
|
||||
|
||||
static void system_free_pages(void *p, size_t len)
|
||||
static void free_pages(void *p, size_t len)
|
||||
{
|
||||
ACTUALLY_FREEING_PAGES(len);
|
||||
LOGICALLY_FREEING_PAGES(len);
|
||||
free(p);
|
||||
}
|
||||
|
||||
static void flush_freed_pages(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void protect_pages(void *p, size_t len, int writeable)
|
||||
{
|
||||
if (len & (page_size - 1)) {
|
||||
|
@ -74,8 +76,6 @@ static void protect_pages(void *p, size_t len, int writeable)
|
|||
mprotect(p, len, (writeable ? (PROT_READ | PROT_WRITE) : PROT_READ));
|
||||
}
|
||||
|
||||
# include "alloc_cache.c"
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
# include "rlimit_heapsize.c"
|
||||
|
|
Loading…
Reference in New Issue
Block a user