mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-07 08:00:48 -08:00
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.
This commit is contained in:
parent
3479ec7332
commit
a48726ebae
3 changed files with 15 additions and 15 deletions
|
|
@ -4964,15 +4964,6 @@ flush_stack_call_func (void (*func) (void *arg), void *arg)
|
|||
eassert (current_thread == self);
|
||||
}
|
||||
|
||||
static bool
|
||||
c_symbol_p (struct Lisp_Symbol *sym)
|
||||
{
|
||||
char *lispsym_ptr = (char *) lispsym;
|
||||
char *sym_ptr = (char *) sym;
|
||||
ptrdiff_t lispsym_offset = sym_ptr - lispsym_ptr;
|
||||
return 0 <= lispsym_offset && lispsym_offset < sizeof lispsym;
|
||||
}
|
||||
|
||||
/* Determine whether it is safe to access memory at address P. */
|
||||
static int
|
||||
valid_pointer_p (void *p)
|
||||
|
|
|
|||
14
src/lisp.h
14
src/lisp.h
|
|
@ -1024,6 +1024,20 @@ builtin_lisp_symbol (int index)
|
|||
return make_lisp_symbol (&lispsym[index]);
|
||||
}
|
||||
|
||||
INLINE bool
|
||||
c_symbol_p (struct Lisp_Symbol *sym)
|
||||
{
|
||||
char *bp = (char *) lispsym;
|
||||
char *sp = (char *) sym;
|
||||
if (PTRDIFF_MAX < INTPTR_MAX)
|
||||
return bp <= sp && sp < bp + sizeof lispsym;
|
||||
else
|
||||
{
|
||||
ptrdiff_t offset = sp - bp;
|
||||
return 0 <= offset && offset < sizeof lispsym;
|
||||
}
|
||||
}
|
||||
|
||||
INLINE void
|
||||
(CHECK_SYMBOL) (Lisp_Object x)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -719,12 +719,7 @@ emacs_offset (const void *emacs_ptr)
|
|||
static bool
|
||||
dump_builtin_symbol_p (Lisp_Object object)
|
||||
{
|
||||
if (!SYMBOLP (object))
|
||||
return false;
|
||||
char *bp = (char *) lispsym;
|
||||
struct Lisp_Symbol *s = XSYMBOL (object);
|
||||
char *sp = (char *) s;
|
||||
return bp <= sp && sp < bp + sizeof (lispsym);
|
||||
return SYMBOLP (object) && c_symbol_p (XSYMBOL (object));
|
||||
}
|
||||
|
||||
/* Return whether OBJECT has the same bit pattern in all Emacs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue