diff options
| author | Paul Eggert | 2019-07-23 11:18:16 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-07-23 11:18:58 -0700 |
| commit | a48726ebae2f44ed15b97cb72bc7eca199d8de47 (patch) | |
| tree | 169d78ee718c9e8617df4de4175e0d82056f863f | |
| parent | 3479ec7332a474b3400cbc6b681c2a1f5637db94 (diff) | |
| download | emacs-a48726ebae2f44ed15b97cb72bc7eca199d8de47.tar.gz emacs-a48726ebae2f44ed15b97cb72bc7eca199d8de47.zip | |
Merge pdumper.c and alloc.c builtin symbol tests
* src/alloc.c (c_symbol_p): Move from here ...
* src/lisp.h (c_symbol_p): ... to here, and make it more portable
to hypothetical platforms where pointers are wider than ptrdiff_t.
* src/pdumper.c (dump_builtin_symbol_p): Use c_symbol_p.
| -rw-r--r-- | src/alloc.c | 9 | ||||
| -rw-r--r-- | src/lisp.h | 14 | ||||
| -rw-r--r-- | src/pdumper.c | 7 |
3 files changed, 15 insertions, 15 deletions
diff --git a/src/alloc.c b/src/alloc.c index f256ff71b07..c17bdb719a9 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -4964,15 +4964,6 @@ flush_stack_call_func (void (*func) (void *arg), void *arg) | |||
| 4964 | eassert (current_thread == self); | 4964 | eassert (current_thread == self); |
| 4965 | } | 4965 | } |
| 4966 | 4966 | ||
| 4967 | static bool | ||
| 4968 | c_symbol_p (struct Lisp_Symbol *sym) | ||
| 4969 | { | ||
| 4970 | char *lispsym_ptr = (char *) lispsym; | ||
| 4971 | char *sym_ptr = (char *) sym; | ||
| 4972 | ptrdiff_t lispsym_offset = sym_ptr - lispsym_ptr; | ||
| 4973 | return 0 <= lispsym_offset && lispsym_offset < sizeof lispsym; | ||
| 4974 | } | ||
| 4975 | |||
| 4976 | /* Determine whether it is safe to access memory at address P. */ | 4967 | /* Determine whether it is safe to access memory at address P. */ |
| 4977 | static int | 4968 | static int |
| 4978 | valid_pointer_p (void *p) | 4969 | valid_pointer_p (void *p) |
diff --git a/src/lisp.h b/src/lisp.h index e96fcfe94d3..17495777378 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1024,6 +1024,20 @@ builtin_lisp_symbol (int index) | |||
| 1024 | return make_lisp_symbol (&lispsym[index]); | 1024 | return make_lisp_symbol (&lispsym[index]); |
| 1025 | } | 1025 | } |
| 1026 | 1026 | ||
| 1027 | INLINE bool | ||
| 1028 | c_symbol_p (struct Lisp_Symbol *sym) | ||
| 1029 | { | ||
| 1030 | char *bp = (char *) lispsym; | ||
| 1031 | char *sp = (char *) sym; | ||
| 1032 | if (PTRDIFF_MAX < INTPTR_MAX) | ||
| 1033 | return bp <= sp && sp < bp + sizeof lispsym; | ||
| 1034 | else | ||
| 1035 | { | ||
| 1036 | ptrdiff_t offset = sp - bp; | ||
| 1037 | return 0 <= offset && offset < sizeof lispsym; | ||
| 1038 | } | ||
| 1039 | } | ||
| 1040 | |||
| 1027 | INLINE void | 1041 | INLINE void |
| 1028 | (CHECK_SYMBOL) (Lisp_Object x) | 1042 | (CHECK_SYMBOL) (Lisp_Object x) |
| 1029 | { | 1043 | { |
diff --git a/src/pdumper.c b/src/pdumper.c index 84147353e85..ddf44a53f86 100644 --- a/src/pdumper.c +++ b/src/pdumper.c | |||
| @@ -719,12 +719,7 @@ emacs_offset (const void *emacs_ptr) | |||
| 719 | static bool | 719 | static bool |
| 720 | dump_builtin_symbol_p (Lisp_Object object) | 720 | dump_builtin_symbol_p (Lisp_Object object) |
| 721 | { | 721 | { |
| 722 | if (!SYMBOLP (object)) | 722 | return SYMBOLP (object) && c_symbol_p (XSYMBOL (object)); |
| 723 | return false; | ||
| 724 | char *bp = (char *) lispsym; | ||
| 725 | struct Lisp_Symbol *s = XSYMBOL (object); | ||
| 726 | char *sp = (char *) s; | ||
| 727 | return bp <= sp && sp < bp + sizeof (lispsym); | ||
| 728 | } | 723 | } |
| 729 | 724 | ||
| 730 | /* Return whether OBJECT has the same bit pattern in all Emacs | 725 | /* Return whether OBJECT has the same bit pattern in all Emacs |