2 * This software is part of the SBCL system. See the README file for
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 /* FIXME: Aren't symbols with underscore prefixes supposed to be
13 * reserved for system libraries? Perhaps rename stuff like this
14 * to names like INCLUDED_SBCL_RUNTIME_H. */
15 #ifndef _SBCL_RUNTIME_H_
16 #define _SBCL_RUNTIME_H_
18 #define QSHOW 0 /* Enable low-level debugging output? */
20 #define FSHOW(args) fprintf args
21 #define SHOW(string) FSHOW((stderr, "/%s\n", string))
27 /* Enable extra-verbose low-level debugging output for signals? (You
28 * probably don't want this unless you're trying to debug very early
29 * cold boot on a new machine, or one where you've just messed up
32 * Note: It may be that doing this is fundamentally unsound, since it
33 * causes output from signal handlers, the i/o libraries aren't
34 * necessarily reentrant. But it can still be very convenient for
35 * figuring out what's going on when you have a signal handling
37 #define QSHOW_SIGNALS 0
39 /* FIXME: There seems to be no reason that LowtagOf can't be defined
40 * as a (possibly inline) function instead of a macro. It would also
41 * be reasonable to rename the constants in ALL CAPS. */
44 #define lowtag_Mask ((1<<lowtag_Bits)-1)
45 #define LowtagOf(obj) ((obj)&lowtag_Mask)
47 #define type_Mask ((1<<type_Bits)-1)
49 /* FIXME: There seems to be no reason that TypeOf, HeaderValue,
50 * Pointerp, PTR, CONS, SYMBOL, and FDEFN can't be defined
51 * as (possibly inline) functions instead of macros. */
53 #define TypeOf(obj) ((obj)&type_Mask)
54 #define HeaderValue(obj) ((unsigned long) ((obj)>>type_Bits))
56 #define Pointerp(obj) ((obj) & 0x01)
57 #define PTR(obj) ((obj)&~lowtag_Mask)
59 #define CONS(obj) ((struct cons *)((obj)-type_ListPointer))
60 #define SYMBOL(obj) ((struct symbol *)((obj)-type_OtherPointer))
61 #define FDEFN(obj) ((struct fdefn *)((obj)-type_OtherPointer))
63 /* KLUDGE: These are in theory machine-dependent and OS-dependent, but
64 * in practice the "foo int" definitions work for all the machines
65 * that SBCL runs on as of 0.6.7. If we port to the Alpha or some
66 * other non-32-bit machine we'll probably need real machine-dependent
67 * and OS-dependent definitions again. */
69 /* We need definitions of u32 and s32. */
70 #error Alpha code is stale.
72 typedef unsigned int u32;
73 typedef signed int s32;
78 /* FIXME: There seems to be no reason that make_fixnum and fixnum_value
79 * can't be implemented as (possibly inline) functions. */
80 #define make_fixnum(n) ((lispobj)((n)<<2))
81 #define fixnum_value(n) (((long)n)>>2)
83 /* Too bad ANSI C doesn't define "bool" as C++ does.. */
86 /* FIXME: There seems to be no reason that SymbolValue, SetSymbolValue,
87 * and SymbolFunction can't be defined as (possibly inline) functions
88 * instead of macros. */
90 #define SymbolValue(sym) \
91 (((struct symbol *)((sym)-type_OtherPointer))->value)
92 #define SetSymbolValue(sym,val) \
93 (((struct symbol *)((sym)-type_OtherPointer))->value = (val))
95 /* This only works for static symbols. */
96 /* FIXME: should be called StaticSymbolFunction, right? */
97 #define SymbolFunction(sym) \
98 (((struct fdefn *)(SymbolValue(sym)-type_OtherPointer))->function)
100 /* KLUDGE: As far as I can tell there's no ANSI C way of saying
101 * "this function never returns". This is the way that you do it
102 * in GCC later than version 2.7 or so. If you are using some
103 * compiler that doesn't understand this, you could could just
104 * change it to "typedef void never_returns" and nothing would
105 * break, you might just get a few more bytes of compiled code or
106 * a few more compiler warnings. -- WHN 2000-10-21 */
107 typedef volatile void never_returns;
109 #endif /* _SBCL_RUNTIME_H_ */