0.9.1.59:
[sbcl/eslaughter.git] / src / runtime / bsd-os.h
blob5dfff24d536e243c4b3349e60d24b226399c0aa0
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 #ifdef __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__
26 typedef vsize_t os_vm_size_t;
27 #elif defined __OpenBSD__
28 typedef size_t os_vm_size_t;
29 #else
30 typedef vm_size_t os_vm_size_t;
31 #endif
32 typedef off_t os_vm_offset_t;
33 typedef int os_vm_prot_t;
34 typedef int os_context_register_t;
36 #if defined __OpenBSD__
37 /* name defined for compatibility between OpenBSD 3.1 sigaltstack(2) and
38 * Linux sigaltstack(2) */
39 typedef struct sigaltstack stack_t;
40 #elif defined __FreeBSD__
41 /* FreeBSD 4.6 and NetBSD 1.6 already have stack_t defined. */
42 #endif
44 #if defined __FreeBSD__
45 /* Note: The man page for sigaction(2) in FreeBSD 4.0 says that this
46 * is an mcontext_t, but according to comments by Raymond Wiker in the
47 * original FreeBSD port of SBCL, that's wrong, it's actually a
48 * ucontext_t. */
50 #include <sys/ucontext.h>
51 typedef ucontext_t os_context_t;
52 /* As the sbcl-devel message from Raymond Wiker 2000-12-01, FreeBSD
53 * (unlike Linux and OpenBSD) doesn't let us tweak the CPU's single
54 * step flag bit by messing with the flags stored in a signal context,
55 * so we need to implement single stepping in a more roundabout way. */
56 #define CANNOT_GET_TO_SINGLE_STEP_FLAG
57 #define SIG_MEMORY_FAULT SIGBUS
59 #elif defined __OpenBSD__
61 typedef struct sigcontext os_context_t;
62 #define SIG_MEMORY_FAULT SIGSEGV
64 #elif defined __NetBSD__
66 #include <ucontext.h>
67 typedef ucontext_t os_context_t;
68 #define SIG_MEMORY_FAULT SIGSEGV
70 #elif defined LISP_FEATURE_DARWIN
71 /* man pages claim that the third argument is a sigcontext struct,
72 but ucontext_t is defined, matches sigcontext where sensible,
73 offers better access to mcontext, and is of course the SUSv2-
74 mandated type of the third argument, so we use that instead.
75 If Apple is going to break ucontext_t out of spite, I'm going
76 to be cross with them ;) -- PRM */
78 #include <ucontext.h>
79 typedef ucontext_t os_context_t;
80 #define SIG_MEMORY_FAULT SIGBUS
82 #else
83 #error unsupported BSD variant
84 #endif
86 #include "target-arch-os.h"
87 #include "target-arch.h"
89 #define OS_VM_PROT_READ PROT_READ
90 #define OS_VM_PROT_WRITE PROT_WRITE
91 #define OS_VM_PROT_EXECUTE PROT_EXEC