Use os_allocate(), not os_validate(), for "anywhere" allocation
[sbcl.git] / src / runtime / bsd-os.h
blob9ffda9509ce887075d0df0e4a9f6b6edb4dd1f2f
1 /*
2 * This software is part of the SBCL system. See the README file for
3 * more information.
5 * This software is derived from the CMU CL system, which was
6 * written at Carnegie Mellon University and released into the
7 * public domain. The software is in the public domain and is
8 * provided with absolutely no warranty. See the COPYING and CREDITS
9 * files for more information.
12 #if defined(LISP_FEATURE_FREEBSD)
13 #include <osreldate.h>
14 #endif
16 #include <sys/types.h>
17 #include <sys/mman.h>
18 #include <sys/signal.h>
20 #ifdef LISP_FEATURE_DARWIN
21 #include <mach/mach_types.h>
22 #endif
24 typedef caddr_t os_vm_address_t;
25 #if defined __NetBSD__ || defined __OpenBSD__
26 typedef size_t os_vm_size_t;
27 #else
28 typedef vm_size_t os_vm_size_t;
29 #endif
30 typedef off_t os_vm_offset_t;
31 typedef int os_vm_prot_t;
33 #if defined(LISP_FEATURE_FREEBSD)
34 /* Note: The man page for sigaction(2) in FreeBSD 4.0 says that this
35 * is an mcontext_t, but according to comments by Raymond Wiker in the
36 * original FreeBSD port of SBCL, that's wrong, it's actually a
37 * ucontext_t. */
39 #include <sys/ucontext.h>
40 typedef ucontext_t os_context_t;
41 /* As the sbcl-devel message from Raymond Wiker 2000-12-01, FreeBSD
42 * (unlike Linux and OpenBSD) doesn't let us tweak the CPU's single
43 * step flag bit by messing with the flags stored in a signal context,
44 * so we need to implement single stepping in a more roundabout way. */
45 #define CANNOT_GET_TO_SINGLE_STEP_FLAG
46 /* Sometime in late 2005 FreeBSD was changed to signal SIGSEGV instead
47 * of SIGBUS for memory faults, as required by POSIX. In order to
48 * support both new and old FreeBSD at the same time, both signals are
49 * hooked to the GC write barrier machinery. If you're reading this
50 * message in the far future where FreeBSD 6 and earlier are just
51 * quaint memories, feel free to delete this hack (and any code that's
52 * #ifdef SIG_MEMORY_FAULT2'ed). -- JES, 2005-12-30
54 /* Hooking both SIGBUS and SIGSEGV causes troubles on some situation,
55 * so use a variable.
57 extern int sig_memory_fault;
58 #define SIG_MEMORY_FAULT (sig_memory_fault)
60 #define SIG_STOP_FOR_GC (SIGUSR2)
62 #elif defined __DragonFly__
64 #include <sys/ucontext.h>
65 typedef ucontext_t os_context_t;
67 #define SIG_MEMORY_FAULT (SIGSEGV)
68 #define SIG_STOP_FOR_GC (SIGUSR2)
70 #elif defined __OpenBSD__
72 typedef struct sigcontext os_context_t;
73 #define SIG_MEMORY_FAULT SIGSEGV
74 #define SIG_STOP_FOR_GC (SIGUSR2)
75 #if defined(LISP_FEATURE_X86)
76 extern int openbsd_use_fxsave;
77 #endif
79 #elif defined __NetBSD__
81 #include <ucontext.h>
82 typedef ucontext_t os_context_t;
83 #define SIG_MEMORY_FAULT SIGSEGV
85 #define SIG_STOP_FOR_GC (SIGUSR2)
87 #elif defined LISP_FEATURE_DARWIN
88 #include "darwin-os.h"
89 #else
90 #error unsupported BSD variant
91 #endif
93 #include "target-arch-os.h"
94 #include "target-arch.h"
96 #define OS_VM_PROT_READ PROT_READ
97 #define OS_VM_PROT_WRITE PROT_WRITE
98 #define OS_VM_PROT_EXECUTE PROT_EXEC