Fix make-array transforms.
[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 #ifdef LISP_FEATURE_DARWIN
21 #include <mach/mach_types.h>
22 #endif
23
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
35 #if defined __FreeBSD__
36 /* Note: The man page for sigaction(2) in FreeBSD 4.0 says that this
37  * is an mcontext_t, but according to comments by Raymond Wiker in the
38  * original FreeBSD port of SBCL, that's wrong, it's actually a
39  * ucontext_t. */
40
41 #include <sys/ucontext.h>
42 typedef ucontext_t os_context_t;
43 /* As the sbcl-devel message from Raymond Wiker 2000-12-01, FreeBSD
44  * (unlike Linux and OpenBSD) doesn't let us tweak the CPU's single
45  * step flag bit by messing with the flags stored in a signal context,
46  * so we need to implement single stepping in a more roundabout way. */
47 #define CANNOT_GET_TO_SINGLE_STEP_FLAG
48 /* Sometime in late 2005 FreeBSD was changed to signal SIGSEGV instead
49  * of SIGBUS for memory faults, as required by POSIX. In order to
50  * support both new and old FreeBSD at the same time, both signals are
51  * hooked to the GC write barrier machinery. If you're reading this
52  * message in the far future where FreeBSD 6 and earlier are just
53  * quaint memories, feel free to delete this hack (and any code that's
54  * #ifdef SIG_MEMORY_FAULT2'ed). -- JES, 2005-12-30
55  */
56 /* Hooking both SIGBUS and SIGSEGV causes troubles on some situation,
57  * so use a variable.
58  */
59 extern int sig_memory_fault;
60 #define SIG_MEMORY_FAULT (sig_memory_fault)
61
62 #define SIG_STOP_FOR_GC (SIGUSR2)
63
64 #elif defined __OpenBSD__
65
66 typedef struct sigcontext os_context_t;
67 #define SIG_MEMORY_FAULT SIGSEGV
68 #if defined(LISP_FEATURE_X86)
69 extern int openbsd_use_fxsave;
70 #endif
71
72 #elif defined __NetBSD__
73
74 #include <ucontext.h>
75 typedef ucontext_t os_context_t;
76 #define SIG_MEMORY_FAULT SIGSEGV
77
78 #elif defined LISP_FEATURE_DARWIN
79 #include "darwin-os.h"
80 #else
81 #error unsupported BSD variant
82 #endif
83
84 #include "target-arch-os.h"
85 #include "target-arch.h"
86
87 #define OS_VM_PROT_READ PROT_READ
88 #define OS_VM_PROT_WRITE PROT_WRITE
89 #define OS_VM_PROT_EXECUTE PROT_EXEC