aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
authorK. Handa2016-01-03 17:53:43 +0900
committerK. Handa2016-01-03 17:53:43 +0900
commitfb6d826c69939c2d016c1b824d4e9bcb53d9e643 (patch)
treeb9ce862d6cbe25e740203421984df21e4cbadbf4 /src/lisp.h
parent536f48e9a2251b9e654ea974bd90ff2f40218753 (diff)
parent91917dd58ec5278e555b9c693a830749083e8f89 (diff)
downloademacs-fb6d826c69939c2d016c1b824d4e9bcb53d9e643.tar.gz
emacs-fb6d826c69939c2d016c1b824d4e9bcb53d9e643.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h152
1 files changed, 104 insertions, 48 deletions
diff --git a/src/lisp.h b/src/lisp.h
index 426b6c949e9..ff88605fc9f 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -357,7 +357,7 @@ error !;
357# define lisp_h_XINT(a) (XLI (a) >> INTTYPEBITS) 357# define lisp_h_XINT(a) (XLI (a) >> INTTYPEBITS)
358# define lisp_h_XSYMBOL(a) \ 358# define lisp_h_XSYMBOL(a) \
359 (eassert (SYMBOLP (a)), \ 359 (eassert (SYMBOLP (a)), \
360 (struct Lisp_Symbol *) ((uintptr_t) XLI (a) - Lisp_Symbol \ 360 (struct Lisp_Symbol *) ((intptr_t) XLI (a) - Lisp_Symbol \
361 + (char *) lispsym)) 361 + (char *) lispsym))
362# define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK)) 362# define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK))
363# define lisp_h_XUNTAG(a, type) ((void *) (intptr_t) (XLI (a) - (type))) 363# define lisp_h_XUNTAG(a, type) ((void *) (intptr_t) (XLI (a) - (type)))
@@ -369,6 +369,12 @@ error !;
369#if (defined __NO_INLINE__ \ 369#if (defined __NO_INLINE__ \
370 && ! defined __OPTIMIZE__ && ! defined __OPTIMIZE_SIZE__ \ 370 && ! defined __OPTIMIZE__ && ! defined __OPTIMIZE_SIZE__ \
371 && ! (defined INLINING && ! INLINING)) 371 && ! (defined INLINING && ! INLINING))
372# define DEFINE_KEY_OPS_AS_MACROS true
373#else
374# define DEFINE_KEY_OPS_AS_MACROS false
375#endif
376
377#if DEFINE_KEY_OPS_AS_MACROS
372# define XLI(o) lisp_h_XLI (o) 378# define XLI(o) lisp_h_XLI (o)
373# define XIL(i) lisp_h_XIL (i) 379# define XIL(i) lisp_h_XIL (i)
374# define CHECK_LIST_CONS(x, y) lisp_h_CHECK_LIST_CONS (x, y) 380# define CHECK_LIST_CONS(x, y) lisp_h_CHECK_LIST_CONS (x, y)
@@ -468,6 +474,9 @@ enum Lisp_Misc_Type
468 Lisp_Misc_Overlay, 474 Lisp_Misc_Overlay,
469 Lisp_Misc_Save_Value, 475 Lisp_Misc_Save_Value,
470 Lisp_Misc_Finalizer, 476 Lisp_Misc_Finalizer,
477#ifdef HAVE_MODULES
478 Lisp_Misc_User_Ptr,
479#endif
471 /* Currently floats are not a misc type, 480 /* Currently floats are not a misc type,
472 but let's define this in case we want to change that. */ 481 but let's define this in case we want to change that. */
473 Lisp_Misc_Float, 482 Lisp_Misc_Float,
@@ -581,6 +590,12 @@ INLINE bool PROCESSP (Lisp_Object);
581INLINE bool PSEUDOVECTORP (Lisp_Object, int); 590INLINE bool PSEUDOVECTORP (Lisp_Object, int);
582INLINE bool SAVE_VALUEP (Lisp_Object); 591INLINE bool SAVE_VALUEP (Lisp_Object);
583INLINE bool FINALIZERP (Lisp_Object); 592INLINE bool FINALIZERP (Lisp_Object);
593
594#ifdef HAVE_MODULES
595INLINE bool USER_PTRP (Lisp_Object);
596INLINE struct Lisp_User_Ptr *(XUSER_PTR) (Lisp_Object);
597#endif
598
584INLINE void set_sub_char_table_contents (Lisp_Object, ptrdiff_t, 599INLINE void set_sub_char_table_contents (Lisp_Object, ptrdiff_t,
585 Lisp_Object); 600 Lisp_Object);
586INLINE bool STRINGP (Lisp_Object); 601INLINE bool STRINGP (Lisp_Object);
@@ -704,9 +719,15 @@ struct Lisp_Symbol
704#define DEFUN_ARGS_8 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, \ 719#define DEFUN_ARGS_8 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, \
705 Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object) 720 Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)
706 721
707/* Yield an integer that contains TAG along with PTR. */ 722/* Yield a signed integer that contains TAG along with PTR.
723
724 Sign-extend pointers when USE_LSB_TAG (this simplifies emacs-module.c),
725 and zero-extend otherwise (that’s a bit faster here).
726 Sign extension matters only when EMACS_INT is wider than a pointer. */
708#define TAG_PTR(tag, ptr) \ 727#define TAG_PTR(tag, ptr) \
709 ((USE_LSB_TAG ? (tag) : (EMACS_UINT) (tag) << VALBITS) + (uintptr_t) (ptr)) 728 (USE_LSB_TAG \
729 ? (intptr_t) (ptr) + (tag) \
730 : (EMACS_INT) (((EMACS_UINT) (tag) << VALBITS) + (uintptr_t) (ptr)))
710 731
711/* Yield an integer that contains a symbol tag along with OFFSET. 732/* Yield an integer that contains a symbol tag along with OFFSET.
712 OFFSET should be the offset in bytes from 'lispsym' to the symbol. */ 733 OFFSET should be the offset in bytes from 'lispsym' to the symbol. */
@@ -838,7 +859,9 @@ INLINE EMACS_INT
838INLINE EMACS_INT 859INLINE EMACS_INT
839(XFASTINT) (Lisp_Object a) 860(XFASTINT) (Lisp_Object a)
840{ 861{
841 return lisp_h_XFASTINT (a); 862 EMACS_INT n = lisp_h_XFASTINT (a);
863 eassume (0 <= n);
864 return n;
842} 865}
843 866
844INLINE struct Lisp_Symbol * 867INLINE struct Lisp_Symbol *
@@ -906,19 +929,10 @@ XFASTINT (Lisp_Object a)
906{ 929{
907 EMACS_INT int0 = Lisp_Int0; 930 EMACS_INT int0 = Lisp_Int0;
908 EMACS_INT n = USE_LSB_TAG ? XINT (a) : XLI (a) - (int0 << VALBITS); 931 EMACS_INT n = USE_LSB_TAG ? XINT (a) : XLI (a) - (int0 << VALBITS);
909 eassert (0 <= n); 932 eassume (0 <= n);
910 return n; 933 return n;
911} 934}
912 935
913/* Extract A's value as a symbol. */
914INLINE struct Lisp_Symbol *
915XSYMBOL (Lisp_Object a)
916{
917 uintptr_t i = (uintptr_t) XUNTAG (a, Lisp_Symbol);
918 void *p = (char *) lispsym + i;
919 return p;
920}
921
922/* Extract A's type. */ 936/* Extract A's type. */
923INLINE enum Lisp_Type 937INLINE enum Lisp_Type
924XTYPE (Lisp_Object a) 938XTYPE (Lisp_Object a)
@@ -927,6 +941,16 @@ XTYPE (Lisp_Object a)
927 return USE_LSB_TAG ? i & ~VALMASK : i >> VALBITS; 941 return USE_LSB_TAG ? i & ~VALMASK : i >> VALBITS;
928} 942}
929 943
944/* Extract A's value as a symbol. */
945INLINE struct Lisp_Symbol *
946XSYMBOL (Lisp_Object a)
947{
948 eassert (SYMBOLP (a));
949 intptr_t i = (intptr_t) XUNTAG (a, Lisp_Symbol);
950 void *p = (char *) lispsym + i;
951 return p;
952}
953
930/* Extract A's pointer value, assuming A's type is TYPE. */ 954/* Extract A's pointer value, assuming A's type is TYPE. */
931INLINE void * 955INLINE void *
932XUNTAG (Lisp_Object a, int type) 956XUNTAG (Lisp_Object a, int type)
@@ -1527,7 +1551,16 @@ aref_addr (Lisp_Object array, ptrdiff_t idx)
1527INLINE ptrdiff_t 1551INLINE ptrdiff_t
1528ASIZE (Lisp_Object array) 1552ASIZE (Lisp_Object array)
1529{ 1553{
1530 return XVECTOR (array)->header.size; 1554 ptrdiff_t size = XVECTOR (array)->header.size;
1555 eassume (0 <= size);
1556 return size;
1557}
1558
1559INLINE ptrdiff_t
1560gc_asize (Lisp_Object array)
1561{
1562 /* Like ASIZE, but also can be used in the garbage collector. */
1563 return XVECTOR (array)->header.size & ~ARRAY_MARK_FLAG;
1531} 1564}
1532 1565
1533INLINE void 1566INLINE void
@@ -1542,7 +1575,7 @@ gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val)
1542{ 1575{
1543 /* Like ASET, but also can be used in the garbage collector: 1576 /* Like ASET, but also can be used in the garbage collector:
1544 sweep_weak_table calls set_hash_key etc. while the table is marked. */ 1577 sweep_weak_table calls set_hash_key etc. while the table is marked. */
1545 eassert (0 <= idx && idx < (ASIZE (array) & ~ARRAY_MARK_FLAG)); 1578 eassert (0 <= idx && idx < gc_asize (array));
1546 XVECTOR (array)->contents[idx] = val; 1579 XVECTOR (array)->contents[idx] = val;
1547} 1580}
1548 1581
@@ -1924,21 +1957,22 @@ struct Lisp_Hash_Table
1924}; 1957};
1925 1958
1926 1959
1960INLINE bool
1961HASH_TABLE_P (Lisp_Object a)
1962{
1963 return PSEUDOVECTORP (a, PVEC_HASH_TABLE);
1964}
1965
1927INLINE struct Lisp_Hash_Table * 1966INLINE struct Lisp_Hash_Table *
1928XHASH_TABLE (Lisp_Object a) 1967XHASH_TABLE (Lisp_Object a)
1929{ 1968{
1969 eassert (HASH_TABLE_P (a));
1930 return XUNTAG (a, Lisp_Vectorlike); 1970 return XUNTAG (a, Lisp_Vectorlike);
1931} 1971}
1932 1972
1933#define XSET_HASH_TABLE(VAR, PTR) \ 1973#define XSET_HASH_TABLE(VAR, PTR) \
1934 (XSETPSEUDOVECTOR (VAR, PTR, PVEC_HASH_TABLE)) 1974 (XSETPSEUDOVECTOR (VAR, PTR, PVEC_HASH_TABLE))
1935 1975
1936INLINE bool
1937HASH_TABLE_P (Lisp_Object a)
1938{
1939 return PSEUDOVECTORP (a, PVEC_HASH_TABLE);
1940}
1941
1942/* Value is the key part of entry IDX in hash table H. */ 1976/* Value is the key part of entry IDX in hash table H. */
1943INLINE Lisp_Object 1977INLINE Lisp_Object
1944HASH_KEY (struct Lisp_Hash_Table *h, ptrdiff_t idx) 1978HASH_KEY (struct Lisp_Hash_Table *h, ptrdiff_t idx)
@@ -2230,6 +2264,18 @@ XSAVE_OBJECT (Lisp_Object obj, int n)
2230 return XSAVE_VALUE (obj)->data[n].object; 2264 return XSAVE_VALUE (obj)->data[n].object;
2231} 2265}
2232 2266
2267#ifdef HAVE_MODULES
2268struct Lisp_User_Ptr
2269{
2270 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_User_Ptr */
2271 bool_bf gcmarkbit : 1;
2272 unsigned spacer : 15;
2273
2274 void (*finalizer) (void *);
2275 void *p;
2276};
2277#endif
2278
2233/* A finalizer sentinel. */ 2279/* A finalizer sentinel. */
2234struct Lisp_Finalizer 2280struct Lisp_Finalizer
2235 { 2281 {
@@ -2265,6 +2311,9 @@ union Lisp_Misc
2265 struct Lisp_Overlay u_overlay; 2311 struct Lisp_Overlay u_overlay;
2266 struct Lisp_Save_Value u_save_value; 2312 struct Lisp_Save_Value u_save_value;
2267 struct Lisp_Finalizer u_finalizer; 2313 struct Lisp_Finalizer u_finalizer;
2314#ifdef HAVE_MODULES
2315 struct Lisp_User_Ptr u_user_ptr;
2316#endif
2268 }; 2317 };
2269 2318
2270INLINE union Lisp_Misc * 2319INLINE union Lisp_Misc *
@@ -2314,6 +2363,15 @@ XFINALIZER (Lisp_Object a)
2314 return & XMISC (a)->u_finalizer; 2363 return & XMISC (a)->u_finalizer;
2315} 2364}
2316 2365
2366#ifdef HAVE_MODULES
2367INLINE struct Lisp_User_Ptr *
2368XUSER_PTR (Lisp_Object a)
2369{
2370 eassert (USER_PTRP (a));
2371 return & XMISC (a)->u_user_ptr;
2372}
2373#endif
2374
2317 2375
2318/* Forwarding pointer to an int variable. 2376/* Forwarding pointer to an int variable.
2319 This is allowed only in the value cell of a symbol, 2377 This is allowed only in the value cell of a symbol,
@@ -2598,6 +2656,14 @@ FINALIZERP (Lisp_Object x)
2598 return MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Finalizer; 2656 return MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Finalizer;
2599} 2657}
2600 2658
2659#ifdef HAVE_MODULES
2660INLINE bool
2661USER_PTRP (Lisp_Object x)
2662{
2663 return MISCP (x) && XMISCTYPE (x) == Lisp_Misc_User_Ptr;
2664}
2665#endif
2666
2601INLINE bool 2667INLINE bool
2602AUTOLOADP (Lisp_Object x) 2668AUTOLOADP (Lisp_Object x)
2603{ 2669{
@@ -3104,7 +3170,9 @@ SPECPDL_INDEX (void)
3104 A call like (throw TAG VAL) searches for a catchtag whose `tag_or_ch' 3170 A call like (throw TAG VAL) searches for a catchtag whose `tag_or_ch'
3105 member is TAG, and then unbinds to it. The `val' member is used to 3171 member is TAG, and then unbinds to it. The `val' member is used to
3106 hold VAL while the stack is unwound; `val' is returned as the value 3172 hold VAL while the stack is unwound; `val' is returned as the value
3107 of the catch form. 3173 of the catch form. If there is a handler of type CATCHER_ALL, it will
3174 be treated as a handler for all invocations of `throw'; in this case
3175 `val' will be set to (TAG . VAL).
3108 3176
3109 All the other members are concerned with restoring the interpreter 3177 All the other members are concerned with restoring the interpreter
3110 state. 3178 state.
@@ -3112,7 +3180,7 @@ SPECPDL_INDEX (void)
3112 Members are volatile if their values need to survive _longjmp when 3180 Members are volatile if their values need to survive _longjmp when
3113 a 'struct handler' is a local variable. */ 3181 a 'struct handler' is a local variable. */
3114 3182
3115enum handlertype { CATCHER, CONDITION_CASE }; 3183enum handlertype { CATCHER, CONDITION_CASE, CATCHER_ALL };
3116 3184
3117struct handler 3185struct handler
3118{ 3186{
@@ -3140,28 +3208,6 @@ struct handler
3140 struct byte_stack *byte_stack; 3208 struct byte_stack *byte_stack;
3141}; 3209};
3142 3210
3143/* Fill in the components of c, and put it on the list. */
3144#define PUSH_HANDLER(c, tag_ch_val, handlertype) \
3145 if (handlerlist->nextfree) \
3146 (c) = handlerlist->nextfree; \
3147 else \
3148 { \
3149 (c) = xmalloc (sizeof (struct handler)); \
3150 (c)->nextfree = NULL; \
3151 handlerlist->nextfree = (c); \
3152 } \
3153 (c)->type = (handlertype); \
3154 (c)->tag_or_ch = (tag_ch_val); \
3155 (c)->val = Qnil; \
3156 (c)->next = handlerlist; \
3157 (c)->lisp_eval_depth = lisp_eval_depth; \
3158 (c)->pdlcount = SPECPDL_INDEX (); \
3159 (c)->poll_suppress_count = poll_suppress_count; \
3160 (c)->interrupt_input_blocked = interrupt_input_blocked;\
3161 (c)->byte_stack = byte_stack_list; \
3162 handlerlist = (c);
3163
3164
3165extern Lisp_Object memory_signal_data; 3211extern Lisp_Object memory_signal_data;
3166 3212
3167/* An address near the bottom of the stack. 3213/* An address near the bottom of the stack.
@@ -3407,7 +3453,8 @@ Lisp_Object make_hash_table (struct hash_table_test, Lisp_Object, Lisp_Object,
3407ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *); 3453ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *);
3408ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object, 3454ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object,
3409 EMACS_UINT); 3455 EMACS_UINT);
3410extern struct hash_table_test hashtest_eql, hashtest_equal; 3456void hash_remove_from_table (struct Lisp_Hash_Table *, Lisp_Object);
3457extern struct hash_table_test hashtest_eq, hashtest_eql, hashtest_equal;
3411extern void validate_subarray (Lisp_Object, Lisp_Object, Lisp_Object, 3458extern void validate_subarray (Lisp_Object, Lisp_Object, Lisp_Object,
3412 ptrdiff_t, ptrdiff_t *, ptrdiff_t *); 3459 ptrdiff_t, ptrdiff_t *, ptrdiff_t *);
3413extern Lisp_Object substring_both (Lisp_Object, ptrdiff_t, ptrdiff_t, 3460extern Lisp_Object substring_both (Lisp_Object, ptrdiff_t, ptrdiff_t,
@@ -3803,7 +3850,6 @@ intern_c_string (const char *str)
3803} 3850}
3804 3851
3805/* Defined in eval.c. */ 3852/* Defined in eval.c. */
3806extern EMACS_INT lisp_eval_depth;
3807extern Lisp_Object Vautoload_queue; 3853extern Lisp_Object Vautoload_queue;
3808extern Lisp_Object Vrun_hooks; 3854extern Lisp_Object Vrun_hooks;
3809extern Lisp_Object Vsignaling_function; 3855extern Lisp_Object Vsignaling_function;
@@ -3847,6 +3893,8 @@ extern Lisp_Object internal_condition_case_2 (Lisp_Object (*) (Lisp_Object, Lisp
3847extern Lisp_Object internal_condition_case_n 3893extern Lisp_Object internal_condition_case_n
3848 (Lisp_Object (*) (ptrdiff_t, Lisp_Object *), ptrdiff_t, Lisp_Object *, 3894 (Lisp_Object (*) (ptrdiff_t, Lisp_Object *), ptrdiff_t, Lisp_Object *,
3849 Lisp_Object, Lisp_Object (*) (Lisp_Object, ptrdiff_t, Lisp_Object *)); 3895 Lisp_Object, Lisp_Object (*) (Lisp_Object, ptrdiff_t, Lisp_Object *));
3896extern struct handler *push_handler (Lisp_Object, enum handlertype);
3897extern struct handler *push_handler_nosignal (Lisp_Object, enum handlertype);
3850extern void specbind (Lisp_Object, Lisp_Object); 3898extern void specbind (Lisp_Object, Lisp_Object);
3851extern void record_unwind_protect (void (*) (Lisp_Object), Lisp_Object); 3899extern void record_unwind_protect (void (*) (Lisp_Object), Lisp_Object);
3852extern void record_unwind_protect_ptr (void (*) (void *), void *); 3900extern void record_unwind_protect_ptr (void (*) (void *), void *);
@@ -3877,6 +3925,14 @@ Lisp_Object backtrace_top_function (void);
3877extern bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol); 3925extern bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol);
3878extern bool let_shadows_global_binding_p (Lisp_Object symbol); 3926extern bool let_shadows_global_binding_p (Lisp_Object symbol);
3879 3927
3928#ifdef HAVE_MODULES
3929/* Defined in alloc.c. */
3930extern Lisp_Object make_user_ptr (void (*finalizer) (void*), void *p);
3931
3932/* Defined in emacs-module.c. */
3933extern void module_init (void);
3934extern void syms_of_module (void);
3935#endif
3880 3936
3881/* Defined in editfns.c. */ 3937/* Defined in editfns.c. */
3882extern void insert1 (Lisp_Object); 3938extern void insert1 (Lisp_Object);