aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
authorPaul Eggert2015-01-10 13:33:38 -0800
committerPaul Eggert2015-01-10 13:42:35 -0800
commit6a37ecee0884ff30ac7666e6502e2a9d2608f291 (patch)
tree875bd8310981ff850911f04da4c3c3b95f34537b /src/lisp.h
parent649937920b5023be5c0685d1537f5ea2bfb9899a (diff)
downloademacs-6a37ecee0884ff30ac7666e6502e2a9d2608f291.tar.gz
emacs-6a37ecee0884ff30ac7666e6502e2a9d2608f291.zip
Port to 32-bit --with-wide-int
Prefer symbol indexes to struct Lisp_Symbol * casted and then widened, as the latter had trouble with GCC on Fedora 21 when configured --with-wide-int and when used in static initializers. * lib-src/make-docfile.c (write_globals): Define and use symbols like iQnil (a small integer, like 0) rather than aQnil (an address constant). * src/alloc.c (garbage_collect_1, which_symbols): * src/lread.c (init_obarray): Prefer builtin_lisp_symbol when it can be used. * src/dispextern.h (struct image_type.type): * src/font.c (font_property_table.key): * src/frame.c (struct frame_parm_table.sym): * src/keyboard.c (scroll_bar_parts, struct event_head): * src/xdisp.c (struct props.name): Use the index of a builtin symbol rather than its address. All uses changed. * src/lisp.h (TAG_SYMPTR, XSYMBOL_INIT): Remove, replacing with ... (TAG_SYMOFFSET, SYMBOL_INDEX): ... new macros that deal with symbol indexes rather than pointers, and which work better on MSB hosts because they shift right before tagging. All uses changed. (DEFINE_LISP_SYMBOL_BEGIN, DEFINE_LISP_SYMBOL_END): No longer noops on wide-int hosts, since they work now. (builtin_lisp_symbol): New function.
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/lisp.h b/src/lisp.h
index ab72bf158a4..1fa1deb82a4 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -725,25 +725,20 @@ struct Lisp_Symbol
725#define TAG_PTR(tag, ptr) \ 725#define TAG_PTR(tag, ptr) \
726 ((USE_LSB_TAG ? (tag) : (EMACS_UINT) (tag) << VALBITS) + (uintptr_t) (ptr)) 726 ((USE_LSB_TAG ? (tag) : (EMACS_UINT) (tag) << VALBITS) + (uintptr_t) (ptr))
727 727
728/* Yield an integer that tags PTR as a symbol. */ 728/* Yield an integer that contains a symbol tag along with OFFSET.
729#define TAG_SYMPTR(ptr) \ 729 OFFSET should be the offset in bytes from 'lispsym' to the symbol. */
730#define TAG_SYMOFFSET(offset) \
730 TAG_PTR (Lisp_Symbol, \ 731 TAG_PTR (Lisp_Symbol, \
731 ((uintptr_t) ((char *) (ptr) - (char *) lispsym) \ 732 ((uintptr_t) (offset) >> (USE_LSB_TAG ? 0 : GCTYPEBITS)))
732 >> (USE_LSB_TAG ? 0 : GCTYPEBITS)))
733 733
734/* Declare extern constants for Lisp symbols. These can be helpful 734/* Declare extern constants for Lisp symbols. These can be helpful
735 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
736 format does not represent C macros. However, they don't work with 736 format does not represent C macros. */
737 GCC if INTPTR_MAX != EMACS_INT_MAX. */ 737#define DEFINE_LISP_SYMBOL_BEGIN(name) \
738#if EMACS_INT_MAX == INTPTR_MAX 738 DEFINE_GDB_SYMBOL_BEGIN (Lisp_Object, name)
739# define DEFINE_LISP_SYMBOL_BEGIN(name) \ 739#define DEFINE_LISP_SYMBOL_END(name) \
740 DEFINE_GDB_SYMBOL_BEGIN (Lisp_Object, name) 740 DEFINE_GDB_SYMBOL_END (LISP_INITIALLY (TAG_SYMOFFSET (i##name \
741# define DEFINE_LISP_SYMBOL_END(name) \ 741 * sizeof *lispsym)))
742 DEFINE_GDB_SYMBOL_END (LISP_INITIALLY (TAG_SYMPTR (name)))
743#else
744# define DEFINE_LISP_SYMBOL_BEGIN(name) /* empty */
745# define DEFINE_LISP_SYMBOL_END(name) /* empty */
746#endif
747 742
748#include "globals.h" 743#include "globals.h"
749 744
@@ -973,9 +968,9 @@ XSTRING (Lisp_Object a)
973 return XUNTAG (a, Lisp_String); 968 return XUNTAG (a, Lisp_String);
974} 969}
975 970
976/* XSYMBOL_INIT (Qfoo) is like XSYMBOL (Qfoo), except it is valid in 971/* The index of the C-defined Lisp symbol SYM.
977 static initializers, and SYM must be a C-defined symbol. */ 972 This can be used in a static initializer. */
978#define XSYMBOL_INIT(sym) a##sym 973#define SYMBOL_INDEX(sym) i##sym
979 974
980INLINE struct Lisp_Float * 975INLINE struct Lisp_Float *
981XFLOAT (Lisp_Object a) 976XFLOAT (Lisp_Object a)
@@ -1054,12 +1049,18 @@ make_lisp_ptr (void *ptr, enum Lisp_Type type)
1054INLINE Lisp_Object 1049INLINE Lisp_Object
1055make_lisp_symbol (struct Lisp_Symbol *sym) 1050make_lisp_symbol (struct Lisp_Symbol *sym)
1056{ 1051{
1057 Lisp_Object a = XIL (TAG_SYMPTR (sym)); 1052 Lisp_Object a = XIL (TAG_SYMOFFSET ((char *) sym - (char *) lispsym));
1058 eassert (XSYMBOL (a) == sym); 1053 eassert (XSYMBOL (a) == sym);
1059 return a; 1054 return a;
1060} 1055}
1061 1056
1062INLINE Lisp_Object 1057INLINE Lisp_Object
1058builtin_lisp_symbol (int index)
1059{
1060 return make_lisp_symbol (lispsym + index);
1061}
1062
1063INLINE Lisp_Object
1063make_lisp_proc (struct Lisp_Process *p) 1064make_lisp_proc (struct Lisp_Process *p)
1064{ 1065{
1065 return make_lisp_ptr (p, Lisp_Vectorlike); 1066 return make_lisp_ptr (p, Lisp_Vectorlike);