Define fun_code_header in C for symmetry with Lisp
[sbcl.git] / src / runtime / bsd-os.h
blob126ab5a77b9f0a5af34e7d9d3b8bf7b149ea605c
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__
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;
35 #if defined(LISP_FEATURE_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. */
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
56 /* Hooking both SIGBUS and SIGSEGV causes troubles on some situation,
57 * so use a variable.
59 extern int sig_memory_fault;
60 #define SIG_MEMORY_FAULT (sig_memory_fault)
62 #define SIG_STOP_FOR_GC (SIGUSR2)
64 #elif defined __DragonFly__
66 #include <sys/ucontext.h>
67 typedef ucontext_t os_context_t;
69 #define SIG_MEMORY_FAULT (SIGSEGV)
70 #define SIG_STOP_FOR_GC (SIGUSR2)
72 #elif defined __OpenBSD__
74 typedef struct sigcontext os_context_t;
75 #define SIG_MEMORY_FAULT SIGSEGV
76 #define SIG_STOP_FOR_GC (SIGUSR2)
77 #if defined(LISP_FEATURE_X86)
78 extern int openbsd_use_fxsave;
79 #endif
81 #elif defined __NetBSD__
83 #include <ucontext.h>
84 typedef ucontext_t os_context_t;
85 #define SIG_MEMORY_FAULT SIGSEGV
87 #define SIG_STOP_FOR_GC (SIGUSR2)
89 #elif defined LISP_FEATURE_DARWIN
90 #include "darwin-os.h"
91 #else
92 #error unsupported BSD variant
93 #endif
95 #include "target-arch-os.h"
96 #include "target-arch.h"
98 #define OS_VM_PROT_READ PROT_READ
99 #define OS_VM_PROT_WRITE PROT_WRITE
100 #define OS_VM_PROT_EXECUTE PROT_EXEC