Commit 84575e67 authored by Paul Eggert's avatar Paul Eggert

Use functions, not macros, for XINT etc.

In lisp.h, prefer functions to function-like macros, and
constants to object-like macros, when either will do.  This:
 . simplifies use, as there's no more need to worry about
   arguments' side effects being evaluated multiple times.
 . makes the code easier to debug on some platforms.
However, when using gcc -O0, keep using function-like macros
for a few critical operations, for performance reasons.
This sort of thing isn't needed with gcc -Og, but -Og
is a GCC 4.8 feature and isn't widely-enough available yet.
Also, move functions from lisp.h to individual modules when possible.
From a suggestion by Andreas Schwab in <http://bugs.gnu.org/11935#68>.
* alloc.c (XFLOAT_INIT, set_symbol_name):
* buffer.c (CHECK_OVERLAY):
* chartab.c (CHECK_CHAR_TABLE, set_char_table_ascii)
(set_char_table_parent):
* coding.c (CHECK_NATNUM_CAR, CHECK_NATNUM_CDR):
* data.c (BOOLFWDP, INTFWDP, KBOARD_OBJFWDP, OBJFWDP, XBOOLFWD)
(XKBOARD_OBJFWD, XINTFWD, XOBJFWD, CHECK_SUBR, set_blv_found)
(blv_value, set_blv_value, set_blv_where, set_blv_defcell)
(set_blv_valcell):
* emacs.c (setlocale) [!HAVE_SETLOCALE]:
* eval.c (specpdl_symbol, specpdl_old_value, specpdl_where)
(specpdl_arg, specpdl_func, backtrace_function, backtrace_nargs)
(backtrace_args, backtrace_debug_on_exit):
* floatfns.c (CHECK_FLOAT):
* fns.c (CHECK_HASH_TABLE, CHECK_LIST_END)
(set_hash_key_and_value, set_hash_next, set_hash_next_slot)
(set_hash_hash, set_hash_hash_slot, set_hash_index)
(set_hash_index_slot):
* keymap.c (CHECK_VECTOR_OR_CHAR_TABLE):
* marker.c (CHECK_MARKER):
* textprop.c (CHECK_STRING_OR_BUFFER):
* window.c (CHECK_WINDOW_CONFIGURATION):
Move here from lisp.h, and make these functions static rather than
extern inline.
* buffer.c (Qoverlayp):
* data.c (Qsubrp):
* fns.c (Qhash_table_p):
* window.c (Qwindow_configuration_p):
Now static.
* lisp.h: Remove the abovementioned defns and decls.

