aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2012-06-13 19:27:39 -0700
committerPaul Eggert2012-06-13 19:27:39 -0700
commit2b5701247845a07e4a279abc8c3acaf75cbc8a1b (patch)
tree245bcf84a0d69c249810e0f400e5a97949b6721d /src
parent81755f695c081ac5eb4e7250ebfbe39e5ffd6a11 (diff)
downloademacs-2b5701247845a07e4a279abc8c3acaf75cbc8a1b.tar.gz
emacs-2b5701247845a07e4a279abc8c3acaf75cbc8a1b.zip
Simplify lisp.h in minor ways that should not affect code.
* lisp.h (USE_2_TAGS_FOR_INTS): Remove, as it was always defined. (LISP_INT_TAG, case_Lisp_Int, LISP_STRING_TAG, LISP_INT_TAG_P) (LISP_INT1_TAG, enum Lisp_Type, XINT, XUINT, make_number): Simplify under the assumption that USE_2_TAGS_FOR_INTS is defined. (INTTYPEBITS): New macro, for clarity. (INTMASK, MOST_POSITIVE_FIXNUM): Use it. (LISP_INT1_TAG, LISP_STRING_TAG, LISP_INT_TAG_P): Simplify now that USE_LSB_TAG is always defined. (TYPEMASK, XINT) [USE_LSB_TAG]: Remove unnecessary cast. (make_number) [!USE_LSB_TAG]: Use INTMASK; that's simpler.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog14
-rw-r--r--src/lisp.h111
2 files changed, 47 insertions, 78 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 809fd2c22c7..e5e0c199026 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,17 @@
12012-06-14 Paul Eggert <eggert@cs.ucla.edu>
2
3 Simplify lisp.h in minor ways that should not affect code.
4 * lisp.h (USE_2_TAGS_FOR_INTS): Remove, as it was always defined.
5 (LISP_INT_TAG, case_Lisp_Int, LISP_STRING_TAG, LISP_INT_TAG_P)
6 (LISP_INT1_TAG, enum Lisp_Type, XINT, XUINT, make_number):
7 Simplify under the assumption that USE_2_TAGS_FOR_INTS is defined.
8 (INTTYPEBITS): New macro, for clarity.
9 (INTMASK, MOST_POSITIVE_FIXNUM): Use it.
10 (LISP_INT1_TAG, LISP_STRING_TAG, LISP_INT_TAG_P): Simplify
11 now that USE_LSB_TAG is always defined.
12 (TYPEMASK, XINT) [USE_LSB_TAG]: Remove unnecessary cast.
13 (make_number) [!USE_LSB_TAG]: Use INTMASK; that's simpler.
14
12012-06-13 Juanma Barranquero <lekktu@gmail.com> 152012-06-13 Juanma Barranquero <lekktu@gmail.com>
2 16
3 * makefile.w32-in ($(BLD)/data.$(O)): Update dependencies. 17 * makefile.w32-in ($(BLD)/data.$(O)): Update dependencies.
diff --git a/src/lisp.h b/src/lisp.h
index cff5a89e395..8093682f0fb 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -230,31 +230,18 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
230 230
231/* Define the fundamental Lisp data structures. */ 231/* Define the fundamental Lisp data structures. */
232 232
233/* If USE_2_TAGBITS_FOR_INTS is defined, then Lisp integers use
234 2 tags, to give them one extra bit, thus extending their range from
235 e.g -2^28..2^28-1 to -2^29..2^29-1. */
236#define USE_2_TAGS_FOR_INTS
237
238/* This is the set of Lisp data types. */ 233/* This is the set of Lisp data types. */
239 234
240#if !defined USE_2_TAGS_FOR_INTS 235/* Lisp integers use 2 tags, to give them one extra bit, thus
241# define LISP_INT_TAG Lisp_Int 236 extending their range from, e.g., -2^28..2^28-1 to -2^29..2^29-1. */
242# define case_Lisp_Int case Lisp_Int 237#define INTTYPEBITS (GCTYPEBITS - 1)
243# define LISP_STRING_TAG 4 238#define FIXNUM_BITS (VALBITS + 1)
244# define LISP_INT_TAG_P(x) ((x) == Lisp_Int) 239#define INTMASK (EMACS_INT_MAX >> (INTTYPEBITS - 1))
245#else 240#define LISP_INT_TAG Lisp_Int0
246# define LISP_INT_TAG Lisp_Int0 241#define case_Lisp_Int case Lisp_Int0: case Lisp_Int1
247# define case_Lisp_Int case Lisp_Int0: case Lisp_Int1 242#define LISP_INT1_TAG (USE_LSB_TAG ? 1 << INTTYPEBITS : 1)
248# if USE_LSB_TAG 243#define LISP_STRING_TAG (5 - LISP_INT1_TAG)
249# define LISP_INT1_TAG 4 244#define LISP_INT_TAG_P(x) (((x) & ~LISP_INT1_TAG) == 0)
250# define LISP_STRING_TAG 1
251# define LISP_INT_TAG_P(x) (((x) & 3) == 0)
252# else
253# define LISP_INT1_TAG 1
254# define LISP_STRING_TAG 4
255# define LISP_INT_TAG_P(x) (((x) & 6) == 0)
256# endif
257#endif
258 245
259/* Stolen from GDB. The only known compiler that doesn't support 246/* Stolen from GDB. The only known compiler that doesn't support
260 enums in bitfields is MSVC. */ 247 enums in bitfields is MSVC. */
@@ -268,12 +255,8 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
268enum Lisp_Type 255enum Lisp_Type
269 { 256 {
270 /* Integer. XINT (obj) is the integer value. */ 257 /* Integer. XINT (obj) is the integer value. */
271#ifdef USE_2_TAGS_FOR_INTS
272 Lisp_Int0 = 0, 258 Lisp_Int0 = 0,
273 Lisp_Int1 = LISP_INT1_TAG, 259 Lisp_Int1 = LISP_INT1_TAG,
274#else
275 Lisp_Int = 0,
276#endif
277 260
278 /* Symbol. XSYMBOL (object) points to a struct Lisp_Symbol. */ 261 /* Symbol. XSYMBOL (object) points to a struct Lisp_Symbol. */
279 Lisp_Symbol = 2, 262 Lisp_Symbol = 2,
@@ -416,68 +399,50 @@ enum pvec_type
416 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */ 399 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */
417 400
418/* Return a perfect hash of the Lisp_Object representation. */ 401/* Return a perfect hash of the Lisp_Object representation. */
419#define XHASH(a) XLI(a) 402#define XHASH(a) XLI (a)
420 403
421#if USE_LSB_TAG 404#if USE_LSB_TAG
422 405
423#define TYPEMASK ((((EMACS_INT) 1) << GCTYPEBITS) - 1) 406#define TYPEMASK ((1 << GCTYPEBITS) - 1)
424#define XTYPE(a) ((enum Lisp_Type) (XLI(a) & TYPEMASK)) 407#define XTYPE(a) ((enum Lisp_Type) (XLI (a) & TYPEMASK))
425#ifdef USE_2_TAGS_FOR_INTS 408#define XINT(a) (XLI (a) >> INTTYPEBITS)
426# define XINT(a) (((EMACS_INT) XLI(a)) >> (GCTYPEBITS - 1)) 409#define XUINT(a) ((EMACS_UINT) XLI (a) >> INTTYPEBITS)
427# define XUINT(a) (((EMACS_UINT) XLI(a)) >> (GCTYPEBITS - 1)) 410#define make_number(N) XIL ((EMACS_INT) (N) << INTTYPEBITS)
428# define make_number(N) XIL(((EMACS_INT) (N)) << (GCTYPEBITS - 1))
429#else
430# define XINT(a) (((EMACS_INT) XLI(a)) >> GCTYPEBITS)
431# define XUINT(a) (((EMACS_UINT) XLI(a)) >> GCTYPEBITS)
432# define make_number(N) XIL(((EMACS_INT) (N)) << GCTYPEBITS)
433#endif
434#define XSET(var, type, ptr) \ 411#define XSET(var, type, ptr) \
435 (eassert (XTYPE (XIL((intptr_t) (ptr))) == 0), /* Check alignment. */ \ 412 (eassert (XTYPE (XIL ((intptr_t) (ptr))) == 0), /* Check alignment. */ \
436 (var) = XIL((type) | (intptr_t) (ptr))) 413 (var) = XIL ((type) | (intptr_t) (ptr)))
437 414
438#define XPNTR(a) ((intptr_t) (XLI(a) & ~TYPEMASK)) 415#define XPNTR(a) ((intptr_t) (XLI (a) & ~TYPEMASK))
439#define XUNTAG(a, type) ((intptr_t) (XLI(a) - (type))) 416#define XUNTAG(a, type) ((intptr_t) (XLI (a) - (type)))
440 417
441#else /* not USE_LSB_TAG */ 418#else /* not USE_LSB_TAG */
442 419
443#define VALMASK VAL_MAX 420#define VALMASK VAL_MAX
444 421
445/* One need to override this if there must be high bits set in data space 422#define XTYPE(a) ((enum Lisp_Type) ((EMACS_UINT) XLI (a) >> VALBITS))
446 (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work
447 on all machines, but would penalize machines which don't need it)
448 */
449#define XTYPE(a) ((enum Lisp_Type) (((EMACS_UINT) XLI(a)) >> VALBITS))
450 423
451/* For integers known to be positive, XFASTINT provides fast retrieval 424/* For integers known to be positive, XFASTINT provides fast retrieval
452 and XSETFASTINT provides fast storage. This takes advantage of the 425 and XSETFASTINT provides fast storage. This takes advantage of the
453 fact that Lisp_Int is 0. */ 426 fact that Lisp integers have zero-bits in their tags. */
454#define XFASTINT(a) (XLI(a) + 0) 427#define XFASTINT(a) (XLI (a) + 0)
455#define XSETFASTINT(a, b) ((a) = XIL(b)) 428#define XSETFASTINT(a, b) ((a) = XIL (b))
456 429
457/* Extract the value of a Lisp_Object as a (un)signed integer. */ 430/* Extract the value of a Lisp_Object as a (un)signed integer. */
458 431
459#ifdef USE_2_TAGS_FOR_INTS 432#define XINT(a) (XLI (a) << INTTYPEBITS >> INTTYPEBITS)
460# define XINT(a) ((((EMACS_INT) XLI(a)) << (GCTYPEBITS - 1)) >> (GCTYPEBITS - 1)) 433#define XUINT(a) ((EMACS_UINT) (XLI (a) & INTMASK))
461# define XUINT(a) ((EMACS_UINT) (XLI(a) & (1 + (VALMASK << 1)))) 434#define make_number(N) XIL ((EMACS_INT) (N) & INTMASK)
462# define make_number(N) XIL((((EMACS_INT) (N)) & (1 + (VALMASK << 1))))
463#else
464# define XINT(a) ((((EMACS_INT) XLI(a)) << (BITS_PER_EMACS_INT - VALBITS)) \
465 >> (BITS_PER_EMACS_INT - VALBITS))
466# define XUINT(a) ((EMACS_UINT) (XLI(a) & VALMASK))
467# define make_number(N) \
468 XIL((((EMACS_INT) (N)) & VALMASK) | ((EMACS_INT) Lisp_Int) << VALBITS)
469#endif
470 435
471#define XSET(var, type, ptr) \ 436#define XSET(var, type, ptr) \
472 ((var) = XIL((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \ 437 ((var) = XIL ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \
473 + ((intptr_t) (ptr) & VALMASK))) 438 + ((intptr_t) (ptr) & VALMASK)))
474 439
475#ifdef DATA_SEG_BITS 440#ifdef DATA_SEG_BITS
476/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers 441/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers
477 which were stored in a Lisp_Object */ 442 which were stored in a Lisp_Object */
478#define XPNTR(a) ((uintptr_t) ((XLI(a) & VALMASK)) | DATA_SEG_BITS)) 443#define XPNTR(a) ((uintptr_t) ((XLI (a) & VALMASK)) | DATA_SEG_BITS))
479#else 444#else
480#define XPNTR(a) ((uintptr_t) (XLI(a) & VALMASK)) 445#define XPNTR(a) ((uintptr_t) (XLI (a) & VALMASK))
481#endif 446#endif
482 447
483#endif /* not USE_LSB_TAG */ 448#endif /* not USE_LSB_TAG */
@@ -499,19 +464,9 @@ enum pvec_type
499 464
500#define EQ(x, y) (XHASH (x) == XHASH (y)) 465#define EQ(x, y) (XHASH (x) == XHASH (y))
501 466
502/* Number of bits in a fixnum, including the sign bit. */
503#ifdef USE_2_TAGS_FOR_INTS
504# define FIXNUM_BITS (VALBITS + 1)
505#else
506# define FIXNUM_BITS VALBITS
507#endif
508
509/* Mask indicating the significant bits of a fixnum. */
510#define INTMASK (((EMACS_INT) 1 << FIXNUM_BITS) - 1)
511
512/* Largest and smallest representable fixnum values. These are the C 467/* Largest and smallest representable fixnum values. These are the C
513 values. */ 468 values. */
514#define MOST_POSITIVE_FIXNUM (INTMASK / 2) 469#define MOST_POSITIVE_FIXNUM (EMACS_INT_MAX >> INTTYPEBITS)
515#define MOST_NEGATIVE_FIXNUM (-1 - MOST_POSITIVE_FIXNUM) 470#define MOST_NEGATIVE_FIXNUM (-1 - MOST_POSITIVE_FIXNUM)
516 471
517/* Value is non-zero if I doesn't fit into a Lisp fixnum. It is 472/* Value is non-zero if I doesn't fit into a Lisp fixnum. It is
@@ -817,7 +772,7 @@ struct vectorlike_header
817 /* When the vector is allocated from a vector block, NBYTES is used 772 /* When the vector is allocated from a vector block, NBYTES is used
818 if the vector is not on a free list, and VECTOR is used otherwise. 773 if the vector is not on a free list, and VECTOR is used otherwise.
819 For large vector-like objects, BUFFER or VECTOR is used as a pointer 774 For large vector-like objects, BUFFER or VECTOR is used as a pointer
820 to the next vector-like object. It is generally a buffer or a 775 to the next vector-like object. It is generally a buffer or a
821 Lisp_Vector alias, so for convenience it is a union instead of a 776 Lisp_Vector alias, so for convenience it is a union instead of a
822 pointer: this way, one can write P->next.vector instead of ((struct 777 pointer: this way, one can write P->next.vector instead of ((struct
823 Lisp_Vector *) P->next). */ 778 Lisp_Vector *) P->next). */