mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-02-17 06:31:14 +00:00
16-byte aligned memory allocator will try the following functions in-order
(determined at compile-time): posix_memalign, memalign, valloc, malloc.
This commit is contained in:
parent
ae93ea2f16
commit
47348e8120
@ -223,6 +223,7 @@ AC_CHECK_FUNCS(nanosleep)
|
|||||||
AC_CHECK_FUNCS(sigaction signal)
|
AC_CHECK_FUNCS(sigaction signal)
|
||||||
AC_CHECK_FUNCS(mmap mprotect munmap)
|
AC_CHECK_FUNCS(mmap mprotect munmap)
|
||||||
AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
|
AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
|
||||||
|
AC_CHECK_FUNCS(posix_memalign memalign valloc)
|
||||||
|
|
||||||
dnl Darwin seems to define mach_task_self() instead of task_self().
|
dnl Darwin seems to define mach_task_self() instead of task_self().
|
||||||
AC_CHECK_FUNCS(mach_task_self task_self)
|
AC_CHECK_FUNCS(mach_task_self task_self)
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "ether.h"
|
#include "ether.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#if ENABLE_MON
|
#if ENABLE_MON
|
||||||
#include "mon.h"
|
#include "mon.h"
|
||||||
@ -167,16 +168,31 @@ void *operator new(size_t size)
|
|||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
/* XXX: try different approaches */
|
#if defined(HAVE_POSIX_MEMALIGN)
|
||||||
if (posix_memalign(&p, 16, size) != 0)
|
if (posix_memalign(&p, 16, size) != 0)
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
|
#elif defined(HAVE_MEMALIGN)
|
||||||
|
p = memalign(16, size);
|
||||||
|
#elif defined(HAVE_VALLOC)
|
||||||
|
p = valloc(size); // page-aligned!
|
||||||
|
#else
|
||||||
|
/* XXX: handle padding ourselves */
|
||||||
|
p = malloc(size);
|
||||||
|
#endif
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator delete(void *p)
|
void operator delete(void *p)
|
||||||
{
|
{
|
||||||
|
#if defined(HAVE_MEMALIGN) || defined(HAVE_VALLOC)
|
||||||
|
#if defined(__GLIBC__)
|
||||||
|
// this is known to work only with GNU libc
|
||||||
free(p);
|
free(p);
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
free(p);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
sheepshaver_cpu::sheepshaver_cpu()
|
sheepshaver_cpu::sheepshaver_cpu()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user