* configure.ac (WARN_CFLAGS): Remove -Wbad-function-cast,
as it generates bogus warnings about reasonable casts of calls.
* alloc.c (gdb_make_enums_visible) [USE_LSB_TAG]:
Remove enum lsb_bits; no longer needed.
(allocate_misc, free_misc): Don't use XMISCTYPE as an lvalue.
* buffer.c (Qoverlap):
* data.c (Qsubrp):
* fns.c (Qhash_table_p):
Now extern, so lisp.h can use these symbols.
* dispextern.h: Include character.h, for MAX_CHAR etc.
(GLYPH, GLYPH_CHAR, GLYPH_FACE, SET_GLYPH_CHAR, SET_GLYPH_FACE)
(SET_GLYPH, GLYPH_CODE_CHAR, GLYPH_CODE_FACE)
(SET_GLYPH_FROM_GLYPH_CODE, GLYPH_MODE_LINE_FACE, GLYPH_CHAR_VALID_P)
(GLYPH_CODE_P): Move here from lisp.h.
(GLYPH_CHAR, GLYPH_FACE, GLYPH_CODE_CHAR, GLYPH_CODE_FACE)
(GLYPH_CHAR_VALID_P, GLYPH_CODE_P): Now functions, not macros.
(GLYPH_MODE_LINE_FACE): Now enums, not macros.
* eval.c (Fautoload): Cast XUNTAG output to intptr_t, since
XUNTAG now returns void *.
* lisp.h (lisp_h_XLI, lisp_h_XIL, lisp_h_CHECK_LIST_CONS)
(lisp_h_CHECK_NUMBER CHECK_SYMBOL, lisp_h_CHECK_TYPE)
(lisp_h_CONSP, lisp_h_EQ, lisp_h_FLOATP, lisp_h_INTEGERP)
(lisp_h_MARKERP, lisp_h_MISCP, lisp_h_NILP)
(lisp_h_SET_SYMBOL_VAL, lisp_h_SYMBOL_CONSTANT_P)
(lisp_h_SYMBOL_VAL, lisp_h_SYMBOLP, lisp_h_VECTORLIKEP)
(lisp_h_XCAR, lisp_h_XCDR, lisp_h_XCONS, lisp_h_XHASH)
(lisp_h_XPNTR, lisp_h_XSYMBOL):
New macros, renamed from their sans-lisp_h_ counterparts.
(XLI, XIL, CHECK_LIST_CONS, CHECK_NUMBER CHECK_SYMBOL)
(CHECK_TYPE, CONSP, EQ, FLOATP, INTEGERP, MARKERP)
(MISCP, NILP, SET_SYMBOL_VAL, SYMBOL_CONSTANT_P, SYMBOL_VAL, SYMBOLP)
(VECTORLIKEP, XCAR, XCDR, XCONS, XHASH, XPNTR, XSYMBOL):
If compiling via GCC without optimization, define these as macros
in addition to inline functions.
To disable this, compile with -DINLINING=0.
(LISP_MACRO_DEFUN, LISP_MACRO_DEFUN_VOID): New macros.
(check_cons_list) [!GC_CHECK_CONS_LIST]: Likewise.
(make_number, XFASTINT, XINT, XTYPE, XUNTAG): Likewise, but
hand-optimize only in the USE_LSB_TAG case, as GNUish hosts do that.
(INTMASK, VALMASK): Now macros, since static values cannot be
accessed from extern inline functions.
(VALMASK): Also a constant, for benefit of old GDB.
(LISP_INT_TAG_P): Remove; no longer needed as the only caller
is INTEGERP, which can fold it in.
(XLI, XIL, XHASH, XTYPE,XINT, XFASTINT, XUINT)
(make_number, XPNTR, XUNTAG, EQ, XCONS, XVECTOR, XSTRING, XSYMBOL)
(XFLOAT, XPROCESS, XWINDOW, XTERMINAL, XSUBR, XBUFFER, XCHAR_TABLE)
(XSUB_CHAR_TABLE, XBOOL_VECTOR, make_lisp_ptr, CHECK_TYPE)
(CHECK_STRING_OR_BUFFER, XCAR, XCDR, XSETCAR, XSETCDR, CAR, CDR)
(CAR_SAFE, CDR_SAFE, STRING_MULTIBYTE, SDATA, SSDATA, SREF, SSET)
(SCHARS, STRING_BYTES, SBYTES, STRING_SET_CHARS, STRING_COPYIN, AREF)
(ASIZE, ASET, CHAR_TABLE_REF_ASCII, CHAR_TABLE_REF)
(CHAR_TABLE_SET, CHAR_TABLE_EXTRA_SLOTS, SYMBOL_VAL, SYMBOL_ALIAS)
(SYMBOL_BLV, SYMBOL_FWD, SET_SYMBOL_VAL, SET_SYMBOL_ALIAS)
(SET_SYMBOL_BLV, SET_SYMBOL_FWD, SYMBOL_NAME, SYMBOL_INTERNED_P)
(SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P, SYMBOL_CONSTANT_P)
(XHASH_TABLE, HASH_TABLE_P, CHECK_HASH_TABLE, HASH_KEY, HASH_VALUE)
(HASH_NEXT, HASH_HASH, HASH_INDEX, HASH_TABLE_SIZE)
(XMISC, XMISCANY, XMARKER, XOVERLAY, XSAVE_VALUE, XFWDTYPE)
(XINTFWD, XBOOLFWD, XOBJFWD, XBUFFER_OBJFWD, XKBOARD_OBJFWD)
(XFLOAT_DATA, XFLOAT_INIT, NILP, NUMBERP, NATNUMP)
(RANGED_INTEGERP, CONSP, FLOATP, MISCP, STRINGP, SYMBOLP)
(INTEGERP, VECTORLIKEP, VECTORP, OVERLAYP)
(MARKERP, SAVE_VALUEP, AUTOLOADP, INTFWDP, BOOLFWDP, OBJFWDP)
(BUFFER_OBJFWDP, KBOARD_OBJFWDP, PSEUDOVECTOR_TYPEP)
(PSEUDOVECTORP, WINDOW_CONFIGURATIONP, PROCESSP, WINDOWP)
(TERMINALP, SUBRP, COMPILEDP, BUFFERP, CHAR_TABLE_P)
(SUB_CHAR_TABLE_P, BOOL_VECTOR_P, FRAMEP, IMAGEP, ARRAYP)
(CHECK_LIST, CHECK_LIST_CONS, CHECK_LIST_END, CHECK_STRING)
(CHECK_STRING_CAR, CHECK_CONS, CHECK_SYMBOL, CHECK_CHAR_TABLE)
(CHECK_VECTOR, CHECK_VECTOR_OR_STRING, CHECK_ARRAY)
(CHECK_VECTOR_OR_CHAR_TABLE, CHECK_BUFFER, CHECK_WINDOW)
(CHECK_WINDOW_CONFIGURATION, CHECK_PROCESS, CHECK_SUBR)
(CHECK_NUMBER, CHECK_NATNUM, CHECK_MARKER, XFLOATINT)
(CHECK_FLOAT, CHECK_NUMBER_OR_FLOAT, CHECK_OVERLAY)
(CHECK_NUMBER_CAR, CHECK_NUMBER_CDR, CHECK_NATNUM_CAR)
(CHECK_NATNUM_CDR, FUNCTIONP, SPECPDL_INDEX, LOADHIST_ATTACH)
Now functions.
(check_cons_list) [!GC_CHECK_CONS_LIST]: New empty function.
(LISP_MAKE_RVALUE, TYPEMASK): Remove; no longer needed.
(VALMASK): Define in one place rather than in two, merging the
USE_LSB_TAG parts; this is simpler.
(aref_addr, gc_aset, MOST_POSITIVE_FIXNUM, MOST_NEGATIVE_FIXNUM)
(max, min, struct Lisp_String, UNSIGNED_CMP, ASCII_CHAR_P):
Move up, to avoid use before definition.
Also include "globals.h" earlier, for the same reason.
(make_natnum): New function.
(XUNTAG): Now returns void *, not intptr_t, as this means fewer casts.
(union Lisp_Fwd, BOOLFWDP, BOOL_VECTOR_P, BUFFER_OBJFWDP, BUFFERP)
(CHAR_TABLE_P, CHAR_TABLE_REF_ASCII, CONSP, FLOATP, INTEGERP, INTFWDP)
(KBOARD_OBJFWDP, MARKERP, MISCP, NILP, OBJFWDP, OVERLAYP, PROCESSP)
(PSEUDOVECTORP, SAVE_VALUEP, STRINGP, SUB_CHAR_TABLE_P, SUBRP, SYMBOLP)
(VECTORLIKEP, WINDOWP, Qoverlayp, char_table_ref, char_table_set)
(char_table_translate, Qarrayp, Qbufferp, Qbuffer_or_string_p)
(Qchar_table_p, Qconsp, Qfloatp, Qintegerp, Qlambda, Qlistp, Qmarkerp)
(Qnil, Qnumberp, Qsubrp, Qstringp, Qsymbolp, Qvectorp)
(Qvector_or_char_table_p, Qwholenump, Ffboundp, wrong_type_argument)
(initialized, Qhash_table_p, extract_float, Qprocessp, Qwindowp)
(Qwindow_configuration_p, Qimage): New forward declarations.
(XSETFASTINT): Simplify by rewriting in terms of make_natnum.
(STRING_COPYIN): Remove; unused.
(XCAR_AS_LVALUE, XCDR_AS_LVALUE): Remove these macros, replacing with ...
(xcar_addr, xcdr_addr): New functions.  All uses changed.
(IEEE_FLOATING_POINT): Now a constant, not a macro.
(GLYPH, GLYPH_CHAR, GLYPH_FACE, SET_GLYPH_CHAR, SET_GLYPH_FACE)
(SET_GLYPH, GLYPH_CODE_CHAR, GLYPH_CODE_FACE)
(SET_GLYPH_FROM_GLYPH_CODE, GLYPH_MODE_LINE_FACE, GLYPH_CHAR_VALID_P)
(GLYPH_CODE_P): Move to dispextern.h, to avoid define-before-use.
(TYPE_RANGED_INTEGERP): Simplify.
(Qsubrp, Qhash_table_p, Qoverlayp): New extern decls.
(setlocale, fixup_locale, synchronize_system_messages_locale)
(synchronize_system_time_locale) [!HAVE_SETLOCALE]:
Now empty functions, not macros.
(functionp): Return bool, not int.
* window.c (Qwindow_configuration_p): Now extern,
so window.h can use it.
* window.h (Qwindowp): Move decl back to lisp.h.
parent f612933b
2013-06-17 Paul Eggert <eggert@cs.ucla.edu>
Use functions, not macros, for XINT etc. (Bug#11935).
* configure.ac (WARN_CFLAGS): Remove -Wbad-function-cast,
as it generates bogus warnings about reasonable casts of calls.
2013-06-16 Paul Eggert <eggert@cs.ucla.edu>
* configure.ac: Report ACL usage at the end (Bug#14612).
......
......@@ -776,6 +776,7 @@ else
# signed overflow has undefined behavior
nw="$nw -Wsync-nand" # irrelevant here, and provokes ObjC warning
nw="$nw -Wunsafe-loop-optimizations" # OK to suppress unsafe optimizations
nw="$nw -Wbad-function-cast" # These casts are no worse than others.
# Emacs doesn't care about shadowing; see
# <http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>.
......
2013-06-17 Paul Eggert <eggert@cs.ucla.edu>
Move functions from lisp.h to individual modules when possible.
From a suggestion by Andreas Schwab in <http://bugs.gnu.org/11935#68>.
* alloc.c (XFLOAT_INIT, set_symbol_name):
* buffer.c (CHECK_OVERLAY):
* chartab.c (CHECK_CHAR_TABLE, set_char_table_ascii)
(set_char_table_parent):
* coding.c (CHECK_NATNUM_CAR, CHECK_NATNUM_CDR):
* data.c (BOOLFWDP, INTFWDP, KBOARD_OBJFWDP, OBJFWDP, XBOOLFWD)
(XKBOARD_OBJFWD, XINTFWD, XOBJFWD, CHECK_SUBR, set_blv_found)
(blv_value, set_blv_value, set_blv_where, set_blv_defcell)
(set_blv_valcell):
* emacs.c (setlocale) [!HAVE_SETLOCALE]:
* eval.c (specpdl_symbol, specpdl_old_value, specpdl_where)
(specpdl_arg, specpdl_func, backtrace_function, backtrace_nargs)
(backtrace_args, backtrace_debug_on_exit):
* floatfns.c (CHECK_FLOAT):
* fns.c (CHECK_HASH_TABLE, CHECK_LIST_END)
(set_hash_key_and_value, set_hash_next, set_hash_next_slot)
(set_hash_hash, set_hash_hash_slot, set_hash_index)
(set_hash_index_slot):
* keymap.c (CHECK_VECTOR_OR_CHAR_TABLE):
* marker.c (CHECK_MARKER):
* textprop.c (CHECK_STRING_OR_BUFFER):
* window.c (CHECK_WINDOW_CONFIGURATION):
Move here from lisp.h, and make these functions static rather than
extern inline.
* buffer.c (Qoverlayp):
* data.c (Qsubrp):
* fns.c (Qhash_table_p):
* window.c (Qwindow_configuration_p):
Now static.
* lisp.h: Remove the abovementioned defns and decls.
Use functions, not macros, for XINT etc. (Bug#11935).
In lisp.h, prefer functions to function-like macros, and
constants to object-like macros, when either will do. This:
. simplifies use, as there's no more need to worry about
arguments' side effects being evaluated multiple times.
. makes the code easier to debug on some platforms.
However, when using gcc -O0, keep using function-like macros
for a few critical operations, for performance reasons.
This sort of thing isn't needed with gcc -Og, but -Og
is a GCC 4.8 feature and isn't widely-enough available yet.
* alloc.c (gdb_make_enums_visible) [USE_LSB_TAG]:
Remove enum lsb_bits; no longer needed.
(allocate_misc, free_misc): Don't use XMISCTYPE as an lvalue.
* buffer.c (Qoverlap):
* data.c (Qsubrp):
* fns.c (Qhash_table_p):
Now extern, so lisp.h can use these symbols.
* dispextern.h: Include character.h, for MAX_CHAR etc.
(GLYPH, GLYPH_CHAR, GLYPH_FACE, SET_GLYPH_CHAR, SET_GLYPH_FACE)
(SET_GLYPH, GLYPH_CODE_CHAR, GLYPH_CODE_FACE)
(SET_GLYPH_FROM_GLYPH_CODE, GLYPH_MODE_LINE_FACE, GLYPH_CHAR_VALID_P)
(GLYPH_CODE_P): Move here from lisp.h.
(GLYPH_CHAR, GLYPH_FACE, GLYPH_CODE_CHAR, GLYPH_CODE_FACE)
(GLYPH_CHAR_VALID_P, GLYPH_CODE_P): Now functions, not macros.
(GLYPH_MODE_LINE_FACE): Now enums, not macros.
* eval.c (Fautoload): Cast XUNTAG output to intptr_t, since
XUNTAG now returns void *.
* lisp.h (lisp_h_XLI, lisp_h_XIL, lisp_h_CHECK_LIST_CONS)
(lisp_h_CHECK_NUMBER CHECK_SYMBOL, lisp_h_CHECK_TYPE)
(lisp_h_CONSP, lisp_h_EQ, lisp_h_FLOATP, lisp_h_INTEGERP)
(lisp_h_MARKERP, lisp_h_MISCP, lisp_h_NILP)
(lisp_h_SET_SYMBOL_VAL, lisp_h_SYMBOL_CONSTANT_P)
(lisp_h_SYMBOL_VAL, lisp_h_SYMBOLP, lisp_h_VECTORLIKEP)
(lisp_h_XCAR, lisp_h_XCDR, lisp_h_XCONS, lisp_h_XHASH)
(lisp_h_XPNTR, lisp_h_XSYMBOL):
New macros, renamed from their sans-lisp_h_ counterparts.
(XLI, XIL, CHECK_LIST_CONS, CHECK_NUMBER CHECK_SYMBOL)
(CHECK_TYPE, CONSP, EQ, FLOATP, INTEGERP, MARKERP)
(MISCP, NILP, SET_SYMBOL_VAL, SYMBOL_CONSTANT_P, SYMBOL_VAL, SYMBOLP)
(VECTORLIKEP, XCAR, XCDR, XCONS, XHASH, XPNTR, XSYMBOL):
If compiling via GCC without optimization, define these as macros
in addition to inline functions.
To disable this, compile with -DINLINING=0.
(LISP_MACRO_DEFUN, LISP_MACRO_DEFUN_VOID): New macros.
(check_cons_list) [!GC_CHECK_CONS_LIST]: Likewise.
(make_number, XFASTINT, XINT, XTYPE, XUNTAG): Likewise, but
hand-optimize only in the USE_LSB_TAG case, as GNUish hosts do that.
(INTMASK, VALMASK): Now macros, since static values cannot be
accessed from extern inline functions.
(VALMASK): Also a constant, for benefit of old GDB.
(LISP_INT_TAG_P): Remove; no longer needed as the only caller
is INTEGERP, which can fold it in.
(XLI, XIL, XHASH, XTYPE,XINT, XFASTINT, XUINT)
(make_number, XPNTR, XUNTAG, EQ, XCONS, XVECTOR, XSTRING, XSYMBOL)
(XFLOAT, XPROCESS, XWINDOW, XTERMINAL, XSUBR, XBUFFER, XCHAR_TABLE)
(XSUB_CHAR_TABLE, XBOOL_VECTOR, make_lisp_ptr, CHECK_TYPE)
(CHECK_STRING_OR_BUFFER, XCAR, XCDR, XSETCAR, XSETCDR, CAR, CDR)
(CAR_SAFE, CDR_SAFE, STRING_MULTIBYTE, SDATA, SSDATA, SREF, SSET)
(SCHARS, STRING_BYTES, SBYTES, STRING_SET_CHARS, STRING_COPYIN, AREF)
(ASIZE, ASET, CHAR_TABLE_REF_ASCII, CHAR_TABLE_REF)
(CHAR_TABLE_SET, CHAR_TABLE_EXTRA_SLOTS, SYMBOL_VAL, SYMBOL_ALIAS)
(SYMBOL_BLV, SYMBOL_FWD, SET_SYMBOL_VAL, SET_SYMBOL_ALIAS)
(SET_SYMBOL_BLV, SET_SYMBOL_FWD, SYMBOL_NAME, SYMBOL_INTERNED_P)
(SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P, SYMBOL_CONSTANT_P)
(XHASH_TABLE, HASH_TABLE_P, CHECK_HASH_TABLE, HASH_KEY, HASH_VALUE)
(HASH_NEXT, HASH_HASH, HASH_INDEX, HASH_TABLE_SIZE)
(XMISC, XMISCANY, XMARKER, XOVERLAY, XSAVE_VALUE, XFWDTYPE)
(XINTFWD, XBOOLFWD, XOBJFWD, XBUFFER_OBJFWD, XKBOARD_OBJFWD)
(XFLOAT_DATA, XFLOAT_INIT, NILP, NUMBERP, NATNUMP)
(RANGED_INTEGERP, CONSP, FLOATP, MISCP, STRINGP, SYMBOLP)
(INTEGERP, VECTORLIKEP, VECTORP, OVERLAYP)
(MARKERP, SAVE_VALUEP, AUTOLOADP, INTFWDP, BOOLFWDP, OBJFWDP)
(BUFFER_OBJFWDP, KBOARD_OBJFWDP, PSEUDOVECTOR_TYPEP)
(PSEUDOVECTORP, WINDOW_CONFIGURATIONP, PROCESSP, WINDOWP)
(TERMINALP, SUBRP, COMPILEDP, BUFFERP, CHAR_TABLE_P)
(SUB_CHAR_TABLE_P, BOOL_VECTOR_P, FRAMEP, IMAGEP, ARRAYP)
(CHECK_LIST, CHECK_LIST_CONS, CHECK_LIST_END, CHECK_STRING)
(CHECK_STRING_CAR, CHECK_CONS, CHECK_SYMBOL, CHECK_CHAR_TABLE)
(CHECK_VECTOR, CHECK_VECTOR_OR_STRING, CHECK_ARRAY)
(CHECK_VECTOR_OR_CHAR_TABLE, CHECK_BUFFER, CHECK_WINDOW)
(CHECK_WINDOW_CONFIGURATION, CHECK_PROCESS, CHECK_SUBR)
(CHECK_NUMBER, CHECK_NATNUM, CHECK_MARKER, XFLOATINT)
(CHECK_FLOAT, CHECK_NUMBER_OR_FLOAT, CHECK_OVERLAY)
(CHECK_NUMBER_CAR, CHECK_NUMBER_CDR, CHECK_NATNUM_CAR)
(CHECK_NATNUM_CDR, FUNCTIONP, SPECPDL_INDEX, LOADHIST_ATTACH)
Now functions.
(check_cons_list) [!GC_CHECK_CONS_LIST]: New empty function.
(LISP_MAKE_RVALUE, TYPEMASK): Remove; no longer needed.
(VALMASK): Define in one place rather than in two, merging the
USE_LSB_TAG parts; this is simpler.
(aref_addr, gc_aset, MOST_POSITIVE_FIXNUM, MOST_NEGATIVE_FIXNUM)
(max, min, struct Lisp_String, UNSIGNED_CMP, ASCII_CHAR_P):
Move up, to avoid use before definition.
Also include "globals.h" earlier, for the same reason.
(make_natnum): New function.
(XUNTAG): Now returns void *, not intptr_t, as this means fewer casts.
(union Lisp_Fwd, BOOLFWDP, BOOL_VECTOR_P, BUFFER_OBJFWDP, BUFFERP)
(CHAR_TABLE_P, CHAR_TABLE_REF_ASCII, CONSP, FLOATP, INTEGERP, INTFWDP)
(KBOARD_OBJFWDP, MARKERP, MISCP, NILP, OBJFWDP, OVERLAYP, PROCESSP)
(PSEUDOVECTORP, SAVE_VALUEP, STRINGP, SUB_CHAR_TABLE_P, SUBRP, SYMBOLP)
(VECTORLIKEP, WINDOWP, Qoverlayp, char_table_ref, char_table_set)
(char_table_translate, Qarrayp, Qbufferp, Qbuffer_or_string_p)
(Qchar_table_p, Qconsp, Qfloatp, Qintegerp, Qlambda, Qlistp, Qmarkerp)
(Qnil, Qnumberp, Qsubrp, Qstringp, Qsymbolp, Qvectorp)
(Qvector_or_char_table_p, Qwholenump, Ffboundp, wrong_type_argument)
(initialized, Qhash_table_p, extract_float, Qprocessp, Qwindowp)
(Qwindow_configuration_p, Qimage): New forward declarations.
(XSETFASTINT): Simplify by rewriting in terms of make_natnum.
(STRING_COPYIN): Remove; unused.
(XCAR_AS_LVALUE, XCDR_AS_LVALUE): Remove these macros, replacing with ...
(xcar_addr, xcdr_addr): New functions. All uses changed.
(IEEE_FLOATING_POINT): Now a constant, not a macro.
(GLYPH, GLYPH_CHAR, GLYPH_FACE, SET_GLYPH_CHAR, SET_GLYPH_FACE)
(SET_GLYPH, GLYPH_CODE_CHAR, GLYPH_CODE_FACE)
(SET_GLYPH_FROM_GLYPH_CODE, GLYPH_MODE_LINE_FACE, GLYPH_CHAR_VALID_P)
(GLYPH_CODE_P): Move to dispextern.h, to avoid define-before-use.
(TYPE_RANGED_INTEGERP): Simplify.
(Qsubrp, Qhash_table_p, Qoverlayp): New extern decls.
(setlocale, fixup_locale, synchronize_system_messages_locale)
(synchronize_system_time_locale) [!HAVE_SETLOCALE]:
Now empty functions, not macros.
(functionp): Return bool, not int.
* window.c (Qwindow_configuration_p): Now extern,
so window.h can use it.
* window.h (Qwindowp): Move decl back to lisp.h.
2013-06-15 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (Fline_pixel_height): New function, required for solving
......
......@@ -363,6 +363,11 @@ static void *pure_alloc (size_t, int);
((void *) (((uintptr_t) (ptr) + (ALIGNMENT) - 1) \
& ~ ((ALIGNMENT) - 1)))
static void
XFLOAT_INIT (Lisp_Object f, double n)
{
XFLOAT (f)->u.data = n;
}
/************************************************************************
......@@ -3189,6 +3194,12 @@ static int symbol_block_index = SYMBOL_BLOCK_SIZE;
static struct Lisp_Symbol *symbol_free_list;
static void
set_symbol_name (Lisp_Object sym, Lisp_Object name)
{
XSYMBOL (sym)->name = name;
}
DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0,
doc: /* Return a newly allocated uninterned symbol whose name is NAME.
Its value is void, and its function definition and property list are nil. */)
......@@ -3309,7 +3320,7 @@ allocate_misc (enum Lisp_Misc_Type type)
--total_free_markers;
consing_since_gc += sizeof (union Lisp_Misc);
misc_objects_consed++;
XMISCTYPE (val) = type;
XMISCANY (val)->type = type;
XMISCANY (val)->gcmarkbit = 0;
return val;
}
......@@ -3319,7 +3330,7 @@ allocate_misc (enum Lisp_Misc_Type type)
void
free_misc (Lisp_Object misc)
{
XMISCTYPE (misc) = Lisp_Misc_Free;
XMISCANY (misc)->type = Lisp_Misc_Free;
XMISC (misc)->u_free.chain = marker_free_list;
marker_free_list = XMISC (misc);
consing_since_gc -= sizeof (union Lisp_Misc);
......@@ -5647,7 +5658,7 @@ mark_discard_killed_buffers (Lisp_Object list)
{
CONS_MARK (XCONS (tail));
mark_object (XCAR (tail));
prev = &XCDR_AS_LVALUE (tail);
prev = xcdr_addr (tail);
}
}
mark_object (tail);
......@@ -6689,8 +6700,5 @@ union
enum MAX_ALLOCA MAX_ALLOCA;
enum More_Lisp_Bits More_Lisp_Bits;
enum pvec_type pvec_type;
#if USE_LSB_TAG
enum lsb_bits lsb_bits;
#endif
} const EXTERNALLY_VISIBLE gdb_make_enums_visible = {0};
#endif /* __GNUC__ */
......@@ -150,6 +150,12 @@ static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay
static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t);
static Lisp_Object buffer_lisp_local_variables (struct buffer *, bool);
static void
CHECK_OVERLAY (Lisp_Object x)
{
CHECK_TYPE (OVERLAYP (x), Qoverlayp, x);
}
/* These setters are used only in this file, so they can be private. */
static void
bset_abbrev_mode (struct buffer *b, Lisp_Object val)
......@@ -1539,7 +1545,7 @@ candidate_buffer (Lisp_Object b, Lisp_Object buffer)
&& BUFFER_LIVE_P (XBUFFER (b))
&& !BUFFER_HIDDEN_P (XBUFFER (b)));
}
DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 3, 0,
doc: /* Return most recently selected buffer other than BUFFER.
Buffers not visible in windows are preferred to visible buffers, unless
......
......@@ -84,6 +84,22 @@ static uniprop_decoder_t uniprop_get_decoder (Lisp_Object);
(STRINGP (OBJ) && SCHARS (OBJ) > 0 \
&& ((SREF (OBJ, 0) == 1 || (SREF (OBJ, 0) == 2))))
static void
CHECK_CHAR_TABLE (Lisp_Object x)
{
CHECK_TYPE (CHAR_TABLE_P (x), Qchar_table_p, x);
}
static void
set_char_table_ascii (Lisp_Object table, Lisp_Object val)
{
XCHAR_TABLE (table)->ascii = val;
}
static void
set_char_table_parent (Lisp_Object table, Lisp_Object val)
{
XCHAR_TABLE (table)->parent = val;
}
DEFUN ("make-char-table", Fmake_char_table, Smake_char_table, 1, 2, 0,
doc: /* Return a newly created char-table, with purpose PURPOSE.
......
......@@ -655,6 +655,22 @@ static struct coding_system coding_categories[coding_category_max];
(charset_list) = CODING_ATTR_CHARSET_LIST (attrs); \
} while (0)
static void
CHECK_NATNUM_CAR (Lisp_Object x)
{
Lisp_Object tmp = XCAR (x);
CHECK_NATNUM (tmp);
XSETCAR (x, tmp);
}
static void
CHECK_NATNUM_CDR (Lisp_Object x)
{
Lisp_Object tmp = XCDR (x);
CHECK_NATNUM (tmp);
XSETCDR (x, tmp);
}
/* Safely get one byte from the source text pointed by SRC which ends
at SRC_END, and set C to that byte. If there are not enough bytes
......
......@@ -76,7 +76,8 @@ static Lisp_Object Qprocess, Qmarker;
static Lisp_Object Qcompiled_function, Qframe;
Lisp_Object Qbuffer;
static Lisp_Object Qchar_table, Qbool_vector, Qhash_table;
static Lisp_Object Qsubrp, Qmany, Qunevalled;
static Lisp_Object Qsubrp;
static Lisp_Object Qmany, Qunevalled;
Lisp_Object Qfont_spec, Qfont_entity, Qfont_object;
static Lisp_Object Qdefun;
......@@ -85,6 +86,94 @@ static Lisp_Object Qdefalias_fset_function;
static void swap_in_symval_forwarding (struct Lisp_Symbol *, struct Lisp_Buffer_Local_Value *);
static bool
BOOLFWDP (union Lisp_Fwd *a)
{
return XFWDTYPE (a) == Lisp_Fwd_Bool;
}
static bool
INTFWDP (union Lisp_Fwd *a)
{
return XFWDTYPE (a) == Lisp_Fwd_Int;
}
static bool
KBOARD_OBJFWDP (union Lisp_Fwd *a)
{
return XFWDTYPE (a) == Lisp_Fwd_Kboard_Obj;
}
static bool
OBJFWDP (union Lisp_Fwd *a)
{
return XFWDTYPE (a) == Lisp_Fwd_Obj;
}
static struct Lisp_Boolfwd *
XBOOLFWD (union Lisp_Fwd *a)
{
eassert (BOOLFWDP (a));
return &a->u_boolfwd;
}
static struct Lisp_Kboard_Objfwd *
XKBOARD_OBJFWD (union Lisp_Fwd *a)
{
eassert (KBOARD_OBJFWDP (a));
return &a->u_kboard_objfwd;
}
static struct Lisp_Intfwd *
XINTFWD (union Lisp_Fwd *a)
{
eassert (INTFWDP (a));
return &a->u_intfwd;
}
static struct Lisp_Objfwd *
XOBJFWD (union Lisp_Fwd *a)
{
eassert (OBJFWDP (a));
return &a->u_objfwd;
}
static void
CHECK_SUBR (Lisp_Object x)
{
CHECK_TYPE (SUBRP (x), Qsubrp, x);
}
static void
set_blv_found (struct Lisp_Buffer_Local_Value *blv, int found)
{
eassert (found == !EQ (blv->defcell, blv->valcell));
blv->found = found;
}
static Lisp_Object
blv_value (struct Lisp_Buffer_Local_Value *blv)
{
return XCDR (blv->valcell);
}
static void
set_blv_value (struct Lisp_Buffer_Local_Value *blv, Lisp_Object val)
{
XSETCDR (blv->valcell, val);
}
static void
set_blv_where (struct Lisp_Buffer_Local_Value *blv, Lisp_Object val)
{
blv->where = val;
}
static void
set_blv_defcell (struct Lisp_Buffer_Local_Value *blv, Lisp_Object val)
{
blv->defcell = val;
}
static void
set_blv_valcell (struct Lisp_Buffer_Local_Value *blv, Lisp_Object val)
{
blv->valcell = val;
}
Lisp_Object
wrong_type_argument (register Lisp_Object predicate, register Lisp_Object value)
......
......@@ -22,6 +22,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifndef DISPEXTERN_H_INCLUDED
#define DISPEXTERN_H_INCLUDED
#include "character.h"
#ifdef HAVE_X_WINDOWS
#include <X11/Xlib.h>
......@@ -270,6 +272,55 @@ struct display_pos
Glyphs
***********************************************************************/
/* The glyph datatype, used to represent characters on the display.
It consists of a char code and a face id. */
typedef struct {
int ch;
int face_id;
} GLYPH;
/* Return a glyph's character code. */
DISPEXTERN_INLINE int GLYPH_CHAR (GLYPH glyph) { return glyph.ch; }
/* Return a glyph's face ID. */
DISPEXTERN_INLINE int GLYPH_FACE (GLYPH glyph) { return glyph.face_id; }
#define SET_GLYPH_CHAR(glyph, char) ((glyph).ch = (char))
#define SET_GLYPH_FACE(glyph, face) ((glyph).face_id = (face))
#define SET_GLYPH(glyph, char, face) \
((glyph).ch = (char), (glyph).face_id = (face))
/* The following are valid only if GLYPH_CODE_P (gc). */
DISPEXTERN_INLINE int
GLYPH_CODE_CHAR (Lisp_Object gc)
{
return (CONSP (gc)
? XINT (XCAR (gc))
: XINT (gc) & MAX_CHAR);
}
DISPEXTERN_INLINE int
GLYPH_CODE_FACE (Lisp_Object gc)
{
return CONSP (gc) ? XINT (XCDR (gc)) : XINT (gc) >> CHARACTERBITS;
}
#define SET_GLYPH_FROM_GLYPH_CODE(glyph, gc) \
do \
{ \
if (CONSP (gc)) \
SET_GLYPH (glyph, XINT (XCAR (gc)), XINT (XCDR (gc))); \
else \
SET_GLYPH (glyph, (XINT (gc) & ((1 << CHARACTERBITS)-1)), \
(XINT (gc) >> CHARACTERBITS)); \
} \
while (0)
/* The ID of the mode line highlighting face. */
enum { GLYPH_MODE_LINE_FACE = 1 };
/* Enumeration of glyph types. Glyph structures contain a type field
containing one of the enumerators defined here. */
......@@ -1774,6 +1825,30 @@ struct face_cache
#endif /* not HAVE_WINDOW_SYSTEM */
/* Return true if G contains a valid character code. */
DISPEXTERN_INLINE bool
GLYPH_CHAR_VALID_P (GLYPH g)
{
return CHAR_VALID_P (GLYPH_CHAR (g));
}
/* The glyph code from a display vector may either be an integer which
encodes a char code in the lower CHARACTERBITS bits and a (very small)
face-id in the upper bits, or it may be a cons (CHAR . FACE-ID). */
DISPEXTERN_INLINE bool
GLYPH_CODE_P (Lisp_Object gc)
{
return (CONSP (gc)
? (CHARACTERP (XCAR (gc))
&& RANGED_INTEGERP (0, XCDR (gc), MAX_FACE_ID))
: (RANGED_INTEGERP
(0, gc,
(MAX_FACE_ID < TYPE_MAXIMUM (EMACS_INT) >> CHARACTERBITS
? ((EMACS_INT) MAX_FACE_ID << CHARACTERBITS) | MAX_CHAR
: TYPE_MAXIMUM (EMACS_INT)))));
}
/* Non-zero means face attributes have been changed since the last
redisplay. Used in redisplay_internal. */
......
......@@ -306,6 +306,13 @@ bool fatal_error_in_progress;
static void *ns_pool;
#endif
#if !HAVE_SETLOCALE
static char *
setlocale (int cat, char const *locale)
{
return 0;
}
#endif
/* Report a fatal error due to signal SIG, output a backtrace of at
......
......@@ -115,6 +115,69 @@ Lisp_Object inhibit_lisp_code;
static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *);
static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args);
static Lisp_Object
specpdl_symbol (struct specbinding *pdl)
{
eassert (pdl->kind >= SPECPDL_LET);
return pdl->v.let.symbol;
}
static Lisp_Object
specpdl_old_value (struct specbinding *pdl)
{
eassert (pdl->kind >= SPECPDL_LET);
return pdl->v.let.old_value;
}
static Lisp_Object
specpdl_where (struct specbinding *pdl)
{
eassert (pdl->kind > SPECPDL_LET);
return pdl->v.let.where;
}
static Lisp_Object
specpdl_arg (struct specbinding *pdl)
{
eassert (pdl->kind == SPECPDL_UNWIND);
return pdl->v.unwind.arg;
}
static specbinding_func
specpdl_func (struct specbinding *pdl)
{
eassert (pdl->kind == SPECPDL_UNWIND);
return pdl->v.unwind.func;
}
static Lisp_Object
backtrace_function (struct specbinding *pdl)
{
eassert (pdl->kind == SPECPDL_BACKTRACE);
return pdl->v.bt.function;
}
static ptrdiff_t
backtrace_nargs (struct specbinding *pdl)
{
eassert (pdl->kind == SPECPDL_BACKTRACE);
return pdl->v.bt.nargs;
}
static Lisp_Object *
backtrace_args (struct specbinding *pdl)
{
eassert (pdl->kind == SPECPDL_BACKTRACE);
return pdl->v.bt.args;
}
static bool
backtrace_debug_on_exit (struct specbinding *pdl)
{
eassert (pdl->kind == SPECPDL_BACKTRACE);
return pdl->v.bt.debug_on_exit;
}
/* Functions to modify slots of backtrace records. */
static void
......
......@@ -41,6 +41,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
# define isnan(x) ((x) != (x))
#endif
/* Check that X is a floating point number. */
static void
CHECK_FLOAT (Lisp_Object x)
{
CHECK_TYPE (FLOATP (x), Qfloatp, x);
}
/* Extract a Lisp number as a `double', or signal an error. */
double
......
......@@ -91,6 +91,12 @@ enum { QUIT_COUNT_HEURISTIC = 1 << 16 };
/* Random data-structure functions. */
static void
CHECK_LIST_END (Lisp_Object x, Lisp_Object y)
{
CHECK_TYPE (NILP (x), Qlistp, y);
}
DEFUN ("length", Flength, Slength, 1, 1, 0,
doc: /* Return the length of vector, list or string SEQUENCE.
A byte-code function object is also allowed.
......@@ -3337,7 +3343,8 @@ static struct Lisp_Hash_Table *weak_hash_tables;
/* Various symbols. */
static Lisp_Object Qhash_table_p, Qkey, Qvalue, Qeql;
static Lisp_Object Qhash_table_p;
static Lisp_Object Qkey, Qvalue, Qeql;
Lisp_Object Qeq, Qequal;
Lisp_Object QCtest, QCsize, QCrehash_size, QCrehash_threshold, QCweakness;
static Lisp_Object Qhash_table_test, Qkey_or_value, Qkey_and_value;
......@@ -3347,6 +3354,48 @@ static Lisp_Object Qhash_table_test, Qkey_or_value, Qkey_and_value;
Utilities
***********************************************************************/
static void
CHECK_HASH_TABLE (Lisp_Object x)
{
CHECK_TYPE (HASH_TABLE_P (x), Qhash_table_p, x);
}
static void
set_hash_key_and_value (struct Lisp_Hash_Table *h, Lisp_Object key_and_value)
{
h->key_and_value = key_and_value;
}
static void
set_hash_next (struct Lisp_Hash_Table *h, Lisp_Object next)
{
h->next = next;
}
static void
set_hash_next_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
{
gc_aset (h->next, idx, val);
}
static void
set_hash_hash (struct Lisp_Hash_Table *h, Lisp_Object hash)