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.
16 /* FIXME: Aren't symbols with underscore prefixes supposed to be
17 * reserved for system libraries? Perhaps rename stuff like this
18 * to names like INCLUDED_SBCL_RUNTIME_H. */
19 #ifndef _SBCL_RUNTIME_H_
20 #define _SBCL_RUNTIME_H_
22 #define QSHOW 0 /* Enable low-level debugging output? */
24 #define FSHOW(args) fprintf args
25 #define SHOW(string) FSHOW((stderr, "/%s\n", string))
31 /* Enable extra-verbose low-level debugging output for signals? (You
32 * probably don't want this unless you're trying to debug very early
33 * cold boot on a new machine, or one where you've just messed up
36 * Note: It may be that doing this is fundamentally unsound, since it
37 * causes output from signal handlers, the i/o libraries aren't
38 * necessarily reentrant. But it can still be very convenient for
39 * figuring out what's going on when you have a signal handling
41 #define QSHOW_SIGNALS 0
43 /* FIXME: There seems to be no reason that LowtagOf can't be defined
44 * as a (possibly inline) function instead of a macro. It would also
45 * be reasonable to rename the constants in ALL CAPS. */
48 #define lowtag_Mask ((1<<lowtag_Bits)-1)
49 #define LowtagOf(obj) ((obj)&lowtag_Mask)
51 #define type_Mask ((1<<type_Bits)-1)
53 /* FIXME: There seems to be no reason that TypeOf, HeaderValue,
54 * Pointerp, PTR, CONS, SYMBOL, and FDEFN can't be defined
55 * as (possibly inline) functions instead of macros. */
57 #define TypeOf(obj) ((obj)&type_Mask)
58 #define HeaderValue(obj) ((unsigned long) ((obj)>>type_Bits))
60 #define Pointerp(obj) ((obj) & 0x01)
61 #define PTR(obj) ((obj)&~lowtag_Mask)
63 #define CONS(obj) ((struct cons *)((obj)-type_ListPointer))
64 #define SYMBOL(obj) ((struct symbol *)((obj)-type_OtherPointer))
65 #define FDEFN(obj) ((struct fdefn *)((obj)-type_OtherPointer))
67 /* KLUDGE: These are in theory machine-dependent and OS-dependent, but
68 * in practice the "foo int" definitions work for all the machines
69 * that SBCL runs on as of 0.6.7. If we port to the Alpha or some
70 * other non-32-bit machine we'll probably need real machine-dependent
71 * and OS-dependent definitions again. */
73 /* We need definitions of u32 and s32. */
74 #error Alpha code is stale.
76 typedef unsigned int u32;
77 typedef signed int s32;
82 /* FIXME: There seems to be no reason that make_fixnum and fixnum_value
83 * can't be implemented as (possibly inline) functions. */
84 #define make_fixnum(n) ((lispobj)((n)<<2))
85 #define fixnum_value(n) (((long)n)>>2)
87 /* Too bad ANSI C doesn't define "bool" as C++ does.. */
90 /* FIXME: There seems to be no reason that SymbolValue, SetSymbolValue,
91 * and SymbolFunction can't be defined as (possibly inline) functions
92 * instead of macros. */
94 #define SymbolValue(sym) \
95 (((struct symbol *)((sym)-type_OtherPointer))->value)
96 #define SetSymbolValue(sym,val) \
97 (((struct symbol *)((sym)-type_OtherPointer))->value = (val))
99 /* This only works for static symbols. */
100 /* FIXME: should be called StaticSymbolFunction, right? */
101 #define SymbolFunction(sym) \
102 (((struct fdefn *)(SymbolValue(sym)-type_OtherPointer))->function)
104 #endif /* _SBCL_RUNTIME_H_ */