aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schwab2012-06-13 15:40:48 +0200
committerAndreas Schwab2012-06-13 15:40:48 +0200
commit646b5f55dfc28ea37a6605b060f67017cdb1aea8 (patch)
tree877cf977e28772931f3d9f3c6cdd05501efeb7c7
parentef62b23df5a7007c3d8c74dbca87ba83e9da682e (diff)
downloademacs-646b5f55dfc28ea37a6605b060f67017cdb1aea8.tar.gz
emacs-646b5f55dfc28ea37a6605b060f67017cdb1aea8.zip
Use a simple struct to implement compile time checks for the Lisp_Object type
* configure.in: Rename --enable-use-lisp-union-type to --enable-check-lisp-object-type and define CHECK_LISP_OBJECT_TYPE instead of USE_LISP_UNION_TYPE. * admin/make-emacs: Rename --union-type to --check-lisp-type. Define CHECK_LISP_OBJECT_TYPE insted of USE_LISP_UNION_TYPE. * admin/CPP-DEFINES (DEBUG_LISP_OBJECT_TYPE): Renamed from USE_LISP_UNION_TYPE. * src/lisp.h (Lisp_Object) [CHECK_LISP_OBJECT_TYPE]: Define as struct instead of union. (XLI, XIL): Define. (XHASH, XTYPE, XINT, XUINT, make_number, XSET, XPNTR, XUNTAG): Use them. * src/emacs.c (gdb_use_struct): Renamed from gdb_use_union. * src/.gdbinit: Check gdb_use_struct instead of gdb_use_union. * src/alloc.c (widen_to_Lisp_Object): Removed. (mark_memory): Use XIL instead of widen_to_Lisp_Object. * src/frame.c (delete_frame): Remove outdated comment. * src/w32fns.c (Fw32_register_hot_key): Use XLI instead of checking USE_LISP_UNION_TYPE. (Fw32_unregister_hot_key): Likewise. (Fw32_toggle_lock_key): Likewise. * src/w32menu.c (add_menu_item): Likewise. (w32_menu_display_help): Use XIL instead of checking USE_LISP_UNION_TYPE. * src/w32heap.c (allocate_heap): Don't check USE_LISP_UNION_TYPE. (init_heap): Likewise. * src/w32term.c (w32_read_socket): Update comment.
-rw-r--r--ChangeLog6
-rw-r--r--admin/CPP-DEFINES2
-rw-r--r--admin/ChangeLog7
-rwxr-xr-xadmin/make-emacs6
-rw-r--r--configure.in12
-rw-r--r--etc/NEWS5
-rw-r--r--src/.gdbinit26
-rw-r--r--src/ChangeLog23
-rw-r--r--src/alloc.c17
-rw-r--r--src/emacs.c6
-rw-r--r--src/frame.c4
-rw-r--r--src/lisp.h160
-rw-r--r--src/w32fns.c21
-rw-r--r--src/w32heap.c8
-rw-r--r--src/w32menu.c13
-rw-r--r--src/w32term.c2
16 files changed, 125 insertions, 193 deletions
diff --git a/ChangeLog b/ChangeLog
index 9a66d00c9e6..f089df625a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
12012-06-13 Andreas Schwab <schwab@linux-m68k.org>
2
3 * configure.in: Rename --enable-use-lisp-union-type to
4 --enable-check-lisp-object-type and define CHECK_LISP_OBJECT_TYPE
5 instead of USE_LISP_UNION_TYPE.
6
12012-06-12 Glenn Morris <rgm@gnu.org> 72012-06-12 Glenn Morris <rgm@gnu.org>
2 8
3 * configure.in (HAVE_PROCFS, _STRUCTURED_PROC): New AC_DEFINEs. 9 * configure.in (HAVE_PROCFS, _STRUCTURED_PROC): New AC_DEFINEs.
diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES
index 738ec0a91a0..35de784f852 100644
--- a/admin/CPP-DEFINES
+++ b/admin/CPP-DEFINES
@@ -46,7 +46,7 @@ HAVE_PROCFS The /proc filesystem is supported.
46REL_ALLOC Compile in the relocatable memory allocator ralloc.c. 46REL_ALLOC Compile in the relocatable memory allocator ralloc.c.
47SYSTEM_MALLOC Use the system library's malloc. 47SYSTEM_MALLOC Use the system library's malloc.
48subprocesses System can use subprocesses (for M-x shell for example). Defined by default, only MSDOS undefines it. 48subprocesses System can use subprocesses (for M-x shell for example). Defined by default, only MSDOS undefines it.
49USE_LISP_UNION_TYPE Define it in lisp.h to make Lisp_Object be a union type instead of the default int. 49DEBUG_LISP_OBJECT_TYPE Define it in lisp.h enable compile time checks on Lisp_Object use.
50 50
51** System specific macros, described in detail in src/s/template.h 51** System specific macros, described in detail in src/s/template.h
52CLASH_DETECTION 52CLASH_DETECTION
diff --git a/admin/ChangeLog b/admin/ChangeLog
index e425c99b8d0..e3b35906ace 100644
--- a/admin/ChangeLog
+++ b/admin/ChangeLog
@@ -1,3 +1,10 @@
12012-06-13 Andreas Schwab <schwab@linux-m68k.org>
2
3 * make-emacs: Rename --union-type to --check-lisp-type. Define
4 CHECK_LISP_OBJECT_TYPE insted of USE_LISP_UNION_TYPE.
5 * CPP-DEFINES (DEBUG_LISP_OBJECT_TYPE): Renamed from
6 USE_LISP_UNION_TYPE.
7
12012-06-03 Glenn Morris <rgm@gnu.org> 82012-06-03 Glenn Morris <rgm@gnu.org>
2 9
3 * quick-install-emacs (PUBLIC_LIBSRC_SCRIPTS): Remove rcs-checkin. 10 * quick-install-emacs (PUBLIC_LIBSRC_SCRIPTS): Remove rcs-checkin.
diff --git a/admin/make-emacs b/admin/make-emacs
index f64d51b0c41..688f5c196bf 100755
--- a/admin/make-emacs
+++ b/admin/make-emacs
@@ -42,7 +42,7 @@ $rc = GetOptions ("help" => \$help,
42 "check-marked" => \$check_marked, 42 "check-marked" => \$check_marked,
43 "all" => \$all, 43 "all" => \$all,
44 "no-optim" => \$no_optim, 44 "no-optim" => \$no_optim,
45 "union-type" => \$union_type, 45 "check-lisp-type" => \$check_lisp_type,
46 "gprof" => \$profile, 46 "gprof" => \$profile,
47 "malloc-check" => \$malloc_check, 47 "malloc-check" => \$malloc_check,
48 "no-mcheck" => \$no_mcheck, 48 "no-mcheck" => \$no_mcheck,
@@ -70,7 +70,7 @@ Build Emacs.
70 --check-marked GC_CHECK_MARKED_OBJECTS=1 70 --check-marked GC_CHECK_MARKED_OBJECTS=1
71 --optim no debug defines 71 --optim no debug defines
72 --gprof make Emacs for profiling 72 --gprof make Emacs for profiling
73 --union-type define USE_LISP_UNION_TYPE (bad for GDB) 73 --check-lisp-type define CHECK_LISP_OBJECT_TYPE
74 --malloc-check define GC_MALLOC_CHECK 74 --malloc-check define GC_MALLOC_CHECK
75 --no-mcheck don't define GC_MCHECK 75 --no-mcheck don't define GC_MCHECK
76 --wall compile with -Wall 76 --wall compile with -Wall
@@ -140,7 +140,7 @@ else
140 } 140 }
141 } 141 }
142 142
143$defs = "$defs -DUSE_LISP_UNION_TYPE" if $union_type; 143$defs = "$defs -DCHECK_LISP_OBJECT_TYPE" if $check_lisp_type;
144$defs = "$defs -DGC_MALLOC_CHECK=1 -DGC_PROTECT_MALLOC_STATE=1" if $malloc_check; 144$defs = "$defs -DGC_MALLOC_CHECK=1 -DGC_PROTECT_MALLOC_STATE=1" if $malloc_check;
145$defs = "$defs -DGC_MCHECK=1" unless $no_mcheck; 145$defs = "$defs -DGC_MCHECK=1" unless $no_mcheck;
146 146
diff --git a/configure.in b/configure.in
index 6c5ba7a06b9..bc78cd47141 100644
--- a/configure.in
+++ b/configure.in
@@ -309,13 +309,13 @@ if test x$ac_gc_check_cons_list != x ; then
309[Define this to check for errors in cons list.]) 309[Define this to check for errors in cons list.])
310fi 310fi
311 311
312AC_ARG_ENABLE(use-lisp-union-type, 312AC_ARG_ENABLE(check-lisp-object-type,
313[AS_HELP_STRING([--enable-use-lisp-union-type], 313[AS_HELP_STRING([--enable-check-lisp-object-type],
314 [use a union for the Lisp_Object data type. 314 [enable compile time checks for the Lisp_Object data type.
315 This is only useful for development for catching certain types of bugs.])], 315 This is useful for development for catching certain types of bugs.])],
316if test "${enableval}" != "no"; then 316if test "${enableval}" != "no"; then
317 AC_DEFINE(USE_LISP_UNION_TYPE, 1, 317 AC_DEFINE(CHECK_LISP_OBJECT_TYPE, 1,
318 [Define this to use a lisp union for the Lisp_Object data type.]) 318 [Define this to enable compile time checks for the Lisp_Object data type.])
319fi) 319fi)
320 320
321 321
diff --git a/etc/NEWS b/etc/NEWS
index 86c8b695e24..e7b977c2dfa 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -49,6 +49,11 @@ directories to the search path. You must add them yourself if you want them.
49(from the bin and libexec directories, respectively). The former is 49(from the bin and libexec directories, respectively). The former is
50no longer relevant, the latter is replaced by lisp (in vc-sccs.el). 50no longer relevant, the latter is replaced by lisp (in vc-sccs.el).
51 51
52** The configuration option '--enable-use-lisp-union-type' has been
53renamed to '--enable-check-lisp-object-type', as the resulting
54Lisp_Object type no longer uses a union to implement the compile time
55check that this option enables.
56
52 57
53* Startup Changes in Emacs 24.2 58* Startup Changes in Emacs 24.2
54 59
diff --git a/src/.gdbinit b/src/.gdbinit
index 8f8508f291f..df3a9cd7124 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -49,17 +49,26 @@ handle SIGALRM ignore
49# Using a constant runs into GDB bugs sometimes. 49# Using a constant runs into GDB bugs sometimes.
50define xgetptr 50define xgetptr
51 set $bugfix = $arg0 51 set $bugfix = $arg0
52 set $ptr = (gdb_use_union ? (gdb_use_lsb ? $bugfix.u.val << gdb_gctypebits : $bugfix.u.val) : $bugfix & $valmask) | gdb_data_seg_bits 52 if gdb_use_struct
53 set $bugfix = $bugfix.i
54 end
55 set $ptr = $bugfix & $valmask | gdb_data_seg_bits
53end 56end
54 57
55define xgetint 58define xgetint
56 set $bugfix = $arg0 59 set $bugfix = $arg0
57 set $int = gdb_use_union ? $bugfix.s.val : (gdb_use_lsb ? $bugfix >> (gdb_gctypebits - 1) : $bugfix << gdb_gctypebits) >> gdb_gctypebits 60 if gdb_use_struct
61 set $bugfix = $bugfix.i
62 end
63 set $int = gdb_use_lsb ? $bugfix >> (gdb_gctypebits - 1) : $bugfix << gdb_gctypebits) >> gdb_gctypebits
58end 64end
59 65
60define xgettype 66define xgettype
61 set $bugfix = $arg0 67 set $bugfix = $arg0
62 set $type = gdb_use_union ? $bugfix.s.type : (enum Lisp_Type) (gdb_use_lsb ? $bugfix & $tagmask : $bugfix >> gdb_valbits) 68 if gdb_use_struct
69 set $bugfix = $bugfix.i
70 end
71 set $type = (enum Lisp_Type) (gdb_use_lsb ? $bugfix & $tagmask : $bugfix >> gdb_valbits)
63end 72end
64 73
65# Set up something to print out s-expressions. 74# Set up something to print out s-expressions.
@@ -949,15 +958,8 @@ end
949 958
950define xpr 959define xpr
951 xtype 960 xtype
952 if gdb_use_union 961 if $type == Lisp_Int0 || $type == Lisp_Int1
953 if $type == Lisp_Int 962 xint
954 xint
955 end
956 end
957 if !gdb_use_union
958 if $type == Lisp_Int0 || $type == Lisp_Int1
959 xint
960 end
961 end 963 end
962 if $type == Lisp_Symbol 964 if $type == Lisp_Symbol
963 xsymbol 965 xsymbol
diff --git a/src/ChangeLog b/src/ChangeLog
index 32d0017d7ef..19a9ace0728 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,26 @@
12012-06-13 Andreas Schwab <schwab@linux-m68k.org>
2
3 * lisp.h (Lisp_Object) [CHECK_LISP_OBJECT_TYPE]: Define as struct
4 instead of union.
5 (XLI, XIL): Define.
6 (XHASH, XTYPE, XINT, XUINT, make_number, XSET, XPNTR, XUNTAG): Use
7 them.
8 * emacs.c (gdb_use_struct): Renamed from gdb_use_union.
9 * .gdbinit: Check gdb_use_struct instead of gdb_use_union.
10 * alloc.c (widen_to_Lisp_Object): Removed.
11 (mark_memory): Use XIL instead of widen_to_Lisp_Object.
12 * frame.c (delete_frame): Remove outdated comment.
13 * w32fns.c (Fw32_register_hot_key): Use XLI instead of checking
14 USE_LISP_UNION_TYPE.
15 (Fw32_unregister_hot_key): Likewise.
16 (Fw32_toggle_lock_key): Likewise.
17 * w32menu.c (add_menu_item): Likewise.
18 (w32_menu_display_help): Use XIL instead of checking
19 USE_LISP_UNION_TYPE.
20 * w32heap.c (allocate_heap): Don't check USE_LISP_UNION_TYPE.
21 (init_heap): Likewise.
22 * w32term.c (w32_read_socket): Update comment.
23
12012-06-13 Glenn Morris <rgm@gnu.org> 242012-06-13 Glenn Morris <rgm@gnu.org>
2 25
3 * s/usg5-4-common.h, src/s/unixware.h: 26 * s/usg5-4-common.h, src/s/unixware.h:
diff --git a/src/alloc.c b/src/alloc.c
index 1223f0bc13d..1478ce9ae4e 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1585,21 +1585,6 @@ mark_interval_tree (register INTERVAL tree)
1585 (i) = balance_intervals (i); \ 1585 (i) = balance_intervals (i); \
1586 } while (0) 1586 } while (0)
1587 1587
1588/* Convert the pointer-sized word P to EMACS_INT while preserving its
1589 type and ptr fields. */
1590static Lisp_Object
1591widen_to_Lisp_Object (void *p)
1592{
1593 intptr_t i = (intptr_t) p;
1594#ifdef USE_LISP_UNION_TYPE
1595 Lisp_Object obj;
1596 obj.i = i;
1597 return obj;
1598#else
1599 return i;
1600#endif
1601}
1602
1603/*********************************************************************** 1588/***********************************************************************
1604 String Allocation 1589 String Allocation
1605 ***********************************************************************/ 1590 ***********************************************************************/
@@ -4678,7 +4663,7 @@ mark_memory (void *start, void *end)
4678 void *p = *(void **) ((char *) pp + i); 4663 void *p = *(void **) ((char *) pp + i);
4679 mark_maybe_pointer (p); 4664 mark_maybe_pointer (p);
4680 if (POINTERS_MIGHT_HIDE_IN_OBJECTS) 4665 if (POINTERS_MIGHT_HIDE_IN_OBJECTS)
4681 mark_maybe_object (widen_to_Lisp_Object (p)); 4666 mark_maybe_object (XIL ((intptr_t) p));
4682 } 4667 }
4683} 4668}
4684 4669
diff --git a/src/emacs.c b/src/emacs.c
index bc3f918e2af..1d58d25ebfa 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -109,10 +109,10 @@ int gdb_use_lsb EXTERNALLY_VISIBLE = 1;
109#else 109#else
110int gdb_use_lsb EXTERNALLY_VISIBLE = 0; 110int gdb_use_lsb EXTERNALLY_VISIBLE = 0;
111#endif 111#endif
112#ifndef USE_LISP_UNION_TYPE 112#ifndef CHECK_LISP_OBJECT_TYPE
113int gdb_use_union EXTERNALLY_VISIBLE = 0; 113int gdb_use_struct EXTERNALLY_VISIBLE = 0;
114#else 114#else
115int gdb_use_union EXTERNALLY_VISIBLE = 1; 115int gdb_use_struct EXTERNALLY_VISIBLE = 1;
116#endif 116#endif
117int gdb_valbits EXTERNALLY_VISIBLE = VALBITS; 117int gdb_valbits EXTERNALLY_VISIBLE = VALBITS;
118int gdb_gctypebits EXTERNALLY_VISIBLE = GCTYPEBITS; 118int gdb_gctypebits EXTERNALLY_VISIBLE = GCTYPEBITS;
diff --git a/src/frame.c b/src/frame.c
index 744485d4615..39d26ded5a6 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1152,10 +1152,6 @@ other_visible_frames (FRAME_PTR f)
1152 described for Fdelete_frame. */ 1152 described for Fdelete_frame. */
1153Lisp_Object 1153Lisp_Object
1154delete_frame (Lisp_Object frame, Lisp_Object force) 1154delete_frame (Lisp_Object frame, Lisp_Object force)
1155 /* If we use `register' here, gcc-4.0.2 on amd64 using
1156 -DUSE_LISP_UNION_TYPE complains further down that we're getting the
1157 address of `force'. Go figure. */
1158
1159{ 1155{
1160 struct frame *f; 1156 struct frame *f;
1161 struct frame *sf = SELECTED_FRAME (); 1157 struct frame *sf = SELECTED_FRAME ();
diff --git a/src/lisp.h b/src/lisp.h
index 0e9b0c63c7f..cff5a89e395 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -149,14 +149,12 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
149#endif 149#endif
150#endif /* ENABLE_CHECKING */ 150#endif /* ENABLE_CHECKING */
151 151
152/* Use the configure flag --enable-use-lisp-union-type to make 152/* Use the configure flag --enable-check-lisp-object-type to make
153 Lisp_Object use a union type instead of the default int. The flag 153 Lisp_Object use a struct type instead of the default int. The flag
154 causes USE_LISP_UNION_TYPE to be defined. */ 154 causes CHECK_LISP_OBJECT_TYPE to be defined. */
155 155
156/***** Select the tagging scheme. *****/ 156/***** Select the tagging scheme. *****/
157/* There are basically two options that control the tagging scheme: 157/* The following option controls the tagging scheme:
158 - USE_LISP_UNION_TYPE says that Lisp_Object should be a union instead
159 of an integer.
160 - USE_LSB_TAG means that we can assume the least 3 bits of pointers are 158 - USE_LSB_TAG means that we can assume the least 3 bits of pointers are
161 always 0, and we can thus use them to hold tag bits, without 159 always 0, and we can thus use them to hold tag bits, without
162 restricting our addressing space. 160 restricting our addressing space.
@@ -237,11 +235,6 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
237 e.g -2^28..2^28-1 to -2^29..2^29-1. */ 235 e.g -2^28..2^28-1 to -2^29..2^29-1. */
238#define USE_2_TAGS_FOR_INTS 236#define USE_2_TAGS_FOR_INTS
239 237
240/* Making it work for the union case is too much trouble. */
241#ifdef USE_LISP_UNION_TYPE
242# undef USE_2_TAGS_FOR_INTS
243#endif
244
245/* This is the set of Lisp data types. */ 238/* This is the set of Lisp data types. */
246 239
247#if !defined USE_2_TAGS_FOR_INTS 240#if !defined USE_2_TAGS_FOR_INTS
@@ -335,29 +328,17 @@ enum Lisp_Fwd_Type
335 Lisp_Fwd_Kboard_Obj, /* Fwd to a Lisp_Object field of kboards. */ 328 Lisp_Fwd_Kboard_Obj, /* Fwd to a Lisp_Object field of kboards. */
336 }; 329 };
337 330
338#ifdef USE_LISP_UNION_TYPE 331#ifdef CHECK_LISP_OBJECT_TYPE
339 332
340typedef 333typedef struct { EMACS_INT i; } Lisp_Object;
341union Lisp_Object 334
342 { 335#define XLI(o) (o).i
343 /* Used for comparing two Lisp_Objects; 336static inline Lisp_Object
344 also, positive integers can be accessed fast this way. */ 337XIL (EMACS_INT i)
345 EMACS_INT i; 338{
346 339 Lisp_Object o = { i };
347 struct 340 return o;
348 { 341}
349 /* Use explicit signed, the signedness of a bit-field of type
350 int is implementation defined. */
351 signed EMACS_INT val : VALBITS;
352 ENUM_BF (Lisp_Type) type : GCTYPEBITS;
353 } s;
354 struct
355 {
356 EMACS_UINT val : VALBITS;
357 ENUM_BF (Lisp_Type) type : GCTYPEBITS;
358 } u;
359 }
360Lisp_Object;
361 342
362static inline Lisp_Object 343static inline Lisp_Object
363LISP_MAKE_RVALUE (Lisp_Object o) 344LISP_MAKE_RVALUE (Lisp_Object o)
@@ -367,14 +348,16 @@ LISP_MAKE_RVALUE (Lisp_Object o)
367 348
368#define LISP_INITIALLY_ZERO {0} 349#define LISP_INITIALLY_ZERO {0}
369 350
370#else /* USE_LISP_UNION_TYPE */ 351#else /* CHECK_LISP_OBJECT_TYPE */
371 352
372/* If union type is not wanted, define Lisp_Object as just a number. */ 353/* If a struct type is not wanted, define Lisp_Object as just a number. */
373 354
374typedef EMACS_INT Lisp_Object; 355typedef EMACS_INT Lisp_Object;
356#define XLI(o) (o)
357#define XIL(i) (i)
375#define LISP_MAKE_RVALUE(o) (0+(o)) 358#define LISP_MAKE_RVALUE(o) (0+(o))
376#define LISP_INITIALLY_ZERO 0 359#define LISP_INITIALLY_ZERO 0
377#endif /* USE_LISP_UNION_TYPE */ 360#endif /* CHECK_LISP_OBJECT_TYPE */
378 361
379/* In the size word of a vector, this bit means the vector has been marked. */ 362/* In the size word of a vector, this bit means the vector has been marked. */
380 363
@@ -432,30 +415,28 @@ enum pvec_type
432 For example, if tem is a Lisp_Object whose type is Lisp_Cons, 415 For example, if tem is a Lisp_Object whose type is Lisp_Cons,
433 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */ 416 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */
434 417
435#ifndef USE_LISP_UNION_TYPE
436
437/* Return a perfect hash of the Lisp_Object representation. */ 418/* Return a perfect hash of the Lisp_Object representation. */
438#define XHASH(a) (a) 419#define XHASH(a) XLI(a)
439 420
440#if USE_LSB_TAG 421#if USE_LSB_TAG
441 422
442#define TYPEMASK ((((EMACS_INT) 1) << GCTYPEBITS) - 1) 423#define TYPEMASK ((((EMACS_INT) 1) << GCTYPEBITS) - 1)
443#define XTYPE(a) ((enum Lisp_Type) ((a) & TYPEMASK)) 424#define XTYPE(a) ((enum Lisp_Type) (XLI(a) & TYPEMASK))
444#ifdef USE_2_TAGS_FOR_INTS 425#ifdef USE_2_TAGS_FOR_INTS
445# define XINT(a) (((EMACS_INT) (a)) >> (GCTYPEBITS - 1)) 426# define XINT(a) (((EMACS_INT) XLI(a)) >> (GCTYPEBITS - 1))
446# define XUINT(a) (((EMACS_UINT) (a)) >> (GCTYPEBITS - 1)) 427# define XUINT(a) (((EMACS_UINT) XLI(a)) >> (GCTYPEBITS - 1))
447# define make_number(N) (((EMACS_INT) (N)) << (GCTYPEBITS - 1)) 428# define make_number(N) XIL(((EMACS_INT) (N)) << (GCTYPEBITS - 1))
448#else 429#else
449# define XINT(a) (((EMACS_INT) (a)) >> GCTYPEBITS) 430# define XINT(a) (((EMACS_INT) XLI(a)) >> GCTYPEBITS)
450# define XUINT(a) (((EMACS_UINT) (a)) >> GCTYPEBITS) 431# define XUINT(a) (((EMACS_UINT) XLI(a)) >> GCTYPEBITS)
451# define make_number(N) (((EMACS_INT) (N)) << GCTYPEBITS) 432# define make_number(N) XIL(((EMACS_INT) (N)) << GCTYPEBITS)
452#endif 433#endif
453#define XSET(var, type, ptr) \ 434#define XSET(var, type, ptr) \
454 (eassert (XTYPE ((intptr_t) (ptr)) == 0), /* Check alignment. */ \ 435 (eassert (XTYPE (XIL((intptr_t) (ptr))) == 0), /* Check alignment. */ \
455 (var) = (type) | (intptr_t) (ptr)) 436 (var) = XIL((type) | (intptr_t) (ptr)))
456 437
457#define XPNTR(a) ((intptr_t) ((a) & ~TYPEMASK)) 438#define XPNTR(a) ((intptr_t) (XLI(a) & ~TYPEMASK))
458#define XUNTAG(a, type) ((intptr_t) ((a) - (type))) 439#define XUNTAG(a, type) ((intptr_t) (XLI(a) - (type)))
459 440
460#else /* not USE_LSB_TAG */ 441#else /* not USE_LSB_TAG */
461 442
@@ -465,91 +446,42 @@ enum pvec_type
465 (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work 446 (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work
466 on all machines, but would penalize machines which don't need it) 447 on all machines, but would penalize machines which don't need it)
467 */ 448 */
468#define XTYPE(a) ((enum Lisp_Type) (((EMACS_UINT) (a)) >> VALBITS)) 449#define XTYPE(a) ((enum Lisp_Type) (((EMACS_UINT) XLI(a)) >> VALBITS))
469 450
470/* For integers known to be positive, XFASTINT provides fast retrieval 451/* For integers known to be positive, XFASTINT provides fast retrieval
471 and XSETFASTINT provides fast storage. This takes advantage of the 452 and XSETFASTINT provides fast storage. This takes advantage of the
472 fact that Lisp_Int is 0. */ 453 fact that Lisp_Int is 0. */
473#define XFASTINT(a) ((a) + 0) 454#define XFASTINT(a) (XLI(a) + 0)
474#define XSETFASTINT(a, b) ((a) = (b)) 455#define XSETFASTINT(a, b) ((a) = XIL(b))
475 456
476/* Extract the value of a Lisp_Object as a (un)signed integer. */ 457/* Extract the value of a Lisp_Object as a (un)signed integer. */
477 458
478#ifdef USE_2_TAGS_FOR_INTS 459#ifdef USE_2_TAGS_FOR_INTS
479# define XINT(a) ((((EMACS_INT) (a)) << (GCTYPEBITS - 1)) >> (GCTYPEBITS - 1)) 460# define XINT(a) ((((EMACS_INT) XLI(a)) << (GCTYPEBITS - 1)) >> (GCTYPEBITS - 1))
480# define XUINT(a) ((EMACS_UINT) ((a) & (1 + (VALMASK << 1)))) 461# define XUINT(a) ((EMACS_UINT) (XLI(a) & (1 + (VALMASK << 1))))
481# define make_number(N) ((((EMACS_INT) (N)) & (1 + (VALMASK << 1)))) 462# define make_number(N) XIL((((EMACS_INT) (N)) & (1 + (VALMASK << 1))))
482#else 463#else
483# define XINT(a) ((((EMACS_INT) (a)) << (BITS_PER_EMACS_INT - VALBITS)) \ 464# define XINT(a) ((((EMACS_INT) XLI(a)) << (BITS_PER_EMACS_INT - VALBITS)) \
484 >> (BITS_PER_EMACS_INT - VALBITS)) 465 >> (BITS_PER_EMACS_INT - VALBITS))
485# define XUINT(a) ((EMACS_UINT) ((a) & VALMASK)) 466# define XUINT(a) ((EMACS_UINT) (XLI(a) & VALMASK))
486# define make_number(N) \ 467# define make_number(N) \
487 ((((EMACS_INT) (N)) & VALMASK) | ((EMACS_INT) Lisp_Int) << VALBITS) 468 XIL((((EMACS_INT) (N)) & VALMASK) | ((EMACS_INT) Lisp_Int) << VALBITS)
488#endif 469#endif
489 470
490#define XSET(var, type, ptr) \ 471#define XSET(var, type, ptr) \
491 ((var) = ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \ 472 ((var) = XIL((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \
492 + ((intptr_t) (ptr) & VALMASK))) 473 + ((intptr_t) (ptr) & VALMASK)))
493 474
494#ifdef DATA_SEG_BITS 475#ifdef DATA_SEG_BITS
495/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers 476/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers
496 which were stored in a Lisp_Object */ 477 which were stored in a Lisp_Object */
497#define XPNTR(a) ((uintptr_t) (((a) & VALMASK)) | DATA_SEG_BITS)) 478#define XPNTR(a) ((uintptr_t) ((XLI(a) & VALMASK)) | DATA_SEG_BITS))
498#else 479#else
499#define XPNTR(a) ((uintptr_t) ((a) & VALMASK)) 480#define XPNTR(a) ((uintptr_t) (XLI(a) & VALMASK))
500#endif 481#endif
501 482
502#endif /* not USE_LSB_TAG */ 483#endif /* not USE_LSB_TAG */
503 484
504#else /* USE_LISP_UNION_TYPE */
505
506#ifdef USE_2_TAGS_FOR_INTS
507# error "USE_2_TAGS_FOR_INTS is not supported with USE_LISP_UNION_TYPE"
508#endif
509
510#define XHASH(a) ((a).i)
511#define XTYPE(a) ((enum Lisp_Type) (a).u.type)
512#define XINT(a) ((EMACS_INT) (a).s.val)
513#define XUINT(a) ((EMACS_UINT) (a).u.val)
514
515#if USE_LSB_TAG
516
517# define XSET(var, vartype, ptr) \
518 (eassert (((uintptr_t) (ptr) & ((1 << GCTYPEBITS) - 1)) == 0), \
519 (var).u.val = (uintptr_t) (ptr) >> GCTYPEBITS, \
520 (var).u.type = (vartype))
521
522/* Some versions of gcc seem to consider the bitfield width when issuing
523 the "cast to pointer from integer of different size" warning, so the
524 cast is here to widen the value back to its natural size. */
525# define XPNTR(v) ((intptr_t) (v).s.val << GCTYPEBITS)
526
527#else /* !USE_LSB_TAG */
528
529# define XSET(var, vartype, ptr) \
530 ((var).s.val = (intptr_t) (ptr), (var).s.type = (vartype))
531
532#ifdef DATA_SEG_BITS
533/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers
534 which were stored in a Lisp_Object */
535#define XPNTR(a) ((intptr_t) (XUINT (a) | DATA_SEG_BITS))
536#else
537#define XPNTR(a) ((intptr_t) XUINT (a))
538#endif
539
540#endif /* !USE_LSB_TAG */
541
542static inline Lisp_Object
543make_number (EMACS_INT n)
544{
545 Lisp_Object o;
546 o.s.val = n;
547 o.s.type = Lisp_Int;
548 return o;
549}
550
551#endif /* USE_LISP_UNION_TYPE */
552
553/* For integers known to be positive, XFASTINT sometimes provides 485/* For integers known to be positive, XFASTINT sometimes provides
554 faster retrieval and XSETFASTINT provides faster storage. 486 faster retrieval and XSETFASTINT provides faster storage.
555 If not, fallback on the non-accelerated path. */ 487 If not, fallback on the non-accelerated path. */
diff --git a/src/w32fns.c b/src/w32fns.c
index b8dc62f5250..a8becea1b74 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -6326,13 +6326,8 @@ The return value is the hotkey-id if registered, otherwise nil. */)
6326 6326
6327 /* Notify input thread about new hot-key definition, so that it 6327 /* Notify input thread about new hot-key definition, so that it
6328 takes effect without needing to switch focus. */ 6328 takes effect without needing to switch focus. */
6329#ifdef USE_LISP_UNION_TYPE
6330 PostThreadMessage (dwWindowsThreadId, WM_EMACS_REGISTER_HOT_KEY, 6329 PostThreadMessage (dwWindowsThreadId, WM_EMACS_REGISTER_HOT_KEY,
6331 (WPARAM) key.i, 0); 6330 (WPARAM) XLI (key), 0);
6332#else
6333 PostThreadMessage (dwWindowsThreadId, WM_EMACS_REGISTER_HOT_KEY,
6334 (WPARAM) key, 0);
6335#endif
6336 } 6331 }
6337 6332
6338 return key; 6333 return key;
@@ -6354,13 +6349,8 @@ DEFUN ("w32-unregister-hot-key", Fw32_unregister_hot_key,
6354 { 6349 {
6355 /* Notify input thread about hot-key definition being removed, so 6350 /* Notify input thread about hot-key definition being removed, so
6356 that it takes effect without needing focus switch. */ 6351 that it takes effect without needing focus switch. */
6357#ifdef USE_LISP_UNION_TYPE
6358 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY,
6359 (WPARAM) XINT (XCAR (item)), (LPARAM) item.i))
6360#else
6361 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY, 6352 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY,
6362 (WPARAM) XINT (XCAR (item)), (LPARAM) item)) 6353 (WPARAM) XINT (XCAR (item)), (LPARAM) XLI (item)))
6363#endif
6364 { 6354 {
6365 MSG msg; 6355 MSG msg;
6366 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE); 6356 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE);
@@ -6432,13 +6422,8 @@ is set to off if the low bit of NEW-STATE is zero, otherwise on. */)
6432 if (!dwWindowsThreadId) 6422 if (!dwWindowsThreadId)
6433 return make_number (w32_console_toggle_lock_key (vk_code, new_state)); 6423 return make_number (w32_console_toggle_lock_key (vk_code, new_state));
6434 6424
6435#ifdef USE_LISP_UNION_TYPE
6436 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_TOGGLE_LOCK_KEY,
6437 (WPARAM) vk_code, (LPARAM) new_state.i))
6438#else
6439 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_TOGGLE_LOCK_KEY, 6425 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_TOGGLE_LOCK_KEY,
6440 (WPARAM) vk_code, (LPARAM) new_state)) 6426 (WPARAM) vk_code, (LPARAM) XLI (new_state)))
6441#endif
6442 { 6427 {
6443 MSG msg; 6428 MSG msg;
6444 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE); 6429 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE);
diff --git a/src/w32heap.c b/src/w32heap.c
index 00572b20ae9..cc5e5cd2bf5 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -114,7 +114,7 @@ get_data_end (void)
114 return data_region_end; 114 return data_region_end;
115} 115}
116 116
117#if !defined USE_LISP_UNION_TYPE && !USE_LSB_TAG 117#if !USE_LSB_TAG
118static char * 118static char *
119allocate_heap (void) 119allocate_heap (void)
120{ 120{
@@ -141,7 +141,7 @@ allocate_heap (void)
141 141
142 return ptr; 142 return ptr;
143} 143}
144#else /* USE_LISP_UNION_TYPE || USE_LSB_TAG */ 144#else /* USE_LSB_TAG */
145static char * 145static char *
146allocate_heap (void) 146allocate_heap (void)
147{ 147{
@@ -160,7 +160,7 @@ allocate_heap (void)
160 160
161 return ptr; 161 return ptr;
162} 162}
163#endif /* USE_LISP_UNION_TYPE || USE_LSB_TAG */ 163#endif /* USE_LSB_TAG */
164 164
165 165
166/* Emulate Unix sbrk. Note that ralloc.c expects the return value to 166/* Emulate Unix sbrk. Note that ralloc.c expects the return value to
@@ -259,7 +259,7 @@ init_heap (void)
259 exit (1); 259 exit (1);
260 } 260 }
261 261
262#if !defined USE_LISP_UNION_TYPE && !USE_LSB_TAG 262#if !USE_LSB_TAG
263 /* Ensure that the addresses don't use the upper tag bits since 263 /* Ensure that the addresses don't use the upper tag bits since
264 the Lisp type goes there. */ 264 the Lisp type goes there. */
265 if (((unsigned long) data_region_base & ~VALMASK) != 0) 265 if (((unsigned long) data_region_base & ~VALMASK) != 0)
diff --git a/src/w32menu.c b/src/w32menu.c
index 2bc4c208956..f5f5c6656c4 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -1533,11 +1533,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1533 until it is ready to be displayed, since GC can happen while 1533 until it is ready to be displayed, since GC can happen while
1534 menus are active. */ 1534 menus are active. */
1535 if (!NILP (wv->help)) 1535 if (!NILP (wv->help))
1536#ifdef USE_LISP_UNION_TYPE 1536 info.dwItemData = (DWORD) XLI (wv->help);
1537 info.dwItemData = (DWORD) (wv->help).i;
1538#else
1539 info.dwItemData = (DWORD) (wv->help);
1540#endif
1541 if (wv->button_type == BUTTON_TYPE_RADIO) 1537 if (wv->button_type == BUTTON_TYPE_RADIO)
1542 { 1538 {
1543 /* CheckMenuRadioItem allows us to differentiate TOGGLE and 1539 /* CheckMenuRadioItem allows us to differentiate TOGGLE and
@@ -1612,12 +1608,7 @@ w32_menu_display_help (HWND owner, HMENU menu, UINT item, UINT flags)
1612 info.fMask = MIIM_DATA; 1608 info.fMask = MIIM_DATA;
1613 get_menu_item_info (menu, item, FALSE, &info); 1609 get_menu_item_info (menu, item, FALSE, &info);
1614 1610
1615#ifdef USE_LISP_UNION_TYPE 1611 help = info.dwItemData ? XIL (info.dwItemData) : Qnil;
1616 help = info.dwItemData ? (Lisp_Object) ((EMACS_INT) info.dwItemData)
1617 : Qnil;
1618#else
1619 help = info.dwItemData ? (Lisp_Object) info.dwItemData : Qnil;
1620#endif
1621 } 1612 }
1622 1613
1623 /* Store the help echo in the keyboard buffer as the X toolkit 1614 /* Store the help echo in the keyboard buffer as the X toolkit
diff --git a/src/w32term.c b/src/w32term.c
index a90e067a3fd..38120b77ac9 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -4342,7 +4342,7 @@ w32_read_socket (struct terminal *terminal, int expected,
4342 4342
4343 /* If the contents of the global variable help_echo_string 4343 /* If the contents of the global variable help_echo_string
4344 has changed, generate a HELP_EVENT. */ 4344 has changed, generate a HELP_EVENT. */
4345#if 0 /* The below is an invalid comparison when USE_LISP_UNION_TYPE. 4345#if 0 /* The below is an invalid comparison when CHECK_LISP_OBJECT_TYPE.
4346 But it was originally changed to this to fix a bug, so I have 4346 But it was originally changed to this to fix a bug, so I have
4347 not removed it completely in case the bug is still there. */ 4347 not removed it completely in case the bug is still there. */
4348 if (help_echo_string != previous_help_echo_string || 4348 if (help_echo_string != previous_help_echo_string ||