return (void *) ROUNDUP ((uintptr_t) ptr, alignment);
}
-/* Extract the pointer hidden within O. Define this as a function, as
- functions are cleaner and can be used in debuggers. Also, define
- it as a macro if being compiled with GCC without optimization, for
- performance in that case. macro_XPNTR is private to this section
- of code. */
+/* Define PNTR_ADD and XPNTR as functions, which are cleaner and can
+ be used in debuggers. Also, define them as macros if
+ DEFINE_KEY_OPS_AS_MACROS, for performance in that case.
+ The macro_* macros are private to this section of code. */
+
+/* Add a pointer an an integer without complaint about a pointer going
+ out of range of the underlying array. */
+
+#define macro_PNTR_ADD(p, i) ((p) + (i))
+
+static char * ATTRIBUTE_NO_SANITIZE_UNDEFINED ATTRIBUTE_UNUSED
+PNTR_ADD (char *p, EMACS_UINT i)
+{
+ return macro_PNTR_ADD (p, i);
+}
+
+#if DEFINE_KEY_OPS_AS_MACROS
+# define PNTR_ADD(p, i) macro_PNTR_ADD (p, i)
+#endif
+
+/* Extract the pointer hidden within O. */
#define macro_XPNTR(o) \
((void *) \
(SYMBOLP (o) \
- ? ((char *) lispsym \
- - ((EMACS_UINT) Lisp_Symbol << (USE_LSB_TAG ? 0 : VALBITS)) \
- + XLI (o)) \
+ ? PNTR_ADD ((char *) lispsym, \
+ (XLI (o) \
+ - ((EMACS_UINT) Lisp_Symbol << (USE_LSB_TAG ? 0 : VALBITS)))) \
: (char *) XLP (o) - (XLI (o) & ~VALMASK)))
static ATTRIBUTE_UNUSED void *
# define __has_attribute_externally_visible GNUC_PREREQ (4, 1, 0)
# define __has_attribute_no_address_safety_analysis false
# define __has_attribute_no_sanitize_address GNUC_PREREQ (4, 8, 0)
+# define __has_attribute_no_sanitize_undefined GNUC_PREREQ (4, 9, 0)
#endif
/* Simulate __has_builtin on compilers that lack it. It is used only
# define ATTRIBUTE_NO_SANITIZE_ADDRESS
#endif
+/* Attribute of functions whose undefined behavior should not be sanitized. */
+
+#if __has_attribute (no_sanitize_undefined)
+# define ATTRIBUTE_NO_SANITIZE_UNDEFINED __attribute__ ((no_sanitize_undefined))
+#elif __has_attribute (no_sanitize)
+# define ATTRIBUTE_NO_SANITIZE_UNDEFINED \
+ __attribute__ ((no_sanitize ("undefined")))
+#else
+# define ATTRIBUTE_NO_SANITIZE_UNDEFINED
+#endif
+
/* gcc -fsanitize=address does not work with vfork in Fedora 25 x86-64.
For now, assume that this problem occurs on all platforms. */
#if ADDRESS_SANITIZER && !defined vfork