# include <sys/uio.h>
# include <malloc.h> /* for locking */
#endif
-#if defined(USE_MMAP) || defined(USE_MUNMAP)
+#if defined(USE_MUNMAP)
# ifndef USE_MMAP
--> USE_MUNMAP requires USE_MMAP
# endif
+#endif
+#if defined(USE_MMAP) || defined(USE_MUNMAP) || defined(FALLBACK_TO_MMAP)
# include <sys/types.h>
# include <sys/mman.h>
# include <sys/stat.h>
# else
# if defined(MPROTECT_VDB) || defined(PROC_VDB) || defined(USE_MMAP) \
- || defined(USE_MUNMAP)
+ || defined(USE_MUNMAP) || defined(FALLBACK_TO_MMAP)
void GC_setpagesize()
{
GC_page_size = GETPAGESIZE();
# endif
# if defined(SUNOS5SIGS) || defined(IRIX5) || defined(OSF1) \
- || defined(HURD) || defined(NETBSD)
+ || defined(HURD) || defined(NETBSD) || defined(FREEBSD)
static struct sigaction old_segv_act;
# if defined(_sigargs) /* !Irix6.x */ || defined(HPUX) \
- || defined(HURD) || defined(NETBSD)
+ || defined(HURD) || defined(NETBSD) || defined(FREEBSD)
static struct sigaction old_bus_act;
# endif
# else
# endif
{
# if defined(SUNOS5SIGS) || defined(IRIX5) \
- || defined(OSF1) || defined(HURD) || defined(NETBSD)
+ || defined(OSF1) || defined(HURD) || defined(NETBSD) || defined(FREEBSD)
struct sigaction act;
act.sa_handler = h;
# else
(void) sigaction(SIGSEGV, &act, &old_segv_act);
# if defined(IRIX5) && defined(_sigargs) /* Irix 5.x, not 6.x */ \
- || defined(HPUX) || defined(HURD) || defined(NETBSD)
+ || defined(HPUX) || defined(HURD) || defined(NETBSD) || defined(FREEBSD)
/* Under Irix 5.x or HP/UX, we may get SIGBUS. */
/* Pthreads doesn't exist under Irix 5.x, so we */
/* don't have to worry in the threads case. */
void GC_reset_fault_handler()
{
# if defined(SUNOS5SIGS) || defined(IRIX5) \
- || defined(OSF1) || defined(HURD) || defined(NETBSD)
+ || defined(OSF1) || defined(HURD) || defined(NETBSD) || defined(FREEBSD)
(void) sigaction(SIGSEGV, &old_segv_act, 0);
# if defined(IRIX5) && defined(_sigargs) /* Irix 5.x, not 6.x */ \
- || defined(HPUX) || defined(HURD) || defined(NETBSD)
+ || defined(HPUX) || defined(HURD) || defined(NETBSD) || defined(FREEBSD)
(void) sigaction(SIGBUS, &old_bus_act, 0);
# endif
# else
/* since the correct value of __libc_stack_end never */
/* becomes visible to us. The second test works around */
/* this. */
+#if USE_LIBC_PRIVATE_SYMBOLS
if (0 != &__libc_stack_end && 0 != __libc_stack_end ) {
# ifdef IA64
/* Some versions of glibc set the address 16 bytes too */
return __libc_stack_end;
# endif
}
+#endif
f = open("/proc/self/stat", O_RDONLY);
if (f < 0 || STAT_READ(f, stat_buf, STAT_BUF_SIZE) < 2 * STAT_SKIP) {
ABORT("Couldn't read /proc/self/stat");
#else /* Not RS6000 */
-#if defined(USE_MMAP) || defined(USE_MUNMAP)
+#if defined(USE_MMAP) || defined(USE_MUNMAP) || defined(FALLBACK_TO_MMAP)
#ifdef USE_MMAP_FIXED
# define GC_MMAP_FLAGS MAP_FIXED | MAP_PRIVATE
#endif /* defined(USE_MMAP) || defined(USE_MUNMAP) */
-#if defined(USE_MMAP)
+#if defined(USE_MMAP) || defined(FALLBACK_TO_MMAP)
/* Tested only under Linux, IRIX5 and Solaris 2 */
#ifndef HEAP_START
# define HEAP_START 0
#endif
+#ifdef FALLBACK_TO_MMAP
+static ptr_t GC_unix_get_mem_mmap(bytes)
+#else
ptr_t GC_unix_get_mem(bytes)
+#endif
word bytes;
{
void *result;
return((ptr_t)result);
}
-#else /* Not RS6000, not USE_MMAP */
+#endif
+
+#ifndef USE_MMAP
+
ptr_t GC_unix_get_mem(bytes)
word bytes;
{
if((ptr_t)sbrk(GC_page_size - lsbs) == (ptr_t)(-1)) return(0);
}
result = (ptr_t)sbrk((SBRK_ARG_T)bytes);
- if (result == (ptr_t)(-1)) result = 0;
+ if (result == (ptr_t)(-1)) {
+#ifdef FALLBACK_TO_MMAP
+ result = GC_unix_get_mem_mmap (bytes);
+#else
+ result = 0;
+#endif
+ }
}
# ifdef IRIX5
__UNLOCK_MALLOC();
/* Using vm_protect (mach syscall) over mprotect (BSD syscall) seems to
decrease the likelihood of some of the problems described below. */
#include <mach/vm_map.h>
- extern mach_port_t GC_task_self;
+ static mach_port_t GC_task_self;
#define PROTECT(addr,len) \
if(vm_protect(GC_task_self,(vm_address_t)(addr),(vm_size_t)(len), \
FALSE,VM_PROT_READ) != KERN_SUCCESS) { \