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