diff options
| author | Tom Tromey | 2013-06-03 12:25:05 -0600 |
|---|---|---|
| committer | Tom Tromey | 2013-06-03 12:25:05 -0600 |
| commit | 68359abba96d7ec4db8aab3d3dd9cf1105c3bab5 (patch) | |
| tree | 862703e7e1a1888170136a8296a5750d6b2ae2eb /src/lisp.h | |
| parent | cbcba8ce7f980b01c18c0fd561ef6687b1361507 (diff) | |
| parent | e2d8a6f0a229b4ebe26484b892ec4f14888f58b6 (diff) | |
| download | emacs-68359abba96d7ec4db8aab3d3dd9cf1105c3bab5.tar.gz emacs-68359abba96d7ec4db8aab3d3dd9cf1105c3bab5.zip | |
merge from trunk; clean up some issues
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 305 |
1 files changed, 220 insertions, 85 deletions
diff --git a/src/lisp.h b/src/lisp.h index 44dde1860cc..c8732d125cc 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -75,6 +75,7 @@ enum | |||
| 75 | BITS_PER_SHORT = CHAR_BIT * sizeof (short), | 75 | BITS_PER_SHORT = CHAR_BIT * sizeof (short), |
| 76 | BITS_PER_INT = CHAR_BIT * sizeof (int), | 76 | BITS_PER_INT = CHAR_BIT * sizeof (int), |
| 77 | BITS_PER_LONG = CHAR_BIT * sizeof (long int), | 77 | BITS_PER_LONG = CHAR_BIT * sizeof (long int), |
| 78 | BITS_PER_PTRDIFF_T = CHAR_BIT * sizeof (ptrdiff_t), | ||
| 78 | BITS_PER_EMACS_INT = CHAR_BIT * sizeof (EMACS_INT) | 79 | BITS_PER_EMACS_INT = CHAR_BIT * sizeof (EMACS_INT) |
| 79 | }; | 80 | }; |
| 80 | 81 | ||
| @@ -233,9 +234,9 @@ enum enum_USE_LSB_TAG { USE_LSB_TAG = 0 }; | |||
| 233 | #define case_Lisp_Int case Lisp_Int0: case Lisp_Int1 | 234 | #define case_Lisp_Int case Lisp_Int0: case Lisp_Int1 |
| 234 | #define LISP_INT_TAG_P(x) (((x) & ~Lisp_Int1) == 0) | 235 | #define LISP_INT_TAG_P(x) (((x) & ~Lisp_Int1) == 0) |
| 235 | 236 | ||
| 236 | /* Stolen from GDB. The only known compiler that doesn't support | 237 | /* Idea stolen from GDB. MSVC doesn't support enums in bitfields, |
| 237 | enums in bitfields is MSVC. */ | 238 | and xlc complains vociferously about them. */ |
| 238 | #ifdef _MSC_VER | 239 | #if defined _MSC_VER || defined __IBMC__ |
| 239 | #define ENUM_BF(TYPE) unsigned int | 240 | #define ENUM_BF(TYPE) unsigned int |
| 240 | #else | 241 | #else |
| 241 | #define ENUM_BF(TYPE) enum TYPE | 242 | #define ENUM_BF(TYPE) enum TYPE |
| @@ -556,6 +557,7 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) | |||
| 556 | return num < lower ? lower : num <= upper ? num : upper; | 557 | return num < lower ? lower : num <= upper ? num : upper; |
| 557 | } | 558 | } |
| 558 | 559 | ||
| 560 | |||
| 559 | /* Extract a value or address from a Lisp_Object. */ | 561 | /* Extract a value or address from a Lisp_Object. */ |
| 560 | 562 | ||
| 561 | #define XCONS(a) (eassert (CONSP (a)), \ | 563 | #define XCONS(a) (eassert (CONSP (a)), \ |
| @@ -576,7 +578,6 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) | |||
| 576 | #define XMISCTYPE(a) (XMISCANY (a)->type) | 578 | #define XMISCTYPE(a) (XMISCANY (a)->type) |
| 577 | #define XMARKER(a) (eassert (MARKERP (a)), &(XMISC (a)->u_marker)) | 579 | #define XMARKER(a) (eassert (MARKERP (a)), &(XMISC (a)->u_marker)) |
| 578 | #define XOVERLAY(a) (eassert (OVERLAYP (a)), &(XMISC (a)->u_overlay)) | 580 | #define XOVERLAY(a) (eassert (OVERLAYP (a)), &(XMISC (a)->u_overlay)) |
| 579 | #define XSAVE_VALUE(a) (eassert (SAVE_VALUEP (a)), &(XMISC (a)->u_save_value)) | ||
| 580 | 581 | ||
| 581 | /* Forwarding object types. */ | 582 | /* Forwarding object types. */ |
| 582 | 583 | ||
| @@ -590,10 +591,12 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) | |||
| 590 | (eassert (KBOARD_OBJFWDP (a)), &((a)->u_kboard_objfwd)) | 591 | (eassert (KBOARD_OBJFWDP (a)), &((a)->u_kboard_objfwd)) |
| 591 | 592 | ||
| 592 | /* Pseudovector types. */ | 593 | /* Pseudovector types. */ |
| 593 | 594 | struct Lisp_Process; | |
| 595 | LISP_INLINE Lisp_Object make_lisp_proc (struct Lisp_Process *p) | ||
| 596 | { return make_lisp_ptr (p, Lisp_Vectorlike); } | ||
| 594 | #define XPROCESS(a) (eassert (PROCESSP (a)), \ | 597 | #define XPROCESS(a) (eassert (PROCESSP (a)), \ |
| 595 | (struct Lisp_Process *) XUNTAG (a, Lisp_Vectorlike)) | 598 | (struct Lisp_Process *) XUNTAG (a, Lisp_Vectorlike)) |
| 596 | #define XWINDOW(a) (eassert (WINDOWP (a)), \ | 599 | #define XWINDOW(a) (eassert (WINDOWP (a)), \ |
| 597 | (struct window *) XUNTAG (a, Lisp_Vectorlike)) | 600 | (struct window *) XUNTAG (a, Lisp_Vectorlike)) |
| 598 | #define XTERMINAL(a) (eassert (TERMINALP (a)), \ | 601 | #define XTERMINAL(a) (eassert (TERMINALP (a)), \ |
| 599 | (struct terminal *) XUNTAG (a, Lisp_Vectorlike)) | 602 | (struct terminal *) XUNTAG (a, Lisp_Vectorlike)) |
| @@ -792,13 +795,10 @@ extern ptrdiff_t string_bytes (struct Lisp_String *); | |||
| 792 | would expose alloc.c internal details that we'd rather keep | 795 | would expose alloc.c internal details that we'd rather keep |
| 793 | private. | 796 | private. |
| 794 | 797 | ||
| 795 | This is a macro for use in static initializers, and a constant for | 798 | This is a macro for use in static initializers. The cast to |
| 796 | visibility to GDB. The cast to ptrdiff_t ensures that | 799 | ptrdiff_t ensures that the macro is signed. */ |
| 797 | the macro is signed. */ | ||
| 798 | static ptrdiff_t const STRING_BYTES_BOUND = | ||
| 799 | #define STRING_BYTES_BOUND \ | 800 | #define STRING_BYTES_BOUND \ |
| 800 | ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, min (SIZE_MAX, PTRDIFF_MAX) - 1)) | 801 | ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, min (SIZE_MAX, PTRDIFF_MAX) - 1)) |
| 801 | STRING_BYTES_BOUND; | ||
| 802 | 802 | ||
| 803 | /* Mark STR as a unibyte string. */ | 803 | /* Mark STR as a unibyte string. */ |
| 804 | #define STRING_SET_UNIBYTE(STR) \ | 804 | #define STRING_SET_UNIBYTE(STR) \ |
| @@ -1403,6 +1403,35 @@ enum | |||
| 1403 | SAVE_OBJECT | 1403 | SAVE_OBJECT |
| 1404 | }; | 1404 | }; |
| 1405 | 1405 | ||
| 1406 | /* Number of bits needed to store one of the above values. */ | ||
| 1407 | enum { SAVE_SLOT_BITS = 2 }; | ||
| 1408 | |||
| 1409 | /* Number of slots in a save value where save_type is nonzero. */ | ||
| 1410 | enum { SAVE_VALUE_SLOTS = 4 }; | ||
| 1411 | |||
| 1412 | /* Bit-width and values for struct Lisp_Save_Value's save_type member. */ | ||
| 1413 | |||
| 1414 | enum { SAVE_TYPE_BITS = SAVE_VALUE_SLOTS * SAVE_SLOT_BITS + 1 }; | ||
| 1415 | |||
| 1416 | enum Lisp_Save_Type | ||
| 1417 | { | ||
| 1418 | SAVE_TYPE_INT_INT = SAVE_INTEGER + (SAVE_INTEGER << SAVE_SLOT_BITS), | ||
| 1419 | SAVE_TYPE_INT_INT_INT | ||
| 1420 | = (SAVE_INTEGER + (SAVE_TYPE_INT_INT << SAVE_SLOT_BITS)), | ||
| 1421 | SAVE_TYPE_OBJ_OBJ = SAVE_OBJECT + (SAVE_OBJECT << SAVE_SLOT_BITS), | ||
| 1422 | SAVE_TYPE_OBJ_OBJ_OBJ = SAVE_OBJECT + (SAVE_TYPE_OBJ_OBJ << SAVE_SLOT_BITS), | ||
| 1423 | SAVE_TYPE_OBJ_OBJ_OBJ_OBJ | ||
| 1424 | = SAVE_OBJECT + (SAVE_TYPE_OBJ_OBJ_OBJ << SAVE_SLOT_BITS), | ||
| 1425 | SAVE_TYPE_PTR_INT = SAVE_POINTER + (SAVE_INTEGER << SAVE_SLOT_BITS), | ||
| 1426 | SAVE_TYPE_PTR_OBJ = SAVE_POINTER + (SAVE_OBJECT << SAVE_SLOT_BITS), | ||
| 1427 | SAVE_TYPE_PTR_PTR = SAVE_POINTER + (SAVE_POINTER << SAVE_SLOT_BITS), | ||
| 1428 | SAVE_TYPE_PTR_PTR_OBJ | ||
| 1429 | = SAVE_POINTER + (SAVE_TYPE_PTR_OBJ << SAVE_SLOT_BITS), | ||
| 1430 | |||
| 1431 | /* This has an extra bit indicating it's raw memory. */ | ||
| 1432 | SAVE_TYPE_MEMORY = SAVE_TYPE_PTR_INT + (1 << (SAVE_TYPE_BITS - 1)) | ||
| 1433 | }; | ||
| 1434 | |||
| 1406 | /* Special object used to hold a different values for later use. | 1435 | /* Special object used to hold a different values for later use. |
| 1407 | 1436 | ||
| 1408 | This is mostly used to package C integers and pointers to call | 1437 | This is mostly used to package C integers and pointers to call |
| @@ -1423,74 +1452,50 @@ enum | |||
| 1423 | 1452 | ||
| 1424 | If yon need to pass more than just one C pointer, you should | 1453 | If yon need to pass more than just one C pointer, you should |
| 1425 | use make_save_value. This function allows you to pack up to | 1454 | use make_save_value. This function allows you to pack up to |
| 1426 | 4 integers, pointers or Lisp_Objects and conveniently get them | 1455 | SAVE_VALUE_SLOTS integers, pointers or Lisp_Objects and |
| 1427 | back with XSAVE_POINTER, XSAVE_INTEGER and XSAVE_OBJECT macros: | 1456 | conveniently get them back with XSAVE_POINTER, XSAVE_INTEGER and |
| 1457 | XSAVE_OBJECT macros: | ||
| 1428 | 1458 | ||
| 1429 | ... | 1459 | ... |
| 1430 | struct my_data *md = get_my_data (); | 1460 | struct my_data *md = get_my_data (); |
| 1431 | ptrdiff_t my_offset = get_my_offset (); | ||
| 1432 | Lisp_Object my_object = get_my_object (); | 1461 | Lisp_Object my_object = get_my_object (); |
| 1433 | record_unwind_protect | 1462 | record_unwind_protect |
| 1434 | (my_unwind, make_save_value ("pio", md, my_offset, my_object)); | 1463 | (my_unwind, make_save_value (SAVE_TYPE_PTR_OBJ, md, my_object)); |
| 1435 | ... | 1464 | ... |
| 1436 | 1465 | ||
| 1437 | Lisp_Object my_unwind (Lisp_Object arg) | 1466 | Lisp_Object my_unwind (Lisp_Object arg) |
| 1438 | { | 1467 | { |
| 1439 | struct my_data *md = XSAVE_POINTER (arg, 0); | 1468 | struct my_data *md = XSAVE_POINTER (arg, 0); |
| 1440 | ptrdiff_t my_offset = XSAVE_INTEGER (arg, 1); | 1469 | Lisp_Object my_object = XSAVE_OBJECT (arg, 1); |
| 1441 | Lisp_Object my_object = XSAVE_OBJECT (arg, 2); | ||
| 1442 | ... | 1470 | ... |
| 1443 | } | 1471 | } |
| 1444 | 1472 | ||
| 1445 | If ENABLE_CHECKING is in effect, XSAVE_xxx macros do type checking of the | 1473 | If ENABLE_CHECKING is in effect, XSAVE_xxx macros do type checking of the |
| 1446 | saved objects and raise eassert if type of the saved object doesn't match | 1474 | saved objects and raise eassert if type of the saved object doesn't match |
| 1447 | the type which is extracted. In the example above, XSAVE_INTEGER (arg, 2) | 1475 | the type which is extracted. In the example above, XSAVE_INTEGER (arg, 2) |
| 1448 | or XSAVE_OBJECT (arg, 1) are wrong because integer was saved in slot 1 and | 1476 | or XSAVE_OBJECT (arg, 0) are wrong because nothing was saved in slot 2 and |
| 1449 | Lisp_Object was saved in slot 2 of ARG. */ | 1477 | Lisp_Object was saved in slot 1 of ARG. */ |
| 1450 | 1478 | ||
| 1451 | struct Lisp_Save_Value | 1479 | struct Lisp_Save_Value |
| 1452 | { | 1480 | { |
| 1453 | ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Save_Value */ | 1481 | ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Save_Value */ |
| 1454 | unsigned gcmarkbit : 1; | 1482 | unsigned gcmarkbit : 1; |
| 1455 | int spacer : 6; | 1483 | int spacer : 32 - (16 + 1 + SAVE_TYPE_BITS); |
| 1456 | /* If `area' is nonzero, `data[0].pointer' is the address of a memory area | 1484 | |
| 1457 | containing `data[1].integer' potential Lisp_Objects. The rest of `data' | 1485 | /* DATA[N] may hold up to SAVE_VALUE_SLOTS entries. The type of |
| 1458 | fields are unused. */ | 1486 | V's Ith entry is given by save_type (V, I). E.g., if save_type |
| 1459 | unsigned area : 1; | 1487 | (V, 3) == SAVE_INTEGER, V->data[3].integer is in use. |
| 1460 | /* If `area' is zero, `data[N]' may hold different objects which type is | 1488 | |
| 1461 | encoded in `typeN' fields as described by the anonymous enum above. | 1489 | If SAVE_TYPE == SAVE_TYPE_MEMORY, DATA[0].pointer is the address of |
| 1462 | E.g. if `type0' is SAVE_INTEGER, `data[0].integer' is in use. */ | 1490 | a memory area containing DATA[1].integer potential Lisp_Objects. */ |
| 1463 | unsigned type0 : 2; | 1491 | ENUM_BF (Lisp_Save_Type) save_type : SAVE_TYPE_BITS; |
| 1464 | unsigned type1 : 2; | ||
| 1465 | unsigned type2 : 2; | ||
| 1466 | unsigned type3 : 2; | ||
| 1467 | union { | 1492 | union { |
| 1468 | void *pointer; | 1493 | void *pointer; |
| 1469 | ptrdiff_t integer; | 1494 | ptrdiff_t integer; |
| 1470 | Lisp_Object object; | 1495 | Lisp_Object object; |
| 1471 | } data[4]; | 1496 | } data[SAVE_VALUE_SLOTS]; |
| 1472 | }; | 1497 | }; |
| 1473 | 1498 | ||
| 1474 | /* Macro to set and extract Nth saved pointer. Type | ||
| 1475 | checking is ugly because it's used as an lvalue. */ | ||
| 1476 | |||
| 1477 | #define XSAVE_POINTER(obj, n) \ | ||
| 1478 | XSAVE_VALUE (obj)->data[(eassert (XSAVE_VALUE (obj)->type \ | ||
| 1479 | ## n == SAVE_POINTER), n)].pointer | ||
| 1480 | |||
| 1481 | /* Likewise for the saved integer. */ | ||
| 1482 | |||
| 1483 | #define XSAVE_INTEGER(obj, n) \ | ||
| 1484 | XSAVE_VALUE (obj)->data[(eassert (XSAVE_VALUE (obj)->type \ | ||
| 1485 | ## n == SAVE_INTEGER), n)].integer | ||
| 1486 | |||
| 1487 | /* Macro to extract Nth saved object. This is never used as | ||
| 1488 | an lvalue, so we can do more convenient type checking. */ | ||
| 1489 | |||
| 1490 | #define XSAVE_OBJECT(obj, n) \ | ||
| 1491 | (eassert (XSAVE_VALUE (obj)->type ## n == SAVE_OBJECT), \ | ||
| 1492 | XSAVE_VALUE (obj)->data[n].object) | ||
| 1493 | |||
| 1494 | /* A miscellaneous object, when it's on the free list. */ | 1499 | /* A miscellaneous object, when it's on the free list. */ |
| 1495 | struct Lisp_Free | 1500 | struct Lisp_Free |
| 1496 | { | 1501 | { |
| @@ -1797,7 +1802,66 @@ typedef struct { | |||
| 1797 | #define VECTORP(x) (VECTORLIKEP (x) && !(ASIZE (x) & PSEUDOVECTOR_FLAG)) | 1802 | #define VECTORP(x) (VECTORLIKEP (x) && !(ASIZE (x) & PSEUDOVECTOR_FLAG)) |
| 1798 | #define OVERLAYP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Overlay) | 1803 | #define OVERLAYP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Overlay) |
| 1799 | #define MARKERP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Marker) | 1804 | #define MARKERP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Marker) |
| 1800 | #define SAVE_VALUEP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Save_Value) | 1805 | |
| 1806 | LISP_INLINE bool | ||
| 1807 | SAVE_VALUEP (Lisp_Object x) | ||
| 1808 | { | ||
| 1809 | return MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Save_Value; | ||
| 1810 | } | ||
| 1811 | |||
| 1812 | LISP_INLINE struct Lisp_Save_Value * | ||
| 1813 | XSAVE_VALUE (Lisp_Object a) | ||
| 1814 | { | ||
| 1815 | eassert (SAVE_VALUEP (a)); | ||
| 1816 | return & XMISC (a)->u_save_value; | ||
| 1817 | } | ||
| 1818 | |||
| 1819 | /* Return the type of V's Nth saved value. */ | ||
| 1820 | LISP_INLINE int | ||
| 1821 | save_type (struct Lisp_Save_Value *v, int n) | ||
| 1822 | { | ||
| 1823 | eassert (0 <= n && n < SAVE_VALUE_SLOTS); | ||
| 1824 | return (v->save_type >> (SAVE_SLOT_BITS * n) & ((1 << SAVE_SLOT_BITS) - 1)); | ||
| 1825 | } | ||
| 1826 | |||
| 1827 | /* Get and set the Nth saved pointer. */ | ||
| 1828 | |||
| 1829 | LISP_INLINE void * | ||
| 1830 | XSAVE_POINTER (Lisp_Object obj, int n) | ||
| 1831 | { | ||
| 1832 | eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_POINTER); | ||
| 1833 | return XSAVE_VALUE (obj)->data[n].pointer;; | ||
| 1834 | } | ||
| 1835 | LISP_INLINE void | ||
| 1836 | set_save_pointer (Lisp_Object obj, int n, void *val) | ||
| 1837 | { | ||
| 1838 | eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_POINTER); | ||
| 1839 | XSAVE_VALUE (obj)->data[n].pointer = val; | ||
| 1840 | } | ||
| 1841 | |||
| 1842 | /* Likewise for the saved integer. */ | ||
| 1843 | |||
| 1844 | LISP_INLINE ptrdiff_t | ||
| 1845 | XSAVE_INTEGER (Lisp_Object obj, int n) | ||
| 1846 | { | ||
| 1847 | eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_INTEGER); | ||
| 1848 | return XSAVE_VALUE (obj)->data[n].integer; | ||
| 1849 | } | ||
| 1850 | LISP_INLINE void | ||
| 1851 | set_save_integer (Lisp_Object obj, int n, ptrdiff_t val) | ||
| 1852 | { | ||
| 1853 | eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_INTEGER); | ||
| 1854 | XSAVE_VALUE (obj)->data[n].integer = val; | ||
| 1855 | } | ||
| 1856 | |||
| 1857 | /* Extract Nth saved object. */ | ||
| 1858 | |||
| 1859 | LISP_INLINE Lisp_Object | ||
| 1860 | XSAVE_OBJECT (Lisp_Object obj, int n) | ||
| 1861 | { | ||
| 1862 | eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_OBJECT); | ||
| 1863 | return XSAVE_VALUE (obj)->data[n].object; | ||
| 1864 | } | ||
| 1801 | 1865 | ||
| 1802 | #define AUTOLOADP(x) (CONSP (x) && EQ (Qautoload, XCAR (x))) | 1866 | #define AUTOLOADP(x) (CONSP (x) && EQ (Qautoload, XCAR (x))) |
| 1803 | 1867 | ||
| @@ -2136,12 +2200,24 @@ typedef jmp_buf sys_jmp_buf; | |||
| 2136 | #endif | 2200 | #endif |
| 2137 | 2201 | ||
| 2138 | 2202 | ||
| 2203 | /* Elisp uses several stacks: | ||
| 2204 | - the C stack. | ||
| 2205 | - the bytecode stack: used internally by the bytecode interpreter. | ||
| 2206 | Allocated from the C stack. | ||
| 2207 | - The specpdl stack: keeps track of active unwind-protect and | ||
| 2208 | dynamic-let-bindings. Allocated from the `specpdl' array, a manually | ||
| 2209 | managed stack. | ||
| 2210 | - The catch stack: keeps track of active catch tags. | ||
| 2211 | Allocated on the C stack. This is where the setmp data is kept. | ||
| 2212 | - The handler stack: keeps track of active condition-case handlers. | ||
| 2213 | Allocated on the C stack. Every entry there also uses an entry in | ||
| 2214 | the catch stack. */ | ||
| 2215 | |||
| 2139 | /* Structure for recording Lisp call stack for backtrace purposes. */ | 2216 | /* Structure for recording Lisp call stack for backtrace purposes. */ |
| 2140 | 2217 | ||
| 2141 | /* The special binding stack holds the outer values of variables while | 2218 | /* The special binding stack holds the outer values of variables while |
| 2142 | they are bound by a function application or a let form, stores the | 2219 | they are bound by a function application or a let form, stores the |
| 2143 | code to be executed for Lisp unwind-protect forms, and stores the C | 2220 | code to be executed for unwind-protect forms. |
| 2144 | functions to be called for record_unwind_protect. | ||
| 2145 | 2221 | ||
| 2146 | If func is non-zero, undoing this binding applies func to old_value; | 2222 | If func is non-zero, undoing this binding applies func to old_value; |
| 2147 | This implements record_unwind_protect. | 2223 | This implements record_unwind_protect. |
| @@ -2154,32 +2230,82 @@ typedef jmp_buf sys_jmp_buf; | |||
| 2154 | which means having bound a local value while CURRENT-BUFFER was active. | 2230 | which means having bound a local value while CURRENT-BUFFER was active. |
| 2155 | If WHERE is nil this means we saw the default value when binding SYMBOL. | 2231 | If WHERE is nil this means we saw the default value when binding SYMBOL. |
| 2156 | WHERE being a buffer or frame means we saw a buffer-local or frame-local | 2232 | WHERE being a buffer or frame means we saw a buffer-local or frame-local |
| 2157 | value. Other values of WHERE mean an internal error. */ | 2233 | value. Other values of WHERE mean an internal error. |
| 2234 | |||
| 2235 | NOTE: The specbinding struct is defined here, because SPECPDL_INDEX is | ||
| 2236 | used all over the place, needs to be fast, and needs to know the size of | ||
| 2237 | struct specbinding. But only eval.c should access it. */ | ||
| 2158 | 2238 | ||
| 2159 | typedef Lisp_Object (*specbinding_func) (Lisp_Object); | 2239 | typedef Lisp_Object (*specbinding_func) (Lisp_Object); |
| 2160 | 2240 | ||
| 2241 | enum specbind_tag { | ||
| 2242 | SPECPDL_UNWIND, /* An unwind_protect function. */ | ||
| 2243 | SPECPDL_BACKTRACE, /* An element of the backtrace. */ | ||
| 2244 | SPECPDL_LET, /* A plain and simple dynamic let-binding. */ | ||
| 2245 | /* Tags greater than SPECPDL_LET must be "subkinds" of LET. */ | ||
| 2246 | SPECPDL_LET_LOCAL, /* A buffer-local let-binding. */ | ||
| 2247 | SPECPDL_LET_DEFAULT /* A global binding for a localized var. */ | ||
| 2248 | }; | ||
| 2249 | |||
| 2161 | struct specbinding | 2250 | struct specbinding |
| 2162 | { | 2251 | { |
| 2163 | Lisp_Object symbol, old_value; | 2252 | enum specbind_tag kind; |
| 2164 | specbinding_func func; | 2253 | union { |
| 2165 | /* Normally this is unused; but it is to the symbol's current | 2254 | struct { |
| 2166 | value when a thread is swapped out. */ | 2255 | Lisp_Object arg; |
| 2167 | Lisp_Object saved_value; | 2256 | specbinding_func func; |
| 2257 | } unwind; | ||
| 2258 | struct { | ||
| 2259 | /* `where' is not used in the case of SPECPDL_LET. */ | ||
| 2260 | Lisp_Object symbol, old_value, where; | ||
| 2261 | /* Normally this is unused; but it is to the symbol's current | ||
| 2262 | value when a thread is swapped out. */ | ||
| 2263 | Lisp_Object saved_value; | ||
| 2264 | } let; | ||
| 2265 | struct { | ||
| 2266 | Lisp_Object function; | ||
| 2267 | Lisp_Object *args; | ||
| 2268 | ptrdiff_t nargs : BITS_PER_PTRDIFF_T - 1; | ||
| 2269 | bool debug_on_exit : 1; | ||
| 2270 | } bt; | ||
| 2271 | } v; | ||
| 2168 | }; | 2272 | }; |
| 2169 | 2273 | ||
| 2170 | #define SPECPDL_INDEX() (specpdl_ptr - specpdl) | 2274 | LISP_INLINE Lisp_Object specpdl_symbol (struct specbinding *pdl) |
| 2275 | { eassert (pdl->kind >= SPECPDL_LET); return pdl->v.let.symbol; } | ||
| 2171 | 2276 | ||
| 2172 | struct backtrace | 2277 | LISP_INLINE Lisp_Object specpdl_old_value (struct specbinding *pdl) |
| 2173 | { | 2278 | { eassert (pdl->kind >= SPECPDL_LET); return pdl->v.let.old_value; } |
| 2174 | struct backtrace *next; | 2279 | |
| 2175 | Lisp_Object function; | 2280 | LISP_INLINE Lisp_Object specpdl_saved_value (struct specbinding *pdl) |
| 2176 | Lisp_Object *args; /* Points to vector of args. */ | 2281 | { eassert (pdl->kind >= SPECPDL_LET); return pdl->v.let.saved_value; } |
| 2177 | ptrdiff_t nargs; /* Length of vector. */ | ||
| 2178 | /* Nonzero means call value of debugger when done with this operation. */ | ||
| 2179 | unsigned int debug_on_exit : 1; | ||
| 2180 | }; | ||
| 2181 | 2282 | ||
| 2182 | extern struct backtrace *backtrace_list; | 2283 | LISP_INLINE Lisp_Object specpdl_where (struct specbinding *pdl) |
| 2284 | { eassert (pdl->kind > SPECPDL_LET); return pdl->v.let.where; } | ||
| 2285 | |||
| 2286 | LISP_INLINE Lisp_Object specpdl_arg (struct specbinding *pdl) | ||
| 2287 | { eassert (pdl->kind == SPECPDL_UNWIND); return pdl->v.unwind.arg; } | ||
| 2288 | |||
| 2289 | LISP_INLINE specbinding_func specpdl_func (struct specbinding *pdl) | ||
| 2290 | { eassert (pdl->kind == SPECPDL_UNWIND); return pdl->v.unwind.func; } | ||
| 2291 | |||
| 2292 | LISP_INLINE Lisp_Object backtrace_function (struct specbinding *pdl) | ||
| 2293 | { eassert (pdl->kind == SPECPDL_BACKTRACE); return pdl->v.bt.function; } | ||
| 2294 | |||
| 2295 | LISP_INLINE ptrdiff_t backtrace_nargs (struct specbinding *pdl) | ||
| 2296 | { eassert (pdl->kind == SPECPDL_BACKTRACE); return pdl->v.bt.nargs; } | ||
| 2297 | |||
| 2298 | LISP_INLINE Lisp_Object *backtrace_args (struct specbinding *pdl) | ||
| 2299 | { eassert (pdl->kind == SPECPDL_BACKTRACE); return pdl->v.bt.args; } | ||
| 2300 | |||
| 2301 | LISP_INLINE bool backtrace_debug_on_exit (struct specbinding *pdl) | ||
| 2302 | { eassert (pdl->kind == SPECPDL_BACKTRACE); return pdl->v.bt.debug_on_exit; } | ||
| 2303 | |||
| 2304 | /* extern struct specbinding *specpdl; */ | ||
| 2305 | /* extern struct specbinding *specpdl_ptr; */ | ||
| 2306 | /* extern ptrdiff_t specpdl_size; */ | ||
| 2307 | |||
| 2308 | #define SPECPDL_INDEX() (specpdl_ptr - specpdl) | ||
| 2183 | 2309 | ||
| 2184 | /* Everything needed to describe an active condition case. | 2310 | /* Everything needed to describe an active condition case. |
| 2185 | 2311 | ||
| @@ -2235,9 +2361,10 @@ struct catchtag | |||
| 2235 | Lisp_Object tag; | 2361 | Lisp_Object tag; |
| 2236 | Lisp_Object volatile val; | 2362 | Lisp_Object volatile val; |
| 2237 | struct catchtag *volatile next; | 2363 | struct catchtag *volatile next; |
| 2364 | #if 1 /* GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS, but they're defined later. */ | ||
| 2238 | struct gcpro *gcpro; | 2365 | struct gcpro *gcpro; |
| 2366 | #endif | ||
| 2239 | sys_jmp_buf jmp; | 2367 | sys_jmp_buf jmp; |
| 2240 | struct backtrace *backlist; | ||
| 2241 | struct handler *f_handlerlist; | 2368 | struct handler *f_handlerlist; |
| 2242 | EMACS_INT f_lisp_eval_depth; | 2369 | EMACS_INT f_lisp_eval_depth; |
| 2243 | ptrdiff_t volatile pdlcount; | 2370 | ptrdiff_t volatile pdlcount; |
| @@ -3122,7 +3249,7 @@ extern bool abort_on_gc; | |||
| 3122 | extern Lisp_Object make_float (double); | 3249 | extern Lisp_Object make_float (double); |
| 3123 | extern void display_malloc_warning (void); | 3250 | extern void display_malloc_warning (void); |
| 3124 | extern ptrdiff_t inhibit_garbage_collection (void); | 3251 | extern ptrdiff_t inhibit_garbage_collection (void); |
| 3125 | extern Lisp_Object make_save_value (const char *, ...); | 3252 | extern Lisp_Object make_save_value (enum Lisp_Save_Type, ...); |
| 3126 | extern Lisp_Object make_save_pointer (void *); | 3253 | extern Lisp_Object make_save_pointer (void *); |
| 3127 | extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object); | 3254 | extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object); |
| 3128 | extern void free_marker (Lisp_Object); | 3255 | extern void free_marker (Lisp_Object); |
| @@ -3180,6 +3307,7 @@ extern Lisp_Object internal_with_output_to_temp_buffer | |||
| 3180 | (const char *, Lisp_Object (*) (Lisp_Object), Lisp_Object); | 3307 | (const char *, Lisp_Object (*) (Lisp_Object), Lisp_Object); |
| 3181 | enum FLOAT_TO_STRING_BUFSIZE { FLOAT_TO_STRING_BUFSIZE = 350 }; | 3308 | enum FLOAT_TO_STRING_BUFSIZE { FLOAT_TO_STRING_BUFSIZE = 350 }; |
| 3182 | extern int float_to_string (char *, double); | 3309 | extern int float_to_string (char *, double); |
| 3310 | extern void init_print_once (void); | ||
| 3183 | extern void syms_of_print (void); | 3311 | extern void syms_of_print (void); |
| 3184 | 3312 | ||
| 3185 | /* Defined in doprnt.c. */ | 3313 | /* Defined in doprnt.c. */ |
| @@ -3294,6 +3422,14 @@ extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); | |||
| 3294 | extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); | 3422 | extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); |
| 3295 | extern void init_eval (void); | 3423 | extern void init_eval (void); |
| 3296 | extern void syms_of_eval (void); | 3424 | extern void syms_of_eval (void); |
| 3425 | extern void record_in_backtrace (Lisp_Object function, | ||
| 3426 | Lisp_Object *args, ptrdiff_t nargs); | ||
| 3427 | extern void mark_specpdl (struct specbinding *first, struct specbinding *ptr); | ||
| 3428 | extern void get_backtrace (Lisp_Object array); | ||
| 3429 | Lisp_Object backtrace_top_function (void); | ||
| 3430 | extern bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol); | ||
| 3431 | extern bool let_shadows_global_binding_p (Lisp_Object symbol); | ||
| 3432 | |||
| 3297 | 3433 | ||
| 3298 | /* Defined in thread.c. */ | 3434 | /* Defined in thread.c. */ |
| 3299 | extern void mark_threads (void); | 3435 | extern void mark_threads (void); |
| @@ -3464,7 +3600,7 @@ extern Lisp_Object Qvisible; | |||
| 3464 | extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object); | 3600 | extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object); |
| 3465 | extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object); | 3601 | extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object); |
| 3466 | extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object); | 3602 | extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object); |
| 3467 | #if HAVE_NS | 3603 | #if HAVE_NS || defined(WINDOWSNT) |
| 3468 | extern Lisp_Object get_frame_param (struct frame *, Lisp_Object); | 3604 | extern Lisp_Object get_frame_param (struct frame *, Lisp_Object); |
| 3469 | #endif | 3605 | #endif |
| 3470 | extern void frames_discard_buffer (Lisp_Object); | 3606 | extern void frames_discard_buffer (Lisp_Object); |
| @@ -3678,9 +3814,9 @@ extern void syms_of_fontset (void); | |||
| 3678 | extern Lisp_Object Qfont_param; | 3814 | extern Lisp_Object Qfont_param; |
| 3679 | #endif | 3815 | #endif |
| 3680 | 3816 | ||
| 3681 | #ifdef WINDOWSNT | 3817 | /* Defined in gfilenotify.c */ |
| 3682 | /* Defined on w32notify.c. */ | 3818 | #ifdef HAVE_GFILENOTIFY |
| 3683 | extern void syms_of_w32notify (void); | 3819 | extern void syms_of_gfilenotify (void); |
| 3684 | #endif | 3820 | #endif |
| 3685 | 3821 | ||
| 3686 | /* Defined in inotify.c */ | 3822 | /* Defined in inotify.c */ |
| @@ -3688,6 +3824,11 @@ extern void syms_of_w32notify (void); | |||
| 3688 | extern void syms_of_inotify (void); | 3824 | extern void syms_of_inotify (void); |
| 3689 | #endif | 3825 | #endif |
| 3690 | 3826 | ||
| 3827 | #ifdef HAVE_W32NOTIFY | ||
| 3828 | /* Defined on w32notify.c. */ | ||
| 3829 | extern void syms_of_w32notify (void); | ||
| 3830 | #endif | ||
| 3831 | |||
| 3691 | /* Defined in xfaces.c. */ | 3832 | /* Defined in xfaces.c. */ |
| 3692 | extern Lisp_Object Qdefault, Qtool_bar, Qfringe; | 3833 | extern Lisp_Object Qdefault, Qtool_bar, Qfringe; |
| 3693 | extern Lisp_Object Qheader_line, Qscroll_bar, Qcursor; | 3834 | extern Lisp_Object Qheader_line, Qscroll_bar, Qcursor; |
| @@ -3728,11 +3869,6 @@ extern void syms_of_xml (void); | |||
| 3728 | extern void xml_cleanup_parser (void); | 3869 | extern void xml_cleanup_parser (void); |
| 3729 | #endif | 3870 | #endif |
| 3730 | 3871 | ||
| 3731 | #ifdef HAVE_MENUS | ||
| 3732 | /* Defined in (x|w32)fns.c, nsfns.m... */ | ||
| 3733 | extern int have_menus_p (void); | ||
| 3734 | #endif | ||
| 3735 | |||
| 3736 | #ifdef HAVE_DBUS | 3872 | #ifdef HAVE_DBUS |
| 3737 | /* Defined in dbusbind.c. */ | 3873 | /* Defined in dbusbind.c. */ |
| 3738 | void syms_of_dbusbind (void); | 3874 | void syms_of_dbusbind (void); |
| @@ -3840,8 +3976,7 @@ extern void *record_xmalloc (size_t); | |||
| 3840 | { \ | 3976 | { \ |
| 3841 | Lisp_Object arg_; \ | 3977 | Lisp_Object arg_; \ |
| 3842 | buf = xmalloc ((nelt) * word_size); \ | 3978 | buf = xmalloc ((nelt) * word_size); \ |
| 3843 | arg_ = make_save_value ("pi", buf, nelt); \ | 3979 | arg_ = make_save_value (SAVE_TYPE_MEMORY, buf, nelt); \ |
| 3844 | XSAVE_VALUE (arg_)->area = 1; \ | ||
| 3845 | sa_must_free = 1; \ | 3980 | sa_must_free = 1; \ |
| 3846 | record_unwind_protect (safe_alloca_unwind, arg_); \ | 3981 | record_unwind_protect (safe_alloca_unwind, arg_); \ |
| 3847 | } \ | 3982 | } \ |