X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fruntime.h;h=91e205c12044340bfe93e4d40cbe3565f8b64888;hb=1b650be8b800cf96e2c268ae317fb26d0bf36827;hp=8315ea164502333de20fa6773777720f78243402;hpb=81cfdf526490d642c73602ebac9bcacb8af644e1;p=sbcl.git diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 8315ea1..91e205c 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -36,43 +36,44 @@ * problem.. */ #define QSHOW_SIGNALS 0 -/* FIXME: There seems to be no reason that LowtagOf can't be defined - * as a (possibly inline) function instead of a macro. It would also - * be reasonable to rename the constants in ALL CAPS. */ +#define N_LOWTAG_BITS 3 +#define LOWTAG_MASK ((1<> N_WIDETAG_BITS)) -#define TypeOf(obj) ((obj)&type_Mask) -#define HeaderValue(obj) ((unsigned long) ((obj)>>type_Bits)) - -#define CONS(obj) ((struct cons *)((obj)-type_ListPointer)) -#define SYMBOL(obj) ((struct symbol *)((obj)-type_OtherPointer)) -#define FDEFN(obj) ((struct fdefn *)((obj)-type_OtherPointer)) +#define CONS(obj) ((struct cons *)((obj)-LIST_POINTER_LOWTAG)) +#define SYMBOL(obj) ((struct symbol *)((obj)-OTHER_POINTER_LOWTAG)) +#define FDEFN(obj) ((struct fdefn *)((obj)-OTHER_POINTER_LOWTAG)) /* KLUDGE: These are in theory machine-dependent and OS-dependent, but * in practice the "foo int" definitions work for all the machines * that SBCL runs on as of 0.6.7. If we port to the Alpha or some * other non-32-bit machine we'll probably need real machine-dependent * and OS-dependent definitions again. */ -#if ((defined alpha) && !(defined __linux__)) -#error No u32,s32 definitions for this platform. Write some. -#else -/* int happens to be 4 bytes on linux/alpha. long is longer. */ +/* even on alpha, int happens to be 4 bytes. long is longer. */ typedef unsigned int u32; typedef signed int s32; #define LOW_WORD(c) ((long)(c) & 0xFFFFFFFFL) -#endif +/* this is an integral type the same length as a machine pointer */ +typedef unsigned long pointer_sized_uint_t ; typedef u32 lispobj; +static inline int +lowtag_of(lispobj obj) { + return obj & LOWTAG_MASK; +} + +static inline int +widetag_of(lispobj obj) { + return obj & WIDETAG_MASK; +} + /* Is the Lisp object obj something with pointer nature (as opposed to * e.g. a fixnum or character or unbound marker)? */ static inline int @@ -83,11 +84,15 @@ is_lisp_pointer(lispobj obj) /* Convert from a lispobj with type bits to a native (ordinary * C/assembly) pointer to the beginning of the object. */ -static inline lispobj +static inline lispobj * native_pointer(lispobj obj) { - return obj & ~lowtag_Mask; + return (lispobj *) ((pointer_sized_uint_t) (obj & ~LOWTAG_MASK)); } +/* inverse operation: create a suitably tagged lispobj from a native + * pointer or integer. Needs to be a macro due to the tedious C type + * system */ +#define make_lispobj(o,low_tag) ((lispobj)(LOW_WORD(o)|low_tag)) /* FIXME: There seems to be no reason that make_fixnum and fixnum_value * can't be implemented as (possibly inline) functions. */ @@ -97,19 +102,15 @@ native_pointer(lispobj obj) /* Too bad ANSI C doesn't define "bool" as C++ does.. */ typedef int boolean; -/* FIXME: There seems to be no reason that SymbolValue, SetSymbolValue, - * and SymbolFunction can't be defined as (possibly inline) functions - * instead of macros. */ - -#define SymbolValue(sym) \ - (((struct symbol *)((sym)-type_OtherPointer))->value) -#define SetSymbolValue(sym,val) \ - (((struct symbol *)((sym)-type_OtherPointer))->value = (val)) +/* FIXME: There seems to be no reason that SymbolFunction can't be + * defined as (possibly inline) functions instead of macros. */ +static inline lispobj SymbolValue(u32 sym, void *thread); +static inline void SetSymbolValue(u32 sym, lispobj val, void *thread); /* This only works for static symbols. */ /* FIXME: should be called StaticSymbolFunction, right? */ #define SymbolFunction(sym) \ - (((struct fdefn *)(SymbolValue(sym)-type_OtherPointer))->function) + (((struct fdefn *)(native_pointer(SymbolValue(sym,0))))->fun) /* KLUDGE: As far as I can tell there's no ANSI C way of saying * "this function never returns". This is the way that you do it