aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2004-01-21 04:31:21 +0000
committerStefan Monnier2004-01-21 04:31:21 +0000
commit9aa0928de798d02fb15ce3158d9625c86db2d137 (patch)
tree16a01b8e3d9e44e4aaf97f73967faf518990a81d /src
parent39eec98ffd24bae4eac6caf062d51a8bbccf02db (diff)
downloademacs-9aa0928de798d02fb15ce3158d9625c86db2d137.tar.gz
emacs-9aa0928de798d02fb15ce3158d9625c86db2d137.zip
[USE_LSB_TAG]: Add definitions for Lisp_Object value
manipulation macros for when tags are in the lower bits. (struct Lisp_Free) [USE_LSB_TAG]: Add padding. (DECL_ALIGN): New macro. (DEFUN): Use it.
Diffstat (limited to 'src')
-rw-r--r--src/lisp.h59
1 files changed, 57 insertions, 2 deletions
diff --git a/src/lisp.h b/src/lisp.h
index cf9f9395262..72d24d79f05 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -289,12 +289,58 @@ enum pvec_type
289/* For convenience, we also store the number of elements in these bits. */ 289/* For convenience, we also store the number of elements in these bits. */
290#define PSEUDOVECTOR_SIZE_MASK 0x1ff 290#define PSEUDOVECTOR_SIZE_MASK 0x1ff
291 291
292/***** Select the tagging scheme. *****/
293
294/* First, try and define DECL_ALIGN(type,var) which declares a static
295 variable VAR of type TYPE with the added requirement that it be
296 TYPEBITS-aligned. */
297#ifndef DECL_ALIGN
298/* What compiler directive should we use for non-gcc compilers? -stef */
299#if defined (__GNUC__)
300#define DECL_ALIGN(type, var) \
301 type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var
302#endif
303#endif
304
305#ifndef DECL_ALIGN
306/* Can't USE_LSB_TAG if we can't enforce alignment of statically allocated
307 objects like lisp_subr and the special buffers in buffer.c. */
308#undef USE_LSB_TAG
309#endif
310
311#ifndef USE_LSB_TAG
312/* Just remove the alignment annotation if we don't use it. */
313#define DECL_ALIGN(type, var) type var
314#endif
315
316
292/* These macros extract various sorts of values from a Lisp_Object. 317/* These macros extract various sorts of values from a Lisp_Object.
293 For example, if tem is a Lisp_Object whose type is Lisp_Cons, 318 For example, if tem is a Lisp_Object whose type is Lisp_Cons,
294 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */ 319 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */
295 320
296#ifdef NO_UNION_TYPE 321#ifdef NO_UNION_TYPE
297 322
323#ifdef USE_LSB_TAG
324
325#define TYPEMASK ((((EMACS_INT) 1) << GCTYPEBITS) - 1)
326#define XTYPE(a) ((enum Lisp_Type) (((EMACS_UINT) (a)) & TYPEMASK))
327#define XINT(a) (((EMACS_INT) (a)) >> GCTYPEBITS)
328#define XUINT(a) (((EMACS_UINT) (a)) >> GCTYPEBITS)
329#define XSET(var, type, ptr) \
330 (eassert (XTYPE (ptr) == 0), /* Check alignment. */ \
331 (var) = ((EMACS_INT) (type)) | ((EMACS_INT) (ptr)))
332#define make_number(N) (((EMACS_INT) (N)) << GCTYPEBITS)
333
334/* XFASTINT and XSETFASTINT are for use when the integer is known to be
335 positive, in which case the implementation can sometimes be faster
336 depending on the tagging scheme. With USE_LSB_TAG, there's no benefit. */
337#define XFASTINT(a) XINT (a)
338#define XSETFASTINT(a, b) ((a) = make_number (b))
339
340#define XPNTR(a) ((EMACS_INT) ((a) & ~TYPEMASK))
341
342#else /* not USE_LSB_TAG */
343
298#define VALMASK ((((EMACS_INT) 1) << VALBITS) - 1) 344#define VALMASK ((((EMACS_INT) 1) << VALBITS) - 1)
299 345
300/* One need to override this if there must be high bits set in data space 346/* One need to override this if there must be high bits set in data space
@@ -333,6 +379,8 @@ enum pvec_type
333#define make_number(N) \ 379#define make_number(N) \
334 ((((EMACS_INT) (N)) & VALMASK) | ((EMACS_INT) Lisp_Int) << VALBITS) 380 ((((EMACS_INT) (N)) & VALMASK) | ((EMACS_INT) Lisp_Int) << VALBITS)
335 381
382#endif /* not USE_LSB_TAG */
383
336#define EQ(x, y) ((x) == (y)) 384#define EQ(x, y) ((x) == (y))
337 385
338#else /* not NO_UNION_TYPE */ 386#else /* not NO_UNION_TYPE */
@@ -1146,6 +1194,13 @@ struct Lisp_Free
1146 unsigned gcmarkbit : 1; 1194 unsigned gcmarkbit : 1;
1147 int spacer : 15; 1195 int spacer : 15;
1148 union Lisp_Misc *chain; 1196 union Lisp_Misc *chain;
1197#ifdef USE_LSB_TAG
1198 /* Try to make sure that sizeof(Lisp_Misc) preserves TYPEBITS-alignment.
1199 This assumes that Lisp_Marker is the largest of the alternatives and
1200 that Lisp_Intfwd has the same size as "Lisp_Free w/o padding". */
1201 char padding[((((sizeof (struct Lisp_Marker) - 1) >> GCTYPEBITS) + 1)
1202 << GCTYPEBITS) - sizeof (struct Lisp_Intfwd)];
1203#endif
1149 }; 1204 };
1150 1205
1151/* To get the type field of a union Lisp_Misc, use XMISCTYPE. 1206/* To get the type field of a union Lisp_Misc, use XMISCTYPE.
@@ -1513,7 +1568,7 @@ typedef unsigned char UCHAR;
1513 1568
1514#define DEFUN(lname, fnname, sname, minargs, maxargs, prompt, doc) \ 1569#define DEFUN(lname, fnname, sname, minargs, maxargs, prompt, doc) \
1515 Lisp_Object fnname (); \ 1570 Lisp_Object fnname (); \
1516 struct Lisp_Subr sname = \ 1571 DECL_ALIGN (struct Lisp_Subr, sname) = \
1517 { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \ 1572 { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \
1518 fnname, minargs, maxargs, lname, prompt, 0}; \ 1573 fnname, minargs, maxargs, lname, prompt, 0}; \
1519 Lisp_Object fnname 1574 Lisp_Object fnname
@@ -1524,7 +1579,7 @@ typedef unsigned char UCHAR;
1524 arguments, so we can catch errors with maxargs at compile-time. */ 1579 arguments, so we can catch errors with maxargs at compile-time. */
1525#define DEFUN(lname, fnname, sname, minargs, maxargs, prompt, doc) \ 1580#define DEFUN(lname, fnname, sname, minargs, maxargs, prompt, doc) \
1526 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ 1581 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
1527 struct Lisp_Subr sname = \ 1582 DECL_ALIGN (struct Lisp_Subr, sname) = \
1528 { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \ 1583 { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \
1529 fnname, minargs, maxargs, lname, prompt, 0}; \ 1584 fnname, minargs, maxargs, lname, prompt, 0}; \
1530 Lisp_Object fnname 1585 Lisp_Object fnname