emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master f67bc3f 1/3: Port to recent gcc -fsanitize=undefine


From: Paul Eggert
Subject: [Emacs-diffs] master f67bc3f 1/3: Port to recent gcc -fsanitize=undefined
Date: Mon, 22 Apr 2019 00:16:32 -0400 (EDT)

branch: master
commit f67bc3f12b8ebe4ff0d133063e3c41ab772dbd45
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Port to recent gcc -fsanitize=undefined
    
    * src/alloc.c (XPNTR): Add ATTRIBUTE_NO_SANITIZE_UNDEFINED and
    remove ATTRIBUTE_UNUSED.  Do not define as a macro, so that
    ATTRIBUTE_NO_SANITIZE_UNDEFINED works.
    * src/lisp.h (lisp_h_XSYMBOL): Remove.  All uses removed.
    With recent GCC the macro does not work with -fsanitize=undefined,
    and the macro can be omitted as its only function is to optimize -O0.
---
 src/alloc.c |  6 +-----
 src/lisp.h  | 24 +++---------------------
 2 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index b5b6dc2..a9cdd77 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -558,16 +558,12 @@ PNTR_ADD (char *p, EMACS_UINT i)
                 - ((EMACS_UINT) Lisp_Symbol << (USE_LSB_TAG ? 0 : VALBITS)))) \
     : (char *) XLP (o) - (XLI (o) & ~VALMASK)))
 
-static ATTRIBUTE_UNUSED void *
+static ATTRIBUTE_NO_SANITIZE_UNDEFINED void *
 XPNTR (Lisp_Object a)
 {
   return macro_XPNTR (a);
 }
 
-#if DEFINE_KEY_OPS_AS_MACROS
-# define XPNTR(a) macro_XPNTR (a)
-#endif
-
 static void
 XFLOAT_INIT (Lisp_Object f, double n)
 {
diff --git a/src/lisp.h b/src/lisp.h
index c2cb89d..2d250fc 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -421,19 +421,6 @@ typedef EMACS_INT Lisp_Word;
     XIL ((EMACS_INT) (((EMACS_UINT) (n) << INTTYPEBITS) + Lisp_Int0))
 # define lisp_h_XFIXNAT(a) XFIXNUM (a)
 # define lisp_h_XFIXNUM(a) (XLI (a) >> INTTYPEBITS)
-# ifdef __CHKP__
-#  define lisp_h_XSYMBOL(a) \
-    (eassert (SYMBOLP (a)), \
-     (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.  */
-#  define lisp_h_XSYMBOL(a) \
-    (eassert (SYMBOLP (a)), \
-     (struct Lisp_Symbol *) ((intptr_t) XLI (a) - Lisp_Symbol \
-                            + (char *) lispsym))
-# endif
 # define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK))
 #endif
 
@@ -479,7 +466,6 @@ typedef EMACS_INT Lisp_Word;
 #  define make_fixnum(n) lisp_h_make_fixnum (n)
 #  define XFIXNAT(a) lisp_h_XFIXNAT (a)
 #  define XFIXNUM(a) lisp_h_XFIXNUM (a)
-#  define XSYMBOL(a) lisp_h_XSYMBOL (a)
 #  define XTYPE(a) lisp_h_XTYPE (a)
 # endif
 #endif
@@ -1023,21 +1009,17 @@ INLINE bool
 }
 
 INLINE struct Lisp_Symbol * ATTRIBUTE_NO_SANITIZE_UNDEFINED
-(XSYMBOL) (Lisp_Object a)
+XSYMBOL (Lisp_Object a)
 {
-#if USE_LSB_TAG
-  return lisp_h_XSYMBOL (a);
-#else
   eassert (SYMBOLP (a));
   intptr_t i = (intptr_t) XUNTAG (a, Lisp_Symbol, struct Lisp_Symbol);
   void *p = (char *) lispsym + i;
-# ifdef __CHKP__
+#ifdef __CHKP__
   /* Bypass pointer checking.  Although this could be improved it is
      probably not worth the trouble.  */
   p = __builtin___bnd_set_ptr_bounds (p, sizeof (struct Lisp_Symbol));
-# endif
-  return p;
 #endif
+  return p;
 }
 
 INLINE Lisp_Object



reply via email to

[Prev in Thread] Current Thread [Next in Thread]