diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-04-21 20:34:03 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-04-21 21:16:26 -0700 |
commit | f67bc3f12b8ebe4ff0d133063e3c41ab772dbd45 (patch) | |
tree | f1f3482421b2358e0d95d1be4a62654c70a49a61 | |
parent | 3a618e5f89c86bc96925b06647fb33568c8fa2c9 (diff) | |
download | emacs-f67bc3f12b8ebe4ff0d133063e3c41ab772dbd45.tar.gz |
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.
-rw-r--r-- | src/alloc.c | 6 | ||||
-rw-r--r-- | src/lisp.h | 24 |
2 files changed, 4 insertions, 26 deletions
diff --git a/src/alloc.c b/src/alloc.c index b5b6dc2f05f..a9cdd77ef2e 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 c2cb89de9d5..2d250fc52ce 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 |