diff options
| author | Paul Eggert | 2019-04-21 21:45:04 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-04-21 21:45:37 -0700 |
| commit | 418400ab7b36d873905f5ab5e1e07f2bdbd05f9c (patch) | |
| tree | 4987342d606912d636c2e631043d576a969b96c5 /src/alloc.c | |
| parent | e85bff0bbb60e1d819f8f5e00f8496026f27f7ea (diff) | |
| download | emacs-418400ab7b36d873905f5ab5e1e07f2bdbd05f9c.tar.gz emacs-418400ab7b36d873905f5ab5e1e07f2bdbd05f9c.zip | |
Simplify XPNTR
Because XPNTR now uses ATTRIBUTE_NO_SANITIZE_UNDEFINED,
it can be simplified.
* src/alloc.c (macro_PNTR_ADD, PNTR_ADD, macro_XPNTR): Remove.
(XPNTR): Open-code rather than using the removed macros and
functions. Also, simplify by using LISP_WORD_TAG.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 32 |
1 files changed, 3 insertions, 29 deletions
diff --git a/src/alloc.c b/src/alloc.c index a9cdd77ef2e..186a4c6a098 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -528,40 +528,14 @@ pointer_align (void *ptr, int alignment) | |||
| 528 | return (void *) ROUNDUP ((uintptr_t) ptr, alignment); | 528 | return (void *) ROUNDUP ((uintptr_t) ptr, alignment); |
| 529 | } | 529 | } |
| 530 | 530 | ||
| 531 | /* Define PNTR_ADD and XPNTR as functions, which are cleaner and can | ||
| 532 | be used in debuggers. Also, define them as macros if | ||
| 533 | DEFINE_KEY_OPS_AS_MACROS, for performance in that case. | ||
| 534 | The macro_* macros are private to this section of code. */ | ||
| 535 | |||
| 536 | /* Add a pointer P to an integer I without gcc -fsanitize complaining | ||
| 537 | about the result being out of range of the underlying array. */ | ||
| 538 | |||
| 539 | #define macro_PNTR_ADD(p, i) ((p) + (i)) | ||
| 540 | |||
| 541 | static ATTRIBUTE_NO_SANITIZE_UNDEFINED ATTRIBUTE_UNUSED char * | ||
| 542 | PNTR_ADD (char *p, EMACS_UINT i) | ||
| 543 | { | ||
| 544 | return macro_PNTR_ADD (p, i); | ||
| 545 | } | ||
| 546 | |||
| 547 | #if DEFINE_KEY_OPS_AS_MACROS | ||
| 548 | # define PNTR_ADD(p, i) macro_PNTR_ADD (p, i) | ||
| 549 | #endif | ||
| 550 | |||
| 551 | /* Extract the pointer hidden within O. */ | 531 | /* Extract the pointer hidden within O. */ |
| 552 | 532 | ||
| 553 | #define macro_XPNTR(o) \ | ||
| 554 | ((void *) \ | ||
| 555 | (SYMBOLP (o) \ | ||
| 556 | ? PNTR_ADD ((char *) lispsym, \ | ||
| 557 | (XLI (o) \ | ||
| 558 | - ((EMACS_UINT) Lisp_Symbol << (USE_LSB_TAG ? 0 : VALBITS)))) \ | ||
| 559 | : (char *) XLP (o) - (XLI (o) & ~VALMASK))) | ||
| 560 | |||
| 561 | static ATTRIBUTE_NO_SANITIZE_UNDEFINED void * | 533 | static ATTRIBUTE_NO_SANITIZE_UNDEFINED void * |
| 562 | XPNTR (Lisp_Object a) | 534 | XPNTR (Lisp_Object a) |
| 563 | { | 535 | { |
| 564 | return macro_XPNTR (a); | 536 | return (SYMBOLP (a) |
| 537 | ? (char *) lispsym + (XLI (a) - LISP_WORD_TAG (Lisp_Symbol)) | ||
| 538 | : (char *) XLP (a) - (XLI (a) & ~VALMASK)); | ||
| 565 | } | 539 | } |
| 566 | 540 | ||
| 567 | static void | 541 | static void |