* 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.
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)
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)
{
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