# HG changeset patch # User Stefan Monnier # Date 1191358669 0 # Node ID 3a31b2cfe77f9d68ebf272e75f2fde29b665134a # Parent 1d35aa87550835ca6cc06f85d1a7ae79240752cd (ARRAY_MARK_FLAG, PSEUDOVECTOR_FLAG): Don't allow definition in m/*.h files. (XCHAR_TABLE, XBOOL_VECTOR): Add assertion checking. (XSETPVECTYPE): New macro. (XSETPSEUDOVECTOR): Use it. diff -r 1d35aa875508 -r 3a31b2cfe77f src/lisp.h --- a/src/lisp.h Tue Oct 02 20:51:02 2007 +0000 +++ b/src/lisp.h Tue Oct 02 20:57:49 2007 +0000 @@ -306,25 +306,21 @@ #define LISP_MAKE_RVALUE(o) (0+(o)) #endif /* NO_UNION_TYPE */ -/* Two flags that are set during GC. On some machines, these flags - are defined differently by the m- file. */ - /* In the size word of a vector, this bit means the vector has been marked. */ -#ifndef ARRAY_MARK_FLAG #define ARRAY_MARK_FLAG ((EMACS_INT) ((EMACS_UINT) 1 << (VALBITS + GCTYPEBITS - 1))) -#endif /* no ARRAY_MARK_FLAG */ /* In the size word of a struct Lisp_Vector, this bit means it's really some other vector-like object. */ -#ifndef PSEUDOVECTOR_FLAG #define PSEUDOVECTOR_FLAG ((ARRAY_MARK_FLAG >> 1) & ~ARRAY_MARK_FLAG) -#endif /* In a pseudovector, the size field actually contains a word with one PSEUDOVECTOR_FLAG bit set, and exactly one of the following bits to indicate the actual type. - FIXME: Why a bitset if only one of the bits can ever be set at a time? */ + We use a bitset, even tho only one of the bits can be set at any + particular time just so as to be able to use micro-optimizations such as + testing membership of a particular subset of pseudovectors in Fequal. + It is not crucial, but there are plenty of bits here, so why not do it? */ enum pvec_type { PVEC_NORMAL_VECTOR = 0, @@ -544,8 +540,8 @@ #define XTERMINAL(a) (eassert (GC_TERMINALP(a)),(struct terminal *) XPNTR(a)) #define XSUBR(a) (eassert (GC_SUBRP(a)),(struct Lisp_Subr *) XPNTR(a)) #define XBUFFER(a) (eassert (GC_BUFFERP(a)),(struct buffer *) XPNTR(a)) -#define XCHAR_TABLE(a) ((struct Lisp_Char_Table *) XPNTR(a)) -#define XBOOL_VECTOR(a) ((struct Lisp_Bool_Vector *) XPNTR(a)) +#define XCHAR_TABLE(a) (eassert (GC_CHAR_TABLE_P (a)), (struct Lisp_Char_Table *) XPNTR(a)) +#define XBOOL_VECTOR(a) (eassert (GC_BOOL_VECTOR_P (a)), (struct Lisp_Bool_Vector *) XPNTR(a)) /* Construct a Lisp_Object from a value or address. */ @@ -563,8 +559,9 @@ /* Pseudovector types. */ +#define XSETPVECTYPE(v,code) ((v)->size |= PSEUDOVECTOR_FLAG | (code)) #define XSETPSEUDOVECTOR(a, b, code) \ - (XSETVECTOR (a, b), XVECTOR (a)->size |= PSEUDOVECTOR_FLAG | (code)) + (XSETVECTOR (a, b), XSETPVECTYPE (XVECTOR (a), code)) #define XSETWINDOW_CONFIGURATION(a, b) \ (XSETPSEUDOVECTOR (a, b, PVEC_WINDOW_CONFIGURATION)) #define XSETPROCESS(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_PROCESS))