summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2018-06-10 10:13:45 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2018-06-10 10:16:53 -0700
commit0303fab396a818d796c7513457aa341ab703e8f3 (patch)
treecf8471d344ed264e9395f0b1eba183c9d4c0f4bc /src
parentefa750e68466fb1bab03028701350a745e0504b6 (diff)
downloademacs-0303fab396a818d796c7513457aa341ab703e8f3.tar.gz
Use native alignment to access Lisp object data
Instead of using __builtin_assume_aligned (P, GCALIGNMENT) to tell GCC that P has alignment 8, use (T *) P where T is the type of the pointed-to object, to tell GCC that P has native alignment. This is simpler, matches the intent better, and should help simplify future improvements. Some of these changes are to pacify gcc -Wnull-dereference, since GCC is smarter about pointers now that Emacs no longer uses __builtin_assume_aligned; these minor changes should improve code efficiency slightly. On Fedora 28 x86-64 with default optimization this patch shrinks the size of the Emacs text segment by 0.36%. * src/conf_post.h (__has_builtin, __builtin_assume_aligned): Remove; no longer used. * src/dbusbind.c (XD_OBJECT_TO_DBUS_TYPE): Pacify -Wnull-dereference by using XCAR instead of CAR_SAFE and XCDR instead of CDR_SAFE when this is safe. * src/fileio.c (Fexpand_file_name): * src/font.c (clear_font_cache): Pacify -Wnull-dereference by removing unnecessary NILP test. * src/keyboard.c (xevent_start): New function. (read_char, read_key_sequence): Pacify -Wnull-dereference by using xevent_start instead of EVENT_START. * src/lisp.h (lisp_h_XUNTAG): Remove; XUNTAG is always a macro now, since it can no longer be implemented as a function. (XUNTAG): New third argument CTYPE. All uses changed. Cast result to CTYPE * instead of using __builtin_assume_aligned. Simplify by using LISP_WORD_TAG. (LISP_WORD_TAG): New macro. (TAG_PTR): Use it. * src/menu.c (x_popup_menu_1): Pacify -Wnull-dereference by using XCAR instead of Fcar and XCDR instead of Fcdr where this is safe.
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c2
-rw-r--r--src/buffer.h2
-rw-r--r--src/conf_post.h13
-rw-r--r--src/dbusbind.c18
-rw-r--r--src/fileio.c17
-rw-r--r--src/font.c5
-rw-r--r--src/font.h12
-rw-r--r--src/frame.h2
-rw-r--r--src/keyboard.c21
-rw-r--r--src/lisp.h87
-rw-r--r--src/menu.c4
-rw-r--r--src/process.h2
-rw-r--r--src/termhooks.h2
-rw-r--r--src/thread.h6
-rw-r--r--src/w32fns.c2
-rw-r--r--src/w32menu.c3
-rw-r--r--src/window.h2
-rw-r--r--src/xwidget.h4
18 files changed, 95 insertions, 109 deletions
diff --git a/src/alloc.c b/src/alloc.c
index f600c89ae2c..cde2e4b3407 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2916,7 +2916,7 @@ DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
static struct Lisp_Vector *
next_vector (struct Lisp_Vector *v)
{
- return XUNTAG (v->contents[0], Lisp_Int0);
+ return XUNTAG (v->contents[0], Lisp_Int0, struct Lisp_Vector);
}
static void
diff --git a/src/buffer.h b/src/buffer.h
index b12dad684f2..85b5631736f 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -912,7 +912,7 @@ INLINE struct buffer *
XBUFFER (Lisp_Object a)
{
eassert (BUFFERP (a));
- return XUNTAG (a, Lisp_Vectorlike);
+ return XUNTAG (a, Lisp_Vectorlike, struct buffer);
}
/* Most code should use these functions to set Lisp fields in struct
diff --git a/src/conf_post.h b/src/conf_post.h
index 30f3b953056..080d7b7e688 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -70,14 +70,6 @@ typedef bool bool_bf;
# define __has_attribute_no_sanitize_undefined GNUC_PREREQ (4, 9, 0)
#endif
-/* Simulate __has_builtin on compilers that lack it. It is used only
- on arguments like __builtin_assume_aligned that are handled in this
- simulation. */
-#ifndef __has_builtin
-# define __has_builtin(a) __has_builtin_##a
-# define __has_builtin___builtin_assume_aligned GNUC_PREREQ (4, 7, 0)
-#endif
-
/* Simulate __has_feature on compilers that lack it. It is used only
to define ADDRESS_SANITIZER below. */
#ifndef __has_feature
@@ -91,11 +83,6 @@ typedef bool bool_bf;
# define ADDRESS_SANITIZER false
#endif
-/* Yield PTR, which must be aligned to ALIGNMENT. */
-#if ! __has_builtin (__builtin_assume_aligned)
-# define __builtin_assume_aligned(ptr, ...) ((void *) (ptr))
-#endif
-
#ifdef DARWIN_OS
#if defined emacs && !defined CANNOT_DUMP
#define malloc unexec_malloc
diff --git a/src/dbusbind.c b/src/dbusbind.c
index ec3707d18f3..4e0b99bea9d 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -207,10 +207,10 @@ xd_symbol_to_dbus_type (Lisp_Object object)
: (STRINGP (object)) ? DBUS_TYPE_STRING \
: (XD_DBUS_TYPE_P (object)) ? xd_symbol_to_dbus_type (object) \
: (CONSP (object)) \
- ? ((XD_DBUS_TYPE_P (CAR_SAFE (object))) \
- ? ((XD_BASIC_DBUS_TYPE (xd_symbol_to_dbus_type (CAR_SAFE (object)))) \
+ ? ((XD_DBUS_TYPE_P (XCAR (object))) \
+ ? ((XD_BASIC_DBUS_TYPE (xd_symbol_to_dbus_type (XCAR (object)))) \
? DBUS_TYPE_ARRAY \
- : xd_symbol_to_dbus_type (CAR_SAFE (object))) \
+ : xd_symbol_to_dbus_type (XCAR (object))) \
: DBUS_TYPE_ARRAY) \
: DBUS_TYPE_INVALID)
@@ -396,7 +396,7 @@ xd_signature (char *signature, int dtype, int parent_type, Lisp_Object object)
CHECK_CONS (object);
/* Type symbol is optional. */
- if (EQ (QCarray, CAR_SAFE (elt)))
+ if (EQ (QCarray, XCAR (elt)))
elt = XD_NEXT_VALUE (elt);
/* If the array is empty, DBUS_TYPE_STRING is the default
@@ -416,10 +416,12 @@ xd_signature (char *signature, int dtype, int parent_type, Lisp_Object object)
/* If the element type is DBUS_TYPE_SIGNATURE, and this is the
only element, the value of this element is used as the
array's element signature. */
- if ((subtype == DBUS_TYPE_SIGNATURE)
- && STRINGP (CAR_SAFE (XD_NEXT_VALUE (elt)))
- && NILP (CDR_SAFE (XD_NEXT_VALUE (elt))))
- subsig = SSDATA (CAR_SAFE (XD_NEXT_VALUE (elt)));
+ if (subtype == DBUS_TYPE_SIGNATURE)
+ {
+ Lisp_Object elt1 = XD_NEXT_VALUE (elt);
+ if (CONSP (elt1) && STRINGP (XCAR (elt1)) && NILP (XCDR (elt1)))
+ subsig = SSDATA (XCAR (elt1));
+ }
while (!NILP (elt))
{
diff --git a/src/fileio.c b/src/fileio.c
index e8d966e1631..47c5fec8532 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -813,17 +813,14 @@ the root directory. */)
#endif
}
- if (!NILP (default_directory))
+ handler = Ffind_file_name_handler (default_directory, Qexpand_file_name);
+ if (!NILP (handler))
{
- handler = Ffind_file_name_handler (default_directory, Qexpand_file_name);
- if (!NILP (handler))
- {
- handled_name = call3 (handler, Qexpand_file_name,
- name, default_directory);
- if (STRINGP (handled_name))
- return handled_name;
- error ("Invalid handler in `file-name-handler-alist'");
- }
+ handled_name = call3 (handler, Qexpand_file_name,
+ name, default_directory);
+ if (STRINGP (handled_name))
+ return handled_name;
+ error ("Invalid handler in `file-name-handler-alist'");
}
{
diff --git a/src/font.c b/src/font.c
index c886c299d19..3800869c5b3 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4354,10 +4354,9 @@ clear_font_cache (struct frame *f)
Lisp_Object val, tmp, cache = driver_list->driver->get_cache (f);
val = XCDR (cache);
- while (! NILP (val)
- && ! EQ (XCAR (XCAR (val)), driver_list->driver->type))
+ while (eassert (CONSP (val)),
+ ! EQ (XCAR (XCAR (val)), driver_list->driver->type))
val = XCDR (val);
- eassert (! NILP (val));
tmp = XCDR (XCAR (val));
if (XINT (XCAR (tmp)) == 0)
{
diff --git a/src/font.h b/src/font.h
index 469431fee67..6ec32def4b9 100644
--- a/src/font.h
+++ b/src/font.h
@@ -494,42 +494,42 @@ INLINE struct font_spec *
XFONT_SPEC (Lisp_Object p)
{
eassert (FONT_SPEC_P (p));
- return XUNTAG (p, Lisp_Vectorlike);
+ return XUNTAG (p, Lisp_Vectorlike, struct font_spec);
}
INLINE struct font_spec *
GC_XFONT_SPEC (Lisp_Object p)
{
eassert (GC_FONT_SPEC_P (p));
- return XUNTAG (p, Lisp_Vectorlike);
+ return XUNTAG (p, Lisp_Vectorlike, struct font_spec);
}
INLINE struct font_entity *
XFONT_ENTITY (Lisp_Object p)
{
eassert (FONT_ENTITY_P (p));
- return XUNTAG (p, Lisp_Vectorlike);
+ return XUNTAG (p, Lisp_Vectorlike, struct font_entity);
}
INLINE struct font_entity *
GC_XFONT_ENTITY (Lisp_Object p)
{
eassert (GC_FONT_ENTITY_P (p));
- return XUNTAG (p, Lisp_Vectorlike);
+ return XUNTAG (p, Lisp_Vectorlike, struct font_entity);
}
INLINE struct font *
XFONT_OBJECT (Lisp_Object p)
{
eassert (FONT_OBJECT_P (p));
- return XUNTAG (p, Lisp_Vectorlike);
+ return XUNTAG (p, Lisp_Vectorlike, struct font);
}
INLINE struct font *
GC_XFONT_OBJECT (Lisp_Object p)
{
eassert (GC_FONT_OBJECT_P (p));
- return XUNTAG (p, Lisp_Vectorlike);
+ return XUNTAG (p, Lisp_Vectorlike, struct font);
}
#define XSETFONT(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FONT))
diff --git a/src/frame.h b/src/frame.h
index 2c9c4143886..1f438d3f694 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -726,7 +726,7 @@ default_pixels_per_inch_y (void)
#define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
#define XFRAME(p) \
- (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
+ (eassert (FRAMEP (p)), XUNTAG (p, Lisp_Vectorlike, struct frame))
#define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
/* Given a window, return its frame as a Lisp_Object. */
diff --git a/src/keyboard.c b/src/keyboard.c
index e6b5cf79983..d498ac3feea 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -377,6 +377,15 @@ static void deliver_user_signal (int);
static char *find_user_signal_name (int);
static void store_user_signal_events (void);
+/* Like EVENT_START, but assume EVENT is an event.
+ This pacifies gcc -Wnull-dereference, which might otherwise
+ complain about earlier checks that EVENT is indeed an event. */
+static Lisp_Object
+xevent_start (Lisp_Object event)
+{
+ return XCAR (XCDR (event));
+}
+
/* These setters are used only in this file, so they can be private. */
static void
kset_echo_string (struct kboard *kb, Lisp_Object val)
@@ -2910,8 +2919,8 @@ read_char (int commandflag, Lisp_Object map,
so we won't do this twice, then queue it up. */
if (EVENT_HAS_PARAMETERS (c)
&& CONSP (XCDR (c))
- && CONSP (EVENT_START (c))
- && CONSP (XCDR (EVENT_START (c))))
+ && CONSP (xevent_start (c))
+ && CONSP (XCDR (xevent_start (c))))
{
Lisp_Object posn;
@@ -9397,12 +9406,12 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt,
}
}
else if (CONSP (XCDR (key))
- && CONSP (EVENT_START (key))
- && CONSP (XCDR (EVENT_START (key))))
+ && CONSP (xevent_start (key))
+ && CONSP (XCDR (xevent_start (key))))
{
Lisp_Object posn;
- posn = POSN_POSN (EVENT_START (key));
+ posn = POSN_POSN (xevent_start (key));
/* Handle menu-bar events:
insert the dummy prefix event `menu-bar'. */
if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar))
@@ -9414,7 +9423,7 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt,
/* Zap the position in key, so we know that we've
expanded it, and don't try to do so again. */
- POSN_SET_POSN (EVENT_START (key), list1 (posn));
+ POSN_SET_POSN (xevent_start (key), list1 (posn));
mock_input = t + 2;
goto replay_sequence;
diff --git a/src/lisp.h b/src/lisp.h
index 293cf2783c3..d4499846053 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -375,7 +375,7 @@ typedef EMACS_INT Lisp_Word;
#define lisp_h_XCAR(c) XCONS (c)->u.s.car
#define lisp_h_XCDR(c) XCONS (c)->u.s.u.cdr
#define lisp_h_XCONS(a) \
- (eassert (CONSP (a)), (struct Lisp_Cons *) XUNTAG (a, Lisp_Cons))
+ (eassert (CONSP (a)), XUNTAG (a, Lisp_Cons, struct Lisp_Cons))
#define lisp_h_XHASH(a) XUINT (a)
#ifndef GC_CHECK_CONS_LIST
# define lisp_h_check_cons_list() ((void) 0)
@@ -388,7 +388,8 @@ typedef EMACS_INT Lisp_Word;
# ifdef __CHKP__
# define lisp_h_XSYMBOL(a) \
(eassert (SYMBOLP (a)), \
- (struct Lisp_Symbol *) ((char *) XUNTAG (a, Lisp_Symbol) \
+ (struct Lisp_Symbol *) ((char *) XUNTAG (a, Lisp_Symbol, \
+ struct Lisp_Symbol) \
+ (intptr_t) lispsym))
# else
/* If !__CHKP__ this is equivalent, and is a bit faster as of GCC 7. */
@@ -398,8 +399,6 @@ typedef EMACS_INT Lisp_Word;
+ (char *) lispsym))
# endif
# define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK))
-# define lisp_h_XUNTAG(a, type) \
- __builtin_assume_aligned ((char *) XLP (a) - (type), GCALIGNMENT)
#endif
/* When compiling via gcc -O0, define the key operations as macros, as
@@ -447,7 +446,6 @@ typedef EMACS_INT Lisp_Word;
# define XINT(a) lisp_h_XINT (a)
# define XSYMBOL(a) lisp_h_XSYMBOL (a)
# define XTYPE(a) lisp_h_XTYPE (a)
-# define XUNTAG(a, type) lisp_h_XUNTAG (a, type)
# endif
#endif
@@ -691,20 +689,11 @@ INLINE void
lisp_h_CHECK_TYPE (ok, predicate, x);
}
-/* Extract A's pointer value, assuming A's type is TYPE. */
-
-INLINE void *
-(XUNTAG) (Lisp_Object a, int type)
-{
-#if USE_LSB_TAG
- return lisp_h_XUNTAG (a, type);
-#else
- EMACS_UINT utype = type;
- char *p = XLP (a);
- return p - (utype << (USE_LSB_TAG ? 0 : VALBITS));
-#endif
-}
+/* Extract A's pointer value, assuming A's Lisp type is TYPE and the
+ extracted pointer's type is CTYPE *. */
+#define XUNTAG(a, type, ctype) ((ctype *) \
+ ((char *) XLP (a) - LISP_WORD_TAG (type)))
/* Interned state of a symbol. */
@@ -812,10 +801,9 @@ verify (!USE_LSB_TAG || alignof (struct Lisp_Symbol) % GCALIGNMENT == 0);
#define DEFUN_ARGS_8 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, \
Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)
-/* Typedefs useful for implementing TAG_PTR. untagged_ptr represents
- a pointer before tagging, and Lisp_Word_tag contains a
- possibly-shifted tag to be added to an untagged_ptr to convert it
- to a Lisp_Word. */
+/* untagged_ptr represents a pointer before tagging, and Lisp_Word_tag
+ contains a possibly-shifted tag to be added to an untagged_ptr to
+ convert it to a Lisp_Word. */
#if LISP_WORDS_ARE_POINTERS
/* untagged_ptr is a pointer so that the compiler knows that TAG_PTR
yields a pointer; this can help with gcc -fcheck-pointer-bounds.
@@ -830,11 +818,13 @@ typedef uintptr_t untagged_ptr;
typedef EMACS_UINT Lisp_Word_tag;
#endif
+/* A integer value tagged with TAG, and otherwise all zero. */
+#define LISP_WORD_TAG(tag) \
+ ((Lisp_Word_tag) (tag) << (USE_LSB_TAG ? 0 : VALBITS))
+
/* An initializer for a Lisp_Object that contains TAG along with PTR. */
#define TAG_PTR(tag, ptr) \
- LISP_INITIALLY ((Lisp_Word) \
- ((untagged_ptr) (ptr) \
- + ((Lisp_Word_tag) (tag) << (USE_LSB_TAG ? 0 : VALBITS))))
+ LISP_INITIALLY ((Lisp_Word) ((untagged_ptr) (ptr) + LISP_WORD_TAG (tag)))
/* LISPSYM_INITIALLY (Qfoo) is equivalent to Qfoo except it is
designed for use as an initializer, even for a constant initializer. */
@@ -913,7 +903,7 @@ INLINE struct Lisp_Symbol * ATTRIBUTE_NO_SANITIZE_UNDEFINED
return lisp_h_XSYMBOL (a);
#else
eassert (SYMBOLP (a));
- intptr_t i = (intptr_t) XUNTAG (a, Lisp_Symbol);
+ intptr_t i = (intptr_t) XUNTAG (a, Lisp_Symbol, struct Lisp_Symbol);
void *p = (char *) lispsym + i;
# ifdef __CHKP__
/* Bypass pointer checking. Although this could be improved it is
@@ -1159,7 +1149,7 @@ INLINE Lisp_Object
make_lisp_ptr (void *ptr, enum Lisp_Type type)
{
Lisp_Object a = TAG_PTR (type, ptr);
- eassert (XTYPE (a) == type && XUNTAG (a, type) == ptr);
+ eassert (XTYPE (a) == type && XUNTAG (a, type, char) == ptr);
return a;
}
@@ -1191,8 +1181,8 @@ INLINE bool
/* The cast to union vectorlike_header * avoids aliasing issues. */
#define XSETPSEUDOVECTOR(a, b, code) \
XSETTYPED_PSEUDOVECTOR (a, b, \
- (((union vectorlike_header *) \
- XUNTAG (a, Lisp_Vectorlike)) \
+ (XUNTAG (a, Lisp_Vectorlike, \
+ union vectorlike_header) \
->size), \
code)
#define XSETTYPED_PSEUDOVECTOR(a, b, size, code) \
@@ -1223,7 +1213,7 @@ INLINE bool
INLINE void *
XINTPTR (Lisp_Object a)
{
- return XUNTAG (a, Lisp_Int0);
+ return XUNTAG (a, Lisp_Int0, char);
}
INLINE Lisp_Object
@@ -1399,7 +1389,7 @@ INLINE struct Lisp_String *
XSTRING (Lisp_Object a)
{
eassert (STRINGP (a));
- return XUNTAG (a, Lisp_String);
+ return XUNTAG (a, Lisp_String, struct Lisp_String);
}
/* True if STR is a multibyte string. */
@@ -1524,7 +1514,7 @@ INLINE struct Lisp_Vector *
XVECTOR (Lisp_Object a)
{
eassert (VECTORLIKEP (a));
- return XUNTAG (a, Lisp_Vectorlike);
+ return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Vector);
}
INLINE ptrdiff_t
@@ -1584,8 +1574,9 @@ PSEUDOVECTORP (Lisp_Object a, int code)
else
{
/* Converting to union vectorlike_header * avoids aliasing issues. */
- union vectorlike_header *h = XUNTAG (a, Lisp_Vectorlike);
- return PSEUDOVECTOR_TYPEP (h, code);
+ return PSEUDOVECTOR_TYPEP (XUNTAG (a, Lisp_Vectorlike,
+ union vectorlike_header),
+ code);
}
}
@@ -1647,7 +1638,7 @@ INLINE struct Lisp_Bool_Vector *
XBOOL_VECTOR (Lisp_Object a)
{
eassert (BOOL_VECTOR_P (a));
- return XUNTAG (a, Lisp_Vectorlike);
+ return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Bool_Vector);
}
INLINE EMACS_INT
@@ -1845,7 +1836,7 @@ INLINE struct Lisp_Char_Table *
XCHAR_TABLE (Lisp_Object a)
{
eassert (CHAR_TABLE_P (a));
- return XUNTAG (a, Lisp_Vectorlike);
+ return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Char_Table);
}
struct Lisp_Sub_Char_Table
@@ -1879,7 +1870,7 @@ INLINE struct Lisp_Sub_Char_Table *
XSUB_CHAR_TABLE (Lisp_Object a)
{
eassert (SUB_CHAR_TABLE_P (a));
- return XUNTAG (a, Lisp_Vectorlike);
+ return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Sub_Char_Table);
}
INLINE Lisp_Object
@@ -1957,7 +1948,7 @@ INLINE struct Lisp_Subr *
XSUBR (Lisp_Object a)
{
eassert (SUBRP (a));
- return XUNTAG (a, Lisp_Vectorlike);
+ return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Subr);
}
enum char_table_specials
@@ -2210,7 +2201,7 @@ INLINE struct Lisp_Hash_Table *
XHASH_TABLE (Lisp_Object a)
{
eassert (HASH_TABLE_P (a));
- return XUNTAG (a, Lisp_Vectorlike);
+ return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Hash_Table);
}
#define XSET_HASH_TABLE(VAR, PTR) \
@@ -2294,7 +2285,7 @@ INLINE struct Lisp_Misc_Any *
XMISCANY (Lisp_Object a)
{
eassert (MISCP (a));
- return XUNTAG (a, Lisp_Misc);
+ return XUNTAG (a, Lisp_Misc, struct Lisp_Misc_Any);
}
INLINE enum Lisp_Misc_Type
@@ -2470,7 +2461,7 @@ INLINE struct Lisp_Save_Value *
XSAVE_VALUE (Lisp_Object a)
{
eassert (SAVE_VALUEP (a));
- return XUNTAG (a, Lisp_Misc);
+ return XUNTAG (a, Lisp_Misc, struct Lisp_Save_Value);
}
/* Return the type of V's Nth saved value. */
@@ -2563,7 +2554,7 @@ INLINE struct Lisp_Finalizer *
XFINALIZER (Lisp_Object a)
{
eassert (FINALIZERP (a));
- return XUNTAG (a, Lisp_Misc);
+ return XUNTAG (a, Lisp_Misc, struct Lisp_Finalizer);
}
/* A miscellaneous object, when it's on the free list. */
@@ -2594,7 +2585,7 @@ union Lisp_Misc
INLINE union Lisp_Misc *
XMISC (Lisp_Object a)
{
- return XUNTAG (a, Lisp_Misc);
+ return XUNTAG (a, Lisp_Misc, union Lisp_Misc);
}
INLINE bool
@@ -2607,7 +2598,7 @@ INLINE struct Lisp_Marker *
XMARKER (Lisp_Object a)
{
eassert (MARKERP (a));
- return XUNTAG (a, Lisp_Misc);
+ return XUNTAG (a, Lisp_Misc, struct Lisp_Marker);
}
INLINE bool
@@ -2620,7 +2611,7 @@ INLINE struct Lisp_Overlay *
XOVERLAY (Lisp_Object a)
{
eassert (OVERLAYP (a));
- return XUNTAG (a, Lisp_Misc);
+ return XUNTAG (a, Lisp_Misc, struct Lisp_Overlay);
}
#ifdef HAVE_MODULES
@@ -2634,7 +2625,7 @@ INLINE struct Lisp_User_Ptr *
XUSER_PTR (Lisp_Object a)
{
eassert (USER_PTRP (a));
- return XUNTAG (a, Lisp_Misc);
+ return XUNTAG (a, Lisp_Misc, struct Lisp_User_Ptr);
}
#endif
@@ -2778,7 +2769,7 @@ INLINE struct Lisp_Float *
XFLOAT (Lisp_Object a)
{
eassert (FLOATP (a));
- return XUNTAG (a, Lisp_Float);
+ return XUNTAG (a, Lisp_Float, struct Lisp_Float);
}
INLINE double
@@ -4055,7 +4046,7 @@ INLINE struct Lisp_Module_Function *
XMODULE_FUNCTION (Lisp_Object o)
{
eassert (MODULE_FUNCTIONP (o));
- return XUNTAG (o, Lisp_Vectorlike);
+ return XUNTAG (o, Lisp_Vectorlike, struct Lisp_Module_Function);
}
#ifdef HAVE_MODULES
diff --git a/src/menu.c b/src/menu.c
index 93e793a5d91..e7d4d782fe8 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1152,7 +1152,7 @@ x_popup_menu_1 (Lisp_Object position, Lisp_Object menu)
else
{
menuflags |= MENU_FOR_CLICK;
- tem = Fcar (Fcdr (position)); /* EVENT_START (position) */
+ tem = Fcar (XCDR (position)); /* EVENT_START (position) */
window = Fcar (tem); /* POSN_WINDOW (tem) */
tem2 = Fcar (Fcdr (tem)); /* POSN_POSN (tem) */
/* The MENU_KBD_NAVIGATION field is set when the menu
@@ -1168,7 +1168,7 @@ x_popup_menu_1 (Lisp_Object position, Lisp_Object menu)
event. */
if (!EQ (POSN_POSN (last_nonmenu_event),
POSN_POSN (position))
- && CONSP (tem2) && EQ (Fcar (tem2), Qmenu_bar))
+ && CONSP (tem2) && EQ (XCAR (tem2), Qmenu_bar))
menuflags |= MENU_KBD_NAVIGATION;
tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */
x = Fcar (tem);
diff --git a/src/process.h b/src/process.h
index 6464a8cc61a..42cc66ec560 100644
--- a/src/process.h
+++ b/src/process.h
@@ -220,7 +220,7 @@ INLINE struct Lisp_Process *
XPROCESS (Lisp_Object a)
{
eassert (PROCESSP (a));
- return XUNTAG (a, Lisp_Vectorlike);
+ return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Process);
}
/* Every field in the preceding structure except for the first two
diff --git a/src/termhooks.h b/src/termhooks.h
index 1b2c95e8248..d8c5edc948e 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -669,7 +669,7 @@ INLINE struct terminal *
XTERMINAL (Lisp_Object a)
{
eassert (TERMINALP (a));
- return XUNTAG (a, Lisp_Vectorlike);
+ return XUNTAG (a, Lisp_Vectorlike, struct terminal);
}
/* Most code should use these functions to set Lisp fields in struct
diff --git a/src/thread.h b/src/thread.h
index 5ab5e90c70d..2c8914e1b28 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -208,7 +208,7 @@ INLINE struct thread_state *
XTHREAD (Lisp_Object a)
{
eassert (THREADP (a));
- return XUNTAG (a, Lisp_Vectorlike);
+ return XUNTAG (a, Lisp_Vectorlike, struct thread_state);
}
/* A mutex in lisp is represented by a system condition variable.
@@ -255,7 +255,7 @@ INLINE struct Lisp_Mutex *
XMUTEX (Lisp_Object a)
{
eassert (MUTEXP (a));
- return XUNTAG (a, Lisp_Vectorlike);
+ return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Mutex);
}
/* A condition variable as a lisp object. */
@@ -289,7 +289,7 @@ INLINE struct Lisp_CondVar *
XCONDVAR (Lisp_Object a)
{
eassert (CONDVARP (a));
- return XUNTAG (a, Lisp_Vectorlike);
+ return XUNTAG (a, Lisp_Vectorlike, struct Lisp_CondVar);
}
extern struct thread_state *current_thread;
diff --git a/src/w32fns.c b/src/w32fns.c
index 5d1c3c84c67..2cb715a356d 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -8542,7 +8542,7 @@ DEFUN ("w32-unregister-hot-key", Fw32_unregister_hot_key,
eassert (CONSP (item));
/* Pass the tail of the list as a pointer to a Lisp_Cons cell,
so that it works in a --with-wide-int build as well. */
- lparam = (LPARAM) XUNTAG (item, Lisp_Cons);
+ lparam = (LPARAM) XUNTAG (item, Lisp_Cons, struct Lisp_Cons);
/* Notify input thread about hot-key definition being removed, so
that it takes effect without needing focus switch. */
diff --git a/src/w32menu.c b/src/w32menu.c
index 30ad54db26d..ece5836498f 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -1407,7 +1407,8 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
Windows alike. MSVC headers get it right; hopefully,
MinGW headers will, too. */
eassert (STRINGP (wv->help));
- info.dwItemData = (ULONG_PTR) XUNTAG (wv->help, Lisp_String);
+ info.dwItemData = (ULONG_PTR) XUNTAG (wv->help, Lisp_String,
+ struct Lisp_String);
}
if (wv->button_type == BUTTON_TYPE_RADIO)
{
diff --git a/src/window.h b/src/window.h
index 91ef7d90272..013083eb9a8 100644
--- a/src/window.h
+++ b/src/window.h
@@ -418,7 +418,7 @@ INLINE struct window *
XWINDOW (Lisp_Object a)
{
eassert (WINDOWP (a));
- return XUNTAG (a, Lisp_Vectorlike);
+ return XUNTAG (a, Lisp_Vectorlike, struct window);
}
/* Most code should use these functions to set Lisp fields in struct
diff --git a/src/xwidget.h b/src/xwidget.h
index 93f4cfb7949..89fc7ff4586 100644
--- a/src/xwidget.h
+++ b/src/xwidget.h
@@ -94,7 +94,7 @@ struct xwidget_view
/* Test for xwidget pseudovector. */
#define XWIDGETP(x) PSEUDOVECTORP (x, PVEC_XWIDGET)
#define XXWIDGET(a) (eassert (XWIDGETP (a)), \
- (struct xwidget *) XUNTAG (a, Lisp_Vectorlike))
+ XUNTAG (a, Lisp_Vectorlike, struct xwidget))
#define CHECK_XWIDGET(x) \
CHECK_TYPE (XWIDGETP (x), Qxwidgetp, x)
@@ -102,7 +102,7 @@ struct xwidget_view
/* Test for xwidget_view pseudovector. */
#define XWIDGET_VIEW_P(x) PSEUDOVECTORP (x, PVEC_XWIDGET_VIEW)
#define XXWIDGET_VIEW(a) (eassert (XWIDGET_VIEW_P (a)), \
- (struct xwidget_view *) XUNTAG (a, Lisp_Vectorlike))
+ XUNTAG (a, Lisp_Vectorlike, struct xwidget_view))
#define CHECK_XWIDGET_VIEW(x) \
CHECK_TYPE (XWIDGET_VIEW_P (x), Qxwidget_view_p, x)