aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2015-10-24 23:51:19 -0700
committerPaul Eggert2015-10-24 23:52:01 -0700
commitd8589ad4e3cf2ed6759836f28081d96748360915 (patch)
tree4a2e184554eb414d8dd2efc9fe70f47eea99d90c /src
parent816f78c2e8ec67a1e8c91ad2e9b0b8628e5584bf (diff)
downloademacs-d8589ad4e3cf2ed6759836f28081d96748360915.tar.gz
emacs-d8589ad4e3cf2ed6759836f28081d96748360915.zip
Port recent inline functions fix to Standard C
* src/lisp.h (LISP_MACRO_DEFUN, LISP_MACRO_DEFUN_VOID): Remove. All uses rewritten to define the function directly rather than to use a macro to define the function. This conforms to Standard C, which does not allow stray semicolons at the top level. I hope it also avoids the problems with TAGS. Those macros, though clever, were pretty confusing anyway, and it wasn’t clear they were worth the aggravation even without the TAGS problem.
Diffstat (limited to 'src')
-rw-r--r--src/lisp.h211
1 files changed, 155 insertions, 56 deletions
diff --git a/src/lisp.h b/src/lisp.h
index e2b7b67103d..a1409d1af8c 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -258,7 +258,7 @@ enum Lisp_Bits
258 258
259/* The maximum value that can be stored in a EMACS_INT, assuming all 259/* The maximum value that can be stored in a EMACS_INT, assuming all
260 bits other than the type bits contribute to a nonnegative signed value. 260 bits other than the type bits contribute to a nonnegative signed value.
261 This can be used in #if, e.g., '#if USB_TAG' below expands to an 261 This can be used in #if, e.g., '#if USE_LSB_TAG' below expands to an
262 expression involving VAL_MAX. */ 262 expression involving VAL_MAX. */
263#define VAL_MAX (EMACS_INT_MAX >> (GCTYPEBITS - 1)) 263#define VAL_MAX (EMACS_INT_MAX >> (GCTYPEBITS - 1))
264 264
@@ -301,10 +301,6 @@ error !;
301 301
302 and/or via a function definition like this: 302 and/or via a function definition like this:
303 303
304 LISP_MACRO_DEFUN (OP, Lisp_Object, (Lisp_Object x), (x))
305
306 which macro-expands to this:
307
308 Lisp_Object (OP) (Lisp_Object x) { return lisp_h_OP (x); } 304 Lisp_Object (OP) (Lisp_Object x) { return lisp_h_OP (x); }
309 305
310 without worrying about the implementations diverging, since 306 without worrying about the implementations diverging, since
@@ -318,15 +314,7 @@ error !;
318 Bug#11935. 314 Bug#11935.
319 315
320 Commentary for these macros can be found near their corresponding 316 Commentary for these macros can be found near their corresponding
321 functions, below. 317 functions, below. */
322
323 Note: Each use of LISP_MACRO_DEFUN should have a semi-colon ; at
324 its end, although the expansion of that macro doesn't require that.
325 That's because any inline function defined immediately after the
326 use of that macro will otherwise be missed by 'etags' (because
327 'etags' works on un-preprocessed source, and treats the invocation
328 of LISP_MACRO_DEFUN as some kind of data type), and will not end up
329 in TAGS. */
330 318
331#if CHECK_LISP_OBJECT_TYPE 319#if CHECK_LISP_OBJECT_TYPE
332# define lisp_h_XLI(o) ((o).i) 320# define lisp_h_XLI(o) ((o).i)
@@ -416,17 +404,6 @@ error !;
416# endif 404# endif
417#endif 405#endif
418 406
419/* Define NAME as a lisp.h inline function that returns TYPE and has
420 arguments declared as ARGDECLS and passed as ARGS. ARGDECLS and
421 ARGS should be parenthesized. Implement the function by calling
422 lisp_h_NAME ARGS. */
423#define LISP_MACRO_DEFUN(name, type, argdecls, args) \
424 INLINE type (name) argdecls { return lisp_h_##name args; }
425
426/* like LISP_MACRO_DEFUN, except NAME returns void. */
427#define LISP_MACRO_DEFUN_VOID(name, argdecls, args) \
428 INLINE void (name) argdecls { lisp_h_##name args; }
429
430 407
431/* Define the fundamental Lisp data structures. */ 408/* Define the fundamental Lisp data structures. */
432 409
@@ -759,8 +736,18 @@ struct Lisp_Symbol
759 736
760/* Convert a Lisp_Object to the corresponding EMACS_INT and vice versa. 737/* Convert a Lisp_Object to the corresponding EMACS_INT and vice versa.
761 At the machine level, these operations are no-ops. */ 738 At the machine level, these operations are no-ops. */
762LISP_MACRO_DEFUN (XLI, EMACS_INT, (Lisp_Object o), (o)); 739
763LISP_MACRO_DEFUN (XIL, Lisp_Object, (EMACS_INT i), (i)); 740INLINE EMACS_INT
741(XLI) (Lisp_Object o)
742{
743 return lisp_h_XLI (o);
744}
745
746INLINE Lisp_Object
747(XIL) (EMACS_INT i)
748{
749 return lisp_h_XIL (i);
750}
764 751
765/* In the size word of a vector, this bit means the vector has been marked. */ 752/* In the size word of a vector, this bit means the vector has been marked. */
766 753
@@ -836,12 +823,41 @@ DEFINE_GDB_SYMBOL_END (VALMASK)
836 823
837#if USE_LSB_TAG 824#if USE_LSB_TAG
838 825
839LISP_MACRO_DEFUN (make_number, Lisp_Object, (EMACS_INT n), (n)); 826INLINE Lisp_Object
840LISP_MACRO_DEFUN (XINT, EMACS_INT, (Lisp_Object a), (a)); 827(make_number) (EMACS_INT n)
841LISP_MACRO_DEFUN (XFASTINT, EMACS_INT, (Lisp_Object a), (a)); 828{
842LISP_MACRO_DEFUN (XSYMBOL, struct Lisp_Symbol *, (Lisp_Object a), (a)); 829 return lisp_h_make_number (n);
843LISP_MACRO_DEFUN (XTYPE, enum Lisp_Type, (Lisp_Object a), (a)); 830}
844LISP_MACRO_DEFUN (XUNTAG, void *, (Lisp_Object a, int type), (a, type)); 831
832INLINE EMACS_INT
833(XINT) (Lisp_Object a)
834{
835 return lisp_h_XINT (a);
836}
837
838INLINE EMACS_INT
839(XFASTINT) (Lisp_Object a)
840{
841 return lisp_h_XFASTINT (a);
842}
843
844INLINE struct Lisp_Symbol *
845(XSYMBOL) (Lisp_Object a)
846{
847 return lisp_h_XSYMBOL (a);
848}
849
850INLINE enum Lisp_Type
851(XTYPE) (Lisp_Object a)
852{
853 return lisp_h_XTYPE (a);
854}
855
856INLINE void *
857(XUNTAG) (Lisp_Object a, int type)
858{
859 return lisp_h_XUNTAG (a, type);
860}
845 861
846#else /* ! USE_LSB_TAG */ 862#else /* ! USE_LSB_TAG */
847 863
@@ -932,7 +948,12 @@ XUINT (Lisp_Object a)
932/* Return A's (Lisp-integer sized) hash. Happens to be like XUINT 948/* Return A's (Lisp-integer sized) hash. Happens to be like XUINT
933 right now, but XUINT should only be applied to objects we know are 949 right now, but XUINT should only be applied to objects we know are
934 integers. */ 950 integers. */
935LISP_MACRO_DEFUN (XHASH, EMACS_INT, (Lisp_Object a), (a)); 951
952INLINE EMACS_INT
953(XHASH) (Lisp_Object a)
954{
955 return lisp_h_XHASH (a);
956}
936 957
937/* Like make_number (N), but may be faster. N must be in nonnegative range. */ 958/* Like make_number (N), but may be faster. N must be in nonnegative range. */
938INLINE Lisp_Object 959INLINE Lisp_Object
@@ -944,7 +965,12 @@ make_natnum (EMACS_INT n)
944} 965}
945 966
946/* Return true if X and Y are the same object. */ 967/* Return true if X and Y are the same object. */
947LISP_MACRO_DEFUN (EQ, bool, (Lisp_Object x, Lisp_Object y), (x, y)); 968
969INLINE bool
970(EQ) (Lisp_Object x, Lisp_Object y)
971{
972 return lisp_h_EQ (x, y);
973}
948 974
949/* Value is true if I doesn't fit into a Lisp fixnum. It is 975/* Value is true if I doesn't fit into a Lisp fixnum. It is
950 written this way so that it also works if I is of unsigned 976 written this way so that it also works if I is of unsigned
@@ -962,7 +988,11 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
962 988
963/* Extract a value or address from a Lisp_Object. */ 989/* Extract a value or address from a Lisp_Object. */
964 990
965LISP_MACRO_DEFUN (XCONS, struct Lisp_Cons *, (Lisp_Object a), (a)); 991INLINE struct Lisp_Cons *
992(XCONS) (Lisp_Object a)
993{
994 return lisp_h_XCONS (a);
995}
966 996
967INLINE struct Lisp_Vector * 997INLINE struct Lisp_Vector *
968XVECTOR (Lisp_Object a) 998XVECTOR (Lisp_Object a)
@@ -1135,9 +1165,11 @@ make_pointer_integer (void *p)
1135 1165
1136/* Type checking. */ 1166/* Type checking. */
1137 1167
1138LISP_MACRO_DEFUN_VOID (CHECK_TYPE, 1168INLINE void
1139 (int ok, Lisp_Object predicate, Lisp_Object x), 1169(CHECK_TYPE) (int ok, Lisp_Object predicate, Lisp_Object x)
1140 (ok, predicate, x)); 1170{
1171 lisp_h_CHECK_TYPE (ok, predicate, x);
1172}
1141 1173
1142/* See the macros in intervals.h. */ 1174/* See the macros in intervals.h. */
1143 1175
@@ -1177,8 +1209,18 @@ xcdr_addr (Lisp_Object c)
1177} 1209}
1178 1210
1179/* Use these from normal code. */ 1211/* Use these from normal code. */
1180LISP_MACRO_DEFUN (XCAR, Lisp_Object, (Lisp_Object c), (c)); 1212
1181LISP_MACRO_DEFUN (XCDR, Lisp_Object, (Lisp_Object c), (c)); 1213INLINE Lisp_Object
1214(XCAR) (Lisp_Object c)
1215{
1216 return lisp_h_XCAR (c);
1217}
1218
1219INLINE Lisp_Object
1220(XCDR) (Lisp_Object c)
1221{
1222 return lisp_h_XCDR (c);
1223}
1182 1224
1183/* Use these to set the fields of a cons cell. 1225/* Use these to set the fields of a cons cell.
1184 1226
@@ -1715,7 +1757,11 @@ verify (offsetof (struct Lisp_Sub_Char_Table, contents)
1715 1757
1716/* Value is name of symbol. */ 1758/* Value is name of symbol. */
1717 1759
1718LISP_MACRO_DEFUN (SYMBOL_VAL, Lisp_Object, (struct Lisp_Symbol *sym), (sym)); 1760INLINE Lisp_Object
1761(SYMBOL_VAL) (struct Lisp_Symbol *sym)
1762{
1763 return lisp_h_SYMBOL_VAL (sym);
1764}
1719 1765
1720INLINE struct Lisp_Symbol * 1766INLINE struct Lisp_Symbol *
1721SYMBOL_ALIAS (struct Lisp_Symbol *sym) 1767SYMBOL_ALIAS (struct Lisp_Symbol *sym)
@@ -1736,8 +1782,11 @@ SYMBOL_FWD (struct Lisp_Symbol *sym)
1736 return sym->val.fwd; 1782 return sym->val.fwd;
1737} 1783}
1738 1784
1739LISP_MACRO_DEFUN_VOID (SET_SYMBOL_VAL, 1785INLINE void
1740 (struct Lisp_Symbol *sym, Lisp_Object v), (sym, v)); 1786(SET_SYMBOL_VAL) (struct Lisp_Symbol *sym, Lisp_Object v)
1787{
1788 lisp_h_SET_SYMBOL_VAL (sym, v);
1789}
1741 1790
1742INLINE void 1791INLINE void
1743SET_SYMBOL_ALIAS (struct Lisp_Symbol *sym, struct Lisp_Symbol *v) 1792SET_SYMBOL_ALIAS (struct Lisp_Symbol *sym, struct Lisp_Symbol *v)
@@ -1784,7 +1833,11 @@ SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (Lisp_Object sym)
1784 value cannot be changed (there is an exception for keyword symbols, 1833 value cannot be changed (there is an exception for keyword symbols,
1785 whose value can be set to the keyword symbol itself). */ 1834 whose value can be set to the keyword symbol itself). */
1786 1835
1787LISP_MACRO_DEFUN (SYMBOL_CONSTANT_P, int, (Lisp_Object sym), (sym)); 1836INLINE int
1837(SYMBOL_CONSTANT_P) (Lisp_Object sym)
1838{
1839 return lisp_h_SYMBOL_CONSTANT_P (sym);
1840}
1788 1841
1789/* Placeholder for make-docfile to process. The actual symbol 1842/* Placeholder for make-docfile to process. The actual symbol
1790 definition is done by lread.c's defsym. */ 1843 definition is done by lread.c's defsym. */
@@ -2454,7 +2507,11 @@ enum char_bits
2454 2507
2455/* Data type checking. */ 2508/* Data type checking. */
2456 2509
2457LISP_MACRO_DEFUN (NILP, bool, (Lisp_Object x), (x)); 2510INLINE bool
2511(NILP) (Lisp_Object x)
2512{
2513 return lisp_h_NILP (x);
2514}
2458 2515
2459INLINE bool 2516INLINE bool
2460NUMBERP (Lisp_Object x) 2517NUMBERP (Lisp_Object x)
@@ -2478,13 +2535,41 @@ RANGED_INTEGERP (intmax_t lo, Lisp_Object x, intmax_t hi)
2478 && (TYPE_SIGNED (type) ? TYPE_MINIMUM (type) <= XINT (x) : 0 <= XINT (x)) \ 2535 && (TYPE_SIGNED (type) ? TYPE_MINIMUM (type) <= XINT (x) : 0 <= XINT (x)) \
2479 && XINT (x) <= TYPE_MAXIMUM (type)) 2536 && XINT (x) <= TYPE_MAXIMUM (type))
2480 2537
2481LISP_MACRO_DEFUN (CONSP, bool, (Lisp_Object x), (x)); 2538INLINE bool
2482LISP_MACRO_DEFUN (FLOATP, bool, (Lisp_Object x), (x)); 2539(CONSP) (Lisp_Object x)
2483LISP_MACRO_DEFUN (MISCP, bool, (Lisp_Object x), (x)); 2540{
2484LISP_MACRO_DEFUN (SYMBOLP, bool, (Lisp_Object x), (x)); 2541 return lisp_h_CONSP (x);
2485LISP_MACRO_DEFUN (INTEGERP, bool, (Lisp_Object x), (x)); 2542}
2486LISP_MACRO_DEFUN (VECTORLIKEP, bool, (Lisp_Object x), (x)); 2543INLINE bool
2487LISP_MACRO_DEFUN (MARKERP, bool, (Lisp_Object x), (x)); 2544(FLOATP) (Lisp_Object x)
2545{
2546 return lisp_h_FLOATP (x);
2547}
2548INLINE bool
2549(MISCP) (Lisp_Object x)
2550{
2551 return lisp_h_MISCP (x);
2552}
2553INLINE bool
2554(SYMBOLP) (Lisp_Object x)
2555{
2556 return lisp_h_SYMBOLP (x);
2557}
2558INLINE bool
2559(INTEGERP) (Lisp_Object x)
2560{
2561 return lisp_h_INTEGERP (x);
2562}
2563INLINE bool
2564(VECTORLIKEP) (Lisp_Object x)
2565{
2566 return lisp_h_VECTORLIKEP (x);
2567}
2568INLINE bool
2569(MARKERP) (Lisp_Object x)
2570{
2571 return lisp_h_MARKERP (x);
2572}
2488 2573
2489INLINE bool 2574INLINE bool
2490STRINGP (Lisp_Object x) 2575STRINGP (Lisp_Object x)
@@ -2635,9 +2720,23 @@ CHECK_LIST (Lisp_Object x)
2635 CHECK_TYPE (CONSP (x) || NILP (x), Qlistp, x); 2720 CHECK_TYPE (CONSP (x) || NILP (x), Qlistp, x);
2636} 2721}
2637 2722
2638LISP_MACRO_DEFUN_VOID (CHECK_LIST_CONS, (Lisp_Object x, Lisp_Object y), (x, y)); 2723INLINE void
2639LISP_MACRO_DEFUN_VOID (CHECK_SYMBOL, (Lisp_Object x), (x)); 2724(CHECK_LIST_CONS) (Lisp_Object x, Lisp_Object y)
2640LISP_MACRO_DEFUN_VOID (CHECK_NUMBER, (Lisp_Object x), (x)); 2725{
2726 lisp_h_CHECK_LIST_CONS (x, y);
2727}
2728
2729INLINE void
2730(CHECK_SYMBOL) (Lisp_Object x)
2731{
2732 lisp_h_CHECK_SYMBOL (x);
2733}
2734
2735INLINE void
2736(CHECK_NUMBER) (Lisp_Object x)
2737{
2738 lisp_h_CHECK_NUMBER (x);
2739}
2641 2740
2642INLINE void 2741INLINE void
2643CHECK_STRING (Lisp_Object x) 2742CHECK_STRING (Lisp_Object x)