Commit ad013ba6 authored by Paul Eggert's avatar Paul Eggert
Browse files

Minor cleanups for Lisp objects and symbols

* alloc.c (next_vector, set_next_vector):
* lisp.h (lisp_h_INTEGERP, make_number, XFASTINT, make_natnum):
(lisp_h_make_number) [USE_LSB_TAG]:
Use Lisp_Int0 instead of the mystery constant 0.
* alloc.c (mark_object): Always set and use po; that's simpler.
(CHECK_LIVE, CHECK_ALLOCATED_AND_LIVE):
Properly parenthesize definientia.
* bidi.c (bidi_initialize):
* buffer.c (init_buffer_once):
* nsfns.m (syms_of_nsfns):
* nsmenu.m (syms_of_nsmenu):
* nsselect.m (syms_of_nsselect):
Prefer DEFSYM to defining by hand.
* data.c: Fix too-long line.
* lisp.h (DECLARE_GDB_SYM): New macro.
(DEFINE_GDB_SYMBOL_BEGIN): Use it.
(DEFINE_GDB_SYMBOL_BEGIN, DEFINE_GDB_SYMBOL_END) [!MAIN_PROGRAM]:
Declare the symbol, so it's visible to everywhere lisp.h is included.
Move forward decls as far forward as they can go,
to allow future changes to use them.
parent 83299b94
2014-12-19 Paul Eggert <eggert@cs.ucla.edu>
Minor cleanups for Lisp objects and symbols
* alloc.c (next_vector, set_next_vector):
* lisp.h (lisp_h_INTEGERP, make_number, XFASTINT, make_natnum):
(lisp_h_make_number) [USE_LSB_TAG]:
Use Lisp_Int0 instead of the mystery constant 0.
* alloc.c (mark_object): Always set and use po; that's simpler.
(CHECK_LIVE, CHECK_ALLOCATED_AND_LIVE):
Properly parenthesize definientia.
* bidi.c (bidi_initialize):
* buffer.c (init_buffer_once):
* nsfns.m (syms_of_nsfns):
* nsmenu.m (syms_of_nsmenu):
* nsselect.m (syms_of_nsselect):
Prefer DEFSYM to defining by hand.
* data.c: Fix too-long line.
* lisp.h (DECLARE_GDB_SYM): New macro.
(DEFINE_GDB_SYMBOL_BEGIN): Use it.
(DEFINE_GDB_SYMBOL_BEGIN, DEFINE_GDB_SYMBOL_END) [!MAIN_PROGRAM]:
Declare the symbol, so it's visible to everywhere lisp.h is included.
Move forward decls as far forward as they can go,
to allow future changes to use them.
2014-12-18 Paul Eggert <eggert@cs.ucla.edu>
 
* gnutls.c: Include gnutls.h.
......
......@@ -2719,13 +2719,13 @@ DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
static struct Lisp_Vector *
next_vector (struct Lisp_Vector *v)
{
return XUNTAG (v->contents[0], 0);
return XUNTAG (v->contents[0], Lisp_Int0);
}
static void
set_next_vector (struct Lisp_Vector *v, struct Lisp_Vector *p)
{
v->contents[0] = make_lisp_ptr (p, 0);
v->contents[0] = make_lisp_ptr (p, Lisp_Int0);
}
/* This value is balanced well enough to avoid too much internal overhead
......@@ -6155,15 +6155,16 @@ void
mark_object (Lisp_Object arg)
{
register Lisp_Object obj = arg;
#ifdef GC_CHECK_MARKED_OBJECTS
void *po;
#ifdef GC_CHECK_MARKED_OBJECTS
struct mem_node *m;
#endif
ptrdiff_t cdr_count = 0;
loop:
if (PURE_POINTER_P (XPNTR (obj)))
po = XPNTR (obj);
if (PURE_POINTER_P (po))
return;
last_marked[last_marked_index++] = obj;
......@@ -6175,8 +6176,6 @@ mark_object (Lisp_Object arg)
by ~80%, and requires compilation with GC_MARK_STACK != 0. */
#ifdef GC_CHECK_MARKED_OBJECTS
po = (void *) XPNTR (obj);
/* Check that the object pointed to by PO is known to be a Lisp
structure allocated from the heap. */
#define CHECK_ALLOCATED() \
......@@ -6203,8 +6202,8 @@ mark_object (Lisp_Object arg)
#else /* not GC_CHECK_MARKED_OBJECTS */
#define CHECK_LIVE(LIVEP) (void) 0
#define CHECK_ALLOCATED_AND_LIVE(LIVEP) (void) 0
#define CHECK_LIVE(LIVEP) ((void) 0)
#define CHECK_ALLOCATED_AND_LIVE(LIVEP) ((void) 0)
#endif /* not GC_CHECK_MARKED_OBJECTS */
......
......@@ -1108,14 +1108,12 @@ bidi_initialize (void)
emacs_abort ();
staticpro (&bidi_brackets_table);
Qparagraph_start = intern ("paragraph-start");
staticpro (&Qparagraph_start);
DEFSYM (Qparagraph_start, "paragraph-start");
paragraph_start_re = Fsymbol_value (Qparagraph_start);
if (!STRINGP (paragraph_start_re))
paragraph_start_re = build_string ("\f\\|[ \t]*$");
staticpro (&paragraph_start_re);
Qparagraph_separate = intern ("paragraph-separate");
staticpro (&Qparagraph_separate);
DEFSYM (Qparagraph_separate, "paragraph-separate");
paragraph_separate_re = Fsymbol_value (Qparagraph_separate);
if (!STRINGP (paragraph_separate_re))
paragraph_separate_re = build_string ("[ \t\f]*$");
......
......@@ -5224,16 +5224,14 @@ init_buffer_once (void)
QSFundamental = build_pure_c_string ("Fundamental");
Qfundamental_mode = intern_c_string ("fundamental-mode");
DEFSYM (Qfundamental_mode, "fundamental-mode");
bset_major_mode (&buffer_defaults, Qfundamental_mode);
Qmode_class = intern_c_string ("mode-class");
DEFSYM (Qmode_class, "mode-class");
DEFSYM (Qprotected_field, "protected-field");
Qprotected_field = intern_c_string ("protected-field");
Qpermanent_local = intern_c_string ("permanent-local");
Qkill_buffer_hook = intern_c_string ("kill-buffer-hook");
DEFSYM (Qpermanent_local, "permanent-local");
DEFSYM (Qkill_buffer_hook, "kill-buffer-hook");
Fput (Qkill_buffer_hook, Qpermanent_local, Qt);
/* super-magic invisible buffer */
......
......@@ -89,7 +89,8 @@ static Lisp_Object Qdefun;
Lisp_Object Qinteractive_form;
static Lisp_Object Qdefalias_fset_function;
static void swap_in_symval_forwarding (struct Lisp_Symbol *, struct Lisp_Buffer_Local_Value *);
static void swap_in_symval_forwarding (struct Lisp_Symbol *,
struct Lisp_Buffer_Local_Value *);
static bool
BOOLFWDP (union Lisp_Fwd *a)
......
......@@ -44,12 +44,13 @@ INLINE_HEADER_BEGIN
definitions or enums visible to the debugger. It's used for symbols
that .gdbinit needs. */
#define DECLARE_GDB_SYM(type, id) type const id EXTERNALLY_VISIBLE
#ifdef MAIN_PROGRAM
# define DEFINE_GDB_SYMBOL_BEGIN(type, id) type const id EXTERNALLY_VISIBLE
# define DEFINE_GDB_SYMBOL_BEGIN(type, id) DECLARE_GDB_SYM (type, id)
# define DEFINE_GDB_SYMBOL_END(id) = id;
#else
# define DEFINE_GDB_SYMBOL_BEGIN(type, id)
# define DEFINE_GDB_SYMBOL_END(val)
# define DEFINE_GDB_SYMBOL_BEGIN(type, id) extern DECLARE_GDB_SYM (type, id)
# define DEFINE_GDB_SYMBOL_END(val) ;
#endif
/* The ubiquitous max and min macros. */
......@@ -337,7 +338,7 @@ error !;
#define lisp_h_CONSP(x) (XTYPE (x) == Lisp_Cons)
#define lisp_h_EQ(x, y) (XLI (x) == XLI (y))
#define lisp_h_FLOATP(x) (XTYPE (x) == Lisp_Float)
#define lisp_h_INTEGERP(x) ((XTYPE (x) & ~Lisp_Int1) == 0)
#define lisp_h_INTEGERP(x) ((XTYPE (x) & (Lisp_Int0 | ~Lisp_Int1)) == Lisp_Int0)
#define lisp_h_MARKERP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Marker)
#define lisp_h_MISCP(x) (XTYPE (x) == Lisp_Misc)
#define lisp_h_NILP(x) EQ (x, Qnil)
......@@ -361,7 +362,7 @@ error !;
#endif
#if USE_LSB_TAG
# define lisp_h_make_number(n) \
XIL ((EMACS_INT) ((EMACS_UINT) (n) << INTTYPEBITS))
XIL ((EMACS_INT) (((EMACS_UINT) (n) << INTTYPEBITS) + Lisp_Int0))
# define lisp_h_XFASTINT(a) XINT (a)
# define lisp_h_XINT(a) (XLI (a) >> INTTYPEBITS)
# define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK))
......@@ -573,7 +574,73 @@ typedef EMACS_INT Lisp_Object;
#define LISP_INITIALLY_ZERO 0
enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = false };
#endif /* CHECK_LISP_OBJECT_TYPE */
/* Forward declarations. */
/* Defined in this file. */
union Lisp_Fwd;
INLINE bool BOOL_VECTOR_P (Lisp_Object);
INLINE bool BUFFER_OBJFWDP (union Lisp_Fwd *);
INLINE bool BUFFERP (Lisp_Object);
INLINE bool CHAR_TABLE_P (Lisp_Object);
INLINE Lisp_Object CHAR_TABLE_REF_ASCII (Lisp_Object, ptrdiff_t);
INLINE bool (CONSP) (Lisp_Object);
INLINE bool (FLOATP) (Lisp_Object);
INLINE bool functionp (Lisp_Object);
INLINE bool (INTEGERP) (Lisp_Object);
INLINE bool (MARKERP) (Lisp_Object);
INLINE bool (MISCP) (Lisp_Object);
INLINE bool (NILP) (Lisp_Object);
INLINE bool OVERLAYP (Lisp_Object);
INLINE bool PROCESSP (Lisp_Object);
INLINE bool PSEUDOVECTORP (Lisp_Object, int);
INLINE bool SAVE_VALUEP (Lisp_Object);
INLINE void set_sub_char_table_contents (Lisp_Object, ptrdiff_t,
Lisp_Object);
INLINE bool STRINGP (Lisp_Object);
INLINE bool SUB_CHAR_TABLE_P (Lisp_Object);
INLINE bool SUBRP (Lisp_Object);
INLINE bool (SYMBOLP) (Lisp_Object);
INLINE bool (VECTORLIKEP) (Lisp_Object);
INLINE bool WINDOWP (Lisp_Object);
INLINE struct Lisp_Save_Value *XSAVE_VALUE (Lisp_Object);
/* Defined in chartab.c. */
extern Lisp_Object char_table_ref (Lisp_Object, int);
extern void char_table_set (Lisp_Object, int, Lisp_Object);
/* Defined in data.c. */
extern Lisp_Object Qarrayp, Qbufferp, Qbuffer_or_string_p, Qchar_table_p;
extern Lisp_Object Qconsp, Qfloatp, Qintegerp, Qlambda, Qlistp, Qmarkerp, Qnil;
extern Lisp_Object Qnumberp, Qstringp, Qsymbolp, Qt, Qvectorp;
extern Lisp_Object Qbool_vector_p;
extern Lisp_Object Qvector_or_char_table_p, Qwholenump;
extern Lisp_Object Qwindow;
extern _Noreturn Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object);
extern _Noreturn void wrong_choice (Lisp_Object, Lisp_Object);
/* Defined in emacs.c. */
extern bool might_dump;
/* True means Emacs has already been initialized.
Used during startup to detect startup of dumped Emacs. */
extern bool initialized;
/* Defined in eval.c. */
extern Lisp_Object Qautoload;
/* Defined in floatfns.c. */
extern double extract_float (Lisp_Object);
/* Defined in process.c. */
extern Lisp_Object Qprocessp;
/* Defined in window.c. */
extern Lisp_Object Qwindowp;
/* Defined in xdisp.c. */
extern Lisp_Object Qimage;
extern Lisp_Object Qfontification_functions;
/* Convert a Lisp_Object to the corresponding EMACS_INT and vice versa.
At the machine level, these operations are no-ops. */
LISP_MACRO_DEFUN (XLI, EMACS_INT, (Lisp_Object o), (o))
......@@ -673,13 +740,18 @@ LISP_MACRO_DEFUN (XUNTAG, void *, (Lisp_Object a, int type), (a, type))
INLINE Lisp_Object
make_number (EMACS_INT n)
{
EMACS_INT int0 = Lisp_Int0;
if (USE_LSB_TAG)
{
EMACS_UINT u = n;
n = u << INTTYPEBITS;
n += int0;
}
else
n &= INTMASK;
{
n &= INTMASK;
n += (int0 << VALBITS);
}
return XIL (n);
}
......@@ -702,7 +774,8 @@ XINT (Lisp_Object a)
INLINE EMACS_INT
XFASTINT (Lisp_Object a)
{
EMACS_INT n = USE_LSB_TAG ? XINT (a) : XLI (a);
EMACS_INT int0 = Lisp_Int0;
EMACS_INT n = USE_LSB_TAG ? XINT (a) : XLI (a) - (int0 << VALBITS);
eassert (0 <= n);
return n;
}
......@@ -747,7 +820,8 @@ INLINE Lisp_Object
make_natnum (EMACS_INT n)
{
eassert (0 <= n && n <= MOST_POSITIVE_FIXNUM);
return USE_LSB_TAG ? make_number (n) : XIL (n);
EMACS_INT int0 = Lisp_Int0;
return USE_LSB_TAG ? make_number (n) : XIL (n + (int0 << VALBITS));
}
/* Return true if X and Y are the same object. */
......@@ -766,72 +840,6 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
return num < lower ? lower : num <= upper ? num : upper;
}
/* Forward declarations. */
/* Defined in this file. */
union Lisp_Fwd;
INLINE bool BOOL_VECTOR_P (Lisp_Object);
INLINE bool BUFFER_OBJFWDP (union Lisp_Fwd *);
INLINE bool BUFFERP (Lisp_Object);
INLINE bool CHAR_TABLE_P (Lisp_Object);
INLINE Lisp_Object CHAR_TABLE_REF_ASCII (Lisp_Object, ptrdiff_t);
INLINE bool (CONSP) (Lisp_Object);
INLINE bool (FLOATP) (Lisp_Object);
INLINE bool functionp (Lisp_Object);
INLINE bool (INTEGERP) (Lisp_Object);
INLINE bool (MARKERP) (Lisp_Object);
INLINE bool (MISCP) (Lisp_Object);
INLINE bool (NILP) (Lisp_Object);
INLINE bool OVERLAYP (Lisp_Object);
INLINE bool PROCESSP (Lisp_Object);
INLINE bool PSEUDOVECTORP (Lisp_Object, int);
INLINE bool SAVE_VALUEP (Lisp_Object);
INLINE void set_sub_char_table_contents (Lisp_Object, ptrdiff_t,
Lisp_Object);
INLINE bool STRINGP (Lisp_Object);
INLINE bool SUB_CHAR_TABLE_P (Lisp_Object);
INLINE bool SUBRP (Lisp_Object);
INLINE bool (SYMBOLP) (Lisp_Object);
INLINE bool (VECTORLIKEP) (Lisp_Object);
INLINE bool WINDOWP (Lisp_Object);
INLINE struct Lisp_Save_Value *XSAVE_VALUE (Lisp_Object);
/* Defined in chartab.c. */
extern Lisp_Object char_table_ref (Lisp_Object, int);
extern void char_table_set (Lisp_Object, int, Lisp_Object);
/* Defined in data.c. */
extern Lisp_Object Qarrayp, Qbufferp, Qbuffer_or_string_p, Qchar_table_p;
extern Lisp_Object Qconsp, Qfloatp, Qintegerp, Qlambda, Qlistp, Qmarkerp, Qnil;
extern Lisp_Object Qnumberp, Qstringp, Qsymbolp, Qt, Qvectorp;
extern Lisp_Object Qbool_vector_p;
extern Lisp_Object Qvector_or_char_table_p, Qwholenump;
extern Lisp_Object Qwindow;
extern _Noreturn Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object);
extern _Noreturn void wrong_choice (Lisp_Object, Lisp_Object);
/* Defined in emacs.c. */
extern bool might_dump;
/* True means Emacs has already been initialized.
Used during startup to detect startup of dumped Emacs. */
extern bool initialized;
/* Defined in eval.c. */
extern Lisp_Object Qautoload;
/* Defined in floatfns.c. */
extern double extract_float (Lisp_Object);
/* Defined in process.c. */
extern Lisp_Object Qprocessp;
/* Defined in window.c. */
extern Lisp_Object Qwindowp;
/* Defined in xdisp.c. */
extern Lisp_Object Qimage;
extern Lisp_Object Qfontification_functions;
/* Extract a value or address from a Lisp_Object. */
......
......@@ -2971,8 +2971,7 @@ - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename
void
syms_of_nsfns (void)
{
Qfontsize = intern_c_string ("fontsize");
staticpro (&Qfontsize);
DEFSYM (Qfontsize, "fontsize");
DEFVAR_LISP ("ns-icon-type-alist", Vns_icon_type_alist,
doc: /* Alist of elements (REGEXP . IMAGE) for images of icons associated to frames.
......
......@@ -1876,6 +1876,5 @@ - (Lisp_Object)runDialogAt: (NSPoint)p
defsubr (&Sns_reset_menu);
defsubr (&Smenu_or_popup_active_p);
Qdebug_on_next_call = intern_c_string ("debug-on-next-call");
staticpro (&Qdebug_on_next_call);
DEFSYM (Qdebug_on_next_call, "debug-on-next-call");
}
......@@ -504,10 +504,10 @@ Updated by Christian Limpach (chris@nice.ch)
void
syms_of_nsselect (void)
{
QCLIPBOARD = intern_c_string ("CLIPBOARD"); staticpro (&QCLIPBOARD);
QSECONDARY = intern_c_string ("SECONDARY"); staticpro (&QSECONDARY);
QTEXT = intern_c_string ("TEXT"); staticpro (&QTEXT);
QFILE_NAME = intern_c_string ("FILE_NAME"); staticpro (&QFILE_NAME);
DEFSYM (QCLIPBOARD, "CLIPBOARD");
DEFSYM (QSECONDARY, "SECONDARY");
DEFSYM (QTEXT, "TEXT");
DEFSYM (QFILE_NAME, "FILE_NAME");
defsubr (&Sns_disown_selection_internal);
defsubr (&Sns_get_selection);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment