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, and 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 #define N_LOWTAG_BITS 3
40 #define LOWTAG_MASK ((1<<N_LOWTAG_BITS)-1)
41 #define N_WIDETAG_BITS 8
42 #define WIDETAG_MASK ((1<<N_WIDETAG_BITS)-1)
44 /* FIXME: Make HeaderValue, CONS, SYMBOL, and FDEFN into inline
45 * functions instead of macros. */
47 #define HeaderValue(obj) ((unsigned long) ((obj) >> N_WIDETAG_BITS))
49 #define CONS(obj) ((struct cons *)((obj)-LIST_POINTER_LOWTAG))
50 #define SYMBOL(obj) ((struct symbol *)((obj)-OTHER_POINTER_LOWTAG))
51 #define FDEFN(obj) ((struct fdefn *)((obj)-OTHER_POINTER_LOWTAG))
53 /* KLUDGE: These are in theory machine-dependent and OS-dependent, but
54 * in practice the "foo int" definitions work for all the machines
55 * that SBCL runs on as of 0.6.7. If we port to the Alpha or some
56 * other non-32-bit machine we'll probably need real machine-dependent
57 * and OS-dependent definitions again. */
58 /* even on alpha, int happens to be 4 bytes. long is longer. */
59 typedef unsigned int u32;
60 typedef signed int s32;
61 #define LOW_WORD(c) ((long)(c) & 0xFFFFFFFFL)
67 lowtag_of(lispobj obj) {
68 return obj & LOWTAG_MASK;
72 widetag_of(lispobj obj) {
73 return obj & WIDETAG_MASK;
76 /* Is the Lisp object obj something with pointer nature (as opposed to
77 * e.g. a fixnum or character or unbound marker)? */
79 is_lisp_pointer(lispobj obj)
84 /* Convert from a lispobj with type bits to a native (ordinary
85 * C/assembly) pointer to the beginning of the object. */
87 native_pointer(lispobj obj)
89 return obj & ~LOWTAG_MASK;
92 /* FIXME: There seems to be no reason that make_fixnum and fixnum_value
93 * can't be implemented as (possibly inline) functions. */
94 #define make_fixnum(n) ((lispobj)((n)<<2))
95 #define fixnum_value(n) (((long)n)>>2)
97 /* Too bad ANSI C doesn't define "bool" as C++ does.. */
100 /* FIXME: There seems to be no reason that SymbolValue, SetSymbolValue,
101 * and SymbolFunction can't be defined as (possibly inline) functions
102 * instead of macros. */
104 #define SymbolValue(sym) \
105 (((struct symbol *)((sym)-OTHER_POINTER_LOWTAG))->value)
106 #define SetSymbolValue(sym,val) \
107 (((struct symbol *)((sym)-OTHER_POINTER_LOWTAG))->value = (val))
109 /* This only works for static symbols. */
110 /* FIXME: should be called StaticSymbolFunction, right? */
111 #define SymbolFunction(sym) \
112 (((struct fdefn *)(SymbolValue(sym)-OTHER_POINTER_LOWTAG))->fun)
114 /* KLUDGE: As far as I can tell there's no ANSI C way of saying
115 * "this function never returns". This is the way that you do it
116 * in GCC later than version 2.7 or so. If you are using some
117 * compiler that doesn't understand this, you could could just
118 * change it to "typedef void never_returns" and nothing would
119 * break, though you might get a few more bytes of compiled code or
120 * a few more compiler warnings. -- WHN 2000-10-21 */
121 typedef volatile void never_returns;
123 #endif /* _SBCL_RUNTIME_H_ */