aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2015-01-10 13:35:33 -0800
committerPaul Eggert2015-01-10 13:42:34 -0800
commit29eaf3c8a8c7b22e34a6183fec5343d82762f590 (patch)
treeed0dd4ae6a7089049129376ae8a7234b810156ab /src
parentec7605b4b13776c1079a25891b82b2401a584632 (diff)
downloademacs-29eaf3c8a8c7b22e34a6183fec5343d82762f590.tar.gz
emacs-29eaf3c8a8c7b22e34a6183fec5343d82762f590.zip
Port Qnil==0 changes to 32-bit --with-wide-int
* lisp.h (lisp_h_XSYMBOL, XSYMBOL): Assume USE_LSB_TAG in the macro-implemented version. For the non-USE_LSB_TAG case, supply a new inline function that is the inverse of the new TAG_SYMPTR. (lisp_h_XUNTAGBASE, XUNTAGBASE): Remove. All uses removed. (TAG_SYMPTR) [!USE_LSB_TAG]: If the pointer subtraction yields a negative number, don't allow sign bits to bleed into the encoded value. Shift in zero bits instead.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/lisp.h50
2 files changed, 32 insertions, 27 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b6358d0e66d..c05083590af 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -21,6 +21,15 @@
21 21
222015-01-09 Paul Eggert <eggert@cs.ucla.edu> 222015-01-09 Paul Eggert <eggert@cs.ucla.edu>
23 23
24 Port Qnil==0 changes to 32-bit --with-wide-int
25 * lisp.h (lisp_h_XSYMBOL, XSYMBOL): Assume USE_LSB_TAG in the
26 macro-implemented version. For the non-USE_LSB_TAG case, supply
27 a new inline function that is the inverse of the new TAG_SYMPTR.
28 (lisp_h_XUNTAGBASE, XUNTAGBASE): Remove. All uses removed.
29 (TAG_SYMPTR) [!USE_LSB_TAG]: If the pointer subtraction yields a
30 negative number, don't allow sign bits to bleed into the encoded
31 value. Shift in zero bits instead.
32
24 Refactor pointer-to-integer conversion 33 Refactor pointer-to-integer conversion
25 * gfilenotify.c (monitor_to_lisp, lisp_to_monitor): 34 * gfilenotify.c (monitor_to_lisp, lisp_to_monitor):
26 Rename and move to lisp.h. All uses changed. 35 Rename and move to lisp.h. All uses changed.
diff --git a/src/lisp.h b/src/lisp.h
index 4571c455a7b..9819e0746d5 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -356,9 +356,6 @@ error !;
356#define lisp_h_XHASH(a) XUINT (a) 356#define lisp_h_XHASH(a) XUINT (a)
357#define lisp_h_XPNTR(a) \ 357#define lisp_h_XPNTR(a) \
358 (SYMBOLP (a) ? XSYMBOL (a) : (void *) ((intptr_t) (XLI (a) & VALMASK))) 358 (SYMBOLP (a) ? XSYMBOL (a) : (void *) ((intptr_t) (XLI (a) & VALMASK)))
359#define lisp_h_XSYMBOL(a) \
360 (eassert (SYMBOLP (a)), \
361 (struct Lisp_Symbol *) XUNTAGBASE (a, Lisp_Symbol, lispsym))
362#ifndef GC_CHECK_CONS_LIST 359#ifndef GC_CHECK_CONS_LIST
363# define lisp_h_check_cons_list() ((void) 0) 360# define lisp_h_check_cons_list() ((void) 0)
364#endif 361#endif
@@ -367,10 +364,12 @@ error !;
367 XIL ((EMACS_INT) (((EMACS_UINT) (n) << INTTYPEBITS) + Lisp_Int0)) 364 XIL ((EMACS_INT) (((EMACS_UINT) (n) << INTTYPEBITS) + Lisp_Int0))
368# define lisp_h_XFASTINT(a) XINT (a) 365# define lisp_h_XFASTINT(a) XINT (a)
369# define lisp_h_XINT(a) (XLI (a) >> INTTYPEBITS) 366# define lisp_h_XINT(a) (XLI (a) >> INTTYPEBITS)
367# define lisp_h_XSYMBOL(a) \
368 (eassert (SYMBOLP (a)), \
369 (struct Lisp_Symbol *) ((uintptr_t) XLI (a) - Lisp_Symbol \
370 + (char *) lispsym))
370# define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK)) 371# define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK))
371# define lisp_h_XUNTAG(a, type) ((void *) (intptr_t) (XLI (a) - (type))) 372# define lisp_h_XUNTAG(a, type) ((void *) (intptr_t) (XLI (a) - (type)))
372# define lisp_h_XUNTAGBASE(a, type, base) \
373 ((void *) ((char *) (base) - (type) + (intptr_t) XLI (a)))
374#endif 373#endif
375 374
376/* When compiling via gcc -O0, define the key operations as macros, as 375/* When compiling via gcc -O0, define the key operations as macros, as
@@ -402,7 +401,6 @@ error !;
402# define XCONS(a) lisp_h_XCONS (a) 401# define XCONS(a) lisp_h_XCONS (a)
403# define XHASH(a) lisp_h_XHASH (a) 402# define XHASH(a) lisp_h_XHASH (a)
404# define XPNTR(a) lisp_h_XPNTR (a) 403# define XPNTR(a) lisp_h_XPNTR (a)
405# define XSYMBOL(a) lisp_h_XSYMBOL (a)
406# ifndef GC_CHECK_CONS_LIST 404# ifndef GC_CHECK_CONS_LIST
407# define check_cons_list() lisp_h_check_cons_list () 405# define check_cons_list() lisp_h_check_cons_list ()
408# endif 406# endif
@@ -410,9 +408,9 @@ error !;
410# define make_number(n) lisp_h_make_number (n) 408# define make_number(n) lisp_h_make_number (n)
411# define XFASTINT(a) lisp_h_XFASTINT (a) 409# define XFASTINT(a) lisp_h_XFASTINT (a)
412# define XINT(a) lisp_h_XINT (a) 410# define XINT(a) lisp_h_XINT (a)
411# define XSYMBOL(a) lisp_h_XSYMBOL (a)
413# define XTYPE(a) lisp_h_XTYPE (a) 412# define XTYPE(a) lisp_h_XTYPE (a)
414# define XUNTAG(a, type) lisp_h_XUNTAG (a, type) 413# define XUNTAG(a, type) lisp_h_XUNTAG (a, type)
415# define XUNTAGBASE(a, type, base) lisp_h_XUNTAGBASE (a, type, base)
416# endif 414# endif
417#endif 415#endif
418 416
@@ -612,7 +610,7 @@ INLINE bool (VECTORLIKEP) (Lisp_Object);
612INLINE bool WINDOWP (Lisp_Object); 610INLINE bool WINDOWP (Lisp_Object);
613INLINE struct Lisp_Save_Value *XSAVE_VALUE (Lisp_Object); 611INLINE struct Lisp_Save_Value *XSAVE_VALUE (Lisp_Object);
614INLINE struct Lisp_Symbol *(XSYMBOL) (Lisp_Object); 612INLINE struct Lisp_Symbol *(XSYMBOL) (Lisp_Object);
615INLINE void *(XUNTAGBASE) (Lisp_Object, int, void *); 613INLINE void *(XUNTAG) (Lisp_Object, int);
616 614
617/* Defined in chartab.c. */ 615/* Defined in chartab.c. */
618extern Lisp_Object char_table_ref (Lisp_Object, int); 616extern Lisp_Object char_table_ref (Lisp_Object, int);
@@ -728,9 +726,10 @@ struct Lisp_Symbol
728 ((USE_LSB_TAG ? (tag) : (EMACS_UINT) (tag) << VALBITS) + (uintptr_t) (ptr)) 726 ((USE_LSB_TAG ? (tag) : (EMACS_UINT) (tag) << VALBITS) + (uintptr_t) (ptr))
729 727
730/* Yield an integer that tags PTR as a symbol. */ 728/* Yield an integer that tags PTR as a symbol. */
731#define TAG_SYMPTR(ptr) \ 729#define TAG_SYMPTR(ptr) \
732 TAG_PTR (Lisp_Symbol, \ 730 TAG_PTR (Lisp_Symbol, \
733 USE_LSB_TAG ? (char *) (ptr) - (char *) lispsym : (intptr_t) (ptr)) 731 ((uintptr_t) ((char *) (ptr) - (char *) lispsym) \
732 >> (USE_LSB_TAG ? 0 : GCTYPEBITS)))
734 733
735/* Declare extern constants for Lisp symbols. These can be helpful 734/* Declare extern constants for Lisp symbols. These can be helpful
736 when using a debugger like GDB, on older platforms where the debug 735 when using a debugger like GDB, on older platforms where the debug
@@ -833,10 +832,9 @@ LISP_MACRO_DEFUN (XPNTR, void *, (Lisp_Object a), (a))
833LISP_MACRO_DEFUN (make_number, Lisp_Object, (EMACS_INT n), (n)) 832LISP_MACRO_DEFUN (make_number, Lisp_Object, (EMACS_INT n), (n))
834LISP_MACRO_DEFUN (XINT, EMACS_INT, (Lisp_Object a), (a)) 833LISP_MACRO_DEFUN (XINT, EMACS_INT, (Lisp_Object a), (a))
835LISP_MACRO_DEFUN (XFASTINT, EMACS_INT, (Lisp_Object a), (a)) 834LISP_MACRO_DEFUN (XFASTINT, EMACS_INT, (Lisp_Object a), (a))
835LISP_MACRO_DEFUN (XSYMBOL, struct Lisp_Symbol *, (Lisp_Object a), (a))
836LISP_MACRO_DEFUN (XTYPE, enum Lisp_Type, (Lisp_Object a), (a)) 836LISP_MACRO_DEFUN (XTYPE, enum Lisp_Type, (Lisp_Object a), (a))
837LISP_MACRO_DEFUN (XUNTAG, void *, (Lisp_Object a, int type), (a, type)) 837LISP_MACRO_DEFUN (XUNTAG, void *, (Lisp_Object a, int type), (a, type))
838LISP_MACRO_DEFUN (XUNTAGBASE, void *, (Lisp_Object a, int type, void *base),
839 (a, type, base))
840 838
841#else /* ! USE_LSB_TAG */ 839#else /* ! USE_LSB_TAG */
842 840
@@ -889,6 +887,17 @@ XFASTINT (Lisp_Object a)
889 return n; 887 return n;
890} 888}
891 889
890/* Extract A's value as a symbol. */
891INLINE struct Lisp_Symbol *
892XSYMBOL (Lisp_Object a)
893{
894 uintptr_t i = (uintptr_t) XUNTAG (a, Lisp_Symbol);
895 if (! USE_LSB_TAG)
896 i <<= GCTYPEBITS;
897 void *p = (char *) lispsym + i;
898 return p;
899}
900
892/* Extract A's type. */ 901/* Extract A's type. */
893INLINE enum Lisp_Type 902INLINE enum Lisp_Type
894XTYPE (Lisp_Object a) 903XTYPE (Lisp_Object a)
@@ -897,16 +906,6 @@ XTYPE (Lisp_Object a)
897 return USE_LSB_TAG ? i & ~VALMASK : i >> VALBITS; 906 return USE_LSB_TAG ? i & ~VALMASK : i >> VALBITS;
898} 907}
899 908
900/* Extract A's pointer value, assuming A's type is TYPE.
901 If USE_LSB_TAG, add BASE to A's pointer value while extracting. */
902INLINE void *
903XUNTAGBASE (Lisp_Object a, int type, void *base)
904{
905 char *b = USE_LSB_TAG ? base : 0;
906 intptr_t i = USE_LSB_TAG ? XLI (a) - type : XLI (a) & VALMASK;
907 return b + i;
908}
909
910/* Extract A's pointer value, assuming A's type is TYPE. */ 909/* Extract A's pointer value, assuming A's type is TYPE. */
911INLINE void * 910INLINE void *
912XUNTAG (Lisp_Object a, int type) 911XUNTAG (Lisp_Object a, int type)
@@ -974,8 +973,6 @@ XSTRING (Lisp_Object a)
974 return XUNTAG (a, Lisp_String); 973 return XUNTAG (a, Lisp_String);
975} 974}
976 975
977LISP_MACRO_DEFUN (XSYMBOL, struct Lisp_Symbol *, (Lisp_Object a), (a))
978
979/* XSYMBOL_INIT (Qfoo) is like XSYMBOL (Qfoo), except it is valid in 976/* XSYMBOL_INIT (Qfoo) is like XSYMBOL (Qfoo), except it is valid in
980 static initializers, and SYM must be a C-defined symbol. */ 977 static initializers, and SYM must be a C-defined symbol. */
981#define XSYMBOL_INIT(sym) a##sym 978#define XSYMBOL_INIT(sym) a##sym
@@ -1058,8 +1055,7 @@ INLINE Lisp_Object
1058make_lisp_symbol (struct Lisp_Symbol *sym) 1055make_lisp_symbol (struct Lisp_Symbol *sym)
1059{ 1056{
1060 Lisp_Object a = XIL (TAG_SYMPTR (sym)); 1057 Lisp_Object a = XIL (TAG_SYMPTR (sym));
1061 eassert (XTYPE (a) == Lisp_Symbol 1058 eassert (XSYMBOL (a) == sym);
1062 && XUNTAGBASE (a, Lisp_Symbol, lispsym) == sym);
1063 return a; 1059 return a;
1064} 1060}
1065 1061