comparison src/lisp.h @ 1318:b531bf8658e9

[xemacs-hg @ 2003-02-21 06:56:46 by ben] redisplay fixes et al. PROBLEMS: Add comment about Cygwin, unexec and sysmalloc. Move some non-general stuff out of general. Make a section for x86. configure.in: Add check for broken alloca in funcalls. mule/mule-cmds.el: Alias file-name to native not vice-versa. Do set EOL of native but not of process output to fix various problems and be consistent with code-init.el. code-cmds.el: Return a name not a coding system. code-init.el: Reindent. Remove `file-name' since it should always be the same as native. unicode.el: Rename to load-unicode-mapping-table as suggested by the anonymous (but rather Turnbullian) comment in unicode.c. xemacs.dsp: Add /k to default build. alloc.c: Make gc_currently_forbidden static. config.h.in, lisp.h: Move some stuff to lisp.h. console-gtk.h, console-impl.h, console-msw.h, console-x.h, event-Xt.c, event-msw.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-x.c, gtk-xemacs.c: Remove duplicated code to redraw exposed area. Add deadbox method needed by the generalized redraw code. Defer redrawing if already in redisplay. frame-msw.c, event-stream.c, frame.c: Add comments about calling Lisp. debug.c, general-slots.h: Move generalish symbols to general-slots.h. doprnt.c: reindent. lisp.h, dynarr.c: Add debug code for locking a dynarr to catch invalid mods. Use in redisplay.c. eval.c: file-coding.c: Define file-name as alias for native not vice-versa. frame-gtk.c, frame-x.c: Move Qwindow_id to general-slots. dialog-msw.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, gui.c, gui.h, menubar-msw.c, menubar.c: Ensure that various glyph functions that eval within redisplay protect the evals. Same for calls to internal_equal(). Modify various functions, e.g. gui_item_*(), to protect evals within redisplay, taking an in_redisplay parameter if it's possible for them to be called both inside and outside of redisplay. gutter.c: Defer specifier-changed updating till after redisplay, if necessary, since we need to enter redisplay to do it. gutter.c: Do nothing if in redisplay. lisp.h: Add version of alloca() for use in function calls. lisp.h: Add XCAD[D+]R up to 6 D's, and aliases X1ST, X2ND, etc. frame.c, frame.h, redisplay.c, redisplay.h, signal.c, toolbar.c: Redo critical-section code and move from frame.c to redisplay.c. Require that every place inside of redisplay catch errors itself, not at the edge of the critical section (thereby bypassing the rest of redisplay and leaving things in an inconsistent state). Introduce separate means of holding frame-size changes without entering a complete critical section. Introduce "post-redisplay" methods for deferring things till after redisplay. Abort if we enter redisplay reentrantly. Disable all quit checking in redisplay since it's too dangerous. Ensure that all calls to QUIT trigger an abort if unprotected. redisplay.c, scrollbar-gtk.c, scrollbar-x.c, scrollbar.c: Create enter/exit_redisplay_critical_section_maybe() for code that needs to ensure it's in a critical section but doesn't interfere with an existing critical section. sysdep.c: Use _wexecve() when under Windows NT for Unicode correctness. text.c, text.h: Add new_dfc() functions, which return an alloca()ed value rather than requiring an lvalue. (Not really used yet; used in another workspace, to come.) Add some macros for SIZED_EXTERNAL. Update the encoding aliases after involved scrutinization of the X manual. unicode.c: Answer the anonymous but suspiciously Turnbullian questions. Rename parse-unicode-translation-table to load-unicode-mapping-table, as suggested.
author ben
date Fri, 21 Feb 2003 06:57:21 +0000
parents 70921960b980
children 1b0339b048ce
comparison
equal deleted inserted replaced
1317:d9d08dc5e617 1318:b531bf8658e9
52 52
53 /************************************************************************/ 53 /************************************************************************/
54 /* general definitions */ 54 /* general definitions */
55 /************************************************************************/ 55 /************************************************************************/
56 56
57 /* ------------------------ include files ------------------- */ 57 /* -------------------------- include files --------------------- */
58 58
59 /* We include the following generally useful header files so that you 59 /* We include the following generally useful header files so that you
60 don't have to worry about prototypes when using the standard C 60 don't have to worry about prototypes when using the standard C
61 library functions and macros. These files shouldn't be excessively 61 library functions and macros. These files shouldn't be excessively
62 large so they shouldn't cause that much of a slowdown. */ 62 large so they shouldn't cause that much of a slowdown. */
68 #include <stdarg.h> 68 #include <stdarg.h>
69 #include <stddef.h> /* offsetof */ 69 #include <stddef.h> /* offsetof */
70 #include <sys/types.h> 70 #include <sys/types.h>
71 #include <limits.h> 71 #include <limits.h>
72 72
73 /* --------------------- error-checking sublevels --------------------- */ 73 /* -------------------------- error-checking ------------------------ */
74 74
75 /* The large categories established by configure can be subdivided into 75 /* The large categories established by configure can be subdivided into
76 smaller subcategories, for problems in specific modules. You can't 76 smaller subcategories, for problems in specific modules. You can't
77 control this using configure, but you can manually stick in a define as 77 control this using configure, but you can manually stick in a define as
78 necessary. */ 78 necessary. */
81 /* Check for problems with the catch list and specbind stack */ 81 /* Check for problems with the catch list and specbind stack */
82 #define ERROR_CHECK_CATCH 82 #define ERROR_CHECK_CATCH
83 /* Check for insufficient use of call_trapping_problems(), particularly 83 /* Check for insufficient use of call_trapping_problems(), particularly
84 due to glyph-related changes causing eval or QUIT within redisplay */ 84 due to glyph-related changes causing eval or QUIT within redisplay */
85 #define ERROR_CHECK_TRAPPING_PROBLEMS 85 #define ERROR_CHECK_TRAPPING_PROBLEMS
86 #endif
87
88 #ifdef ERROR_CHECK_TYPES
89 #define type_checking_assert(assertion) assert (assertion)
90 #define type_checking_assert_at_line(assertion, file, line) \
91 assert_at_line (assertion, file, line)
92 #define type_checking_assert_with_message(assertion, msg) \
93 assert_with_message (assertion, msg)
94 #else
95 #define type_checking_assert(assertion)
96 #define type_checking_assert_at_line(assertion, file, line)
97 #define type_checking_assert_with_message(assertion, msg)
98 #endif
99 #ifdef ERROR_CHECK_GC
100 #define gc_checking_assert(assertion) assert (assertion)
101 #define gc_checking_assert_at_line(assertion, file, line) \
102 assert_at_line (assertion, file, line)
103 #define gc_checking_assert_with_message(assertion, msg) \
104 assert_with_message (assertion, msg)
105 #else
106 #define gc_checking_assert(assertion)
107 #define gc_checking_assert_at_line(assertion, file, line)
108 #define gc_checking_assert_with_message(assertion, msg)
109 #endif
110 #ifdef ERROR_CHECK_TEXT
111 #define text_checking_assert(assertion) assert (assertion)
112 #define text_checking_assert_at_line(assertion, file, line) \
113 assert_at_line (assertion, file, line)
114 #define text_checking_assert_with_message(assertion, msg) \
115 assert_with_message (assertion, msg)
116 #else
117 #define text_checking_assert(assertion)
118 #define text_checking_assert_at_line(assertion, file, line)
119 #define text_checking_assert_with_message(assertion, msg)
120 #endif
121 #ifdef ERROR_CHECK_TRAPPING_PROBLEMS
122 #define trapping_problems_checking_assert(assertion) assert (assertion)
123 #define trapping_problems_checking_assert_at_line(assertion, file, line) \
124 assert_at_line (assertion, file, line)
125 #define trapping_problems_checking_assert_with_message(assertion, msg) \
126 assert_with_message (assertion, msg)
127 #else
128 #define trapping_problems_checking_assert(assertion)
129 #define trapping_problems_checking_assert_at_line(assertion, file, line)
130 #define trapping_problems_checking_assert_with_message(assertion, msg)
86 #endif 131 #endif
87 132
88 /* ------------------------ definition of EMACS_INT ------------------- */ 133 /* ------------------------ definition of EMACS_INT ------------------- */
89 134
90 /* EMACS_INT is the underlying integral type into which a Lisp_Object must fit. 135 /* EMACS_INT is the underlying integral type into which a Lisp_Object must fit.
576 DECLARE_INTCLASS (cl) \ 621 DECLARE_INTCLASS (cl) \
577 DECLARE_POS_CLASS_SECOND_HALF (cl, countcl) 622 DECLARE_POS_CLASS_SECOND_HALF (cl, countcl)
578 623
579 /* Basic declaration at the top of all X-position classes (that can refer 624 /* Basic declaration at the top of all X-position classes (that can refer
580 to buffers or strings). CL1 and CL2 are the equivalent more specific 625 to buffers or strings). CL1 and CL2 are the equivalent more specific
581 classes referring only to buffers or strings, respefitvely. */ 626 classes referring only to buffers or strings, respectively. */
582 627
583 #define DECLARE_XPOS_CLASS(cl, countcl, cl1, cl2) \ 628 #define DECLARE_XPOS_CLASS(cl, countcl, cl1, cl2) \
584 DECLARE_INTCLASS (cl) \ 629 DECLARE_INTCLASS (cl) \
585 cl (const cl1& x) { data = x.data; } \ 630 cl (const cl1& x) { data = x.data; } \
586 cl (const cl2& x) { data = x.data; } \ 631 cl (const cl2& x) { data = x.data; } \
1112 __temp_alloca_size__ > MAX_ALLOCA_VS_C_ALLOCA ? \ 1157 __temp_alloca_size__ > MAX_ALLOCA_VS_C_ALLOCA ? \
1113 xemacs_c_alloca (__temp_alloca_size__) : \ 1158 xemacs_c_alloca (__temp_alloca_size__) : \
1114 (need_to_check_c_alloca ? xemacs_c_alloca (0) : 0, \ 1159 (need_to_check_c_alloca ? xemacs_c_alloca (0) : 0, \
1115 alloca (__temp_alloca_size__))) 1160 alloca (__temp_alloca_size__)))
1116 1161
1162 /* Version of ALLOCA() that is guaranteed to work inside of function calls
1163 (i.e., we call the C alloca if regular alloca() is broken inside of
1164 function calls). */
1165 #ifdef BROKEN_ALLOCA_IN_FUNCTION_CALLS
1166 #define ALLOCA_FUNCALL_OK(size) xemacs_c_alloca (size)
1167 #else
1168 #define ALLOCA_FUNCALL_OK(size) ALLOCA (size)
1169 #endif
1170
1117 /* WARNING: If you use this, you must unbind_to() at the end of your 1171 /* WARNING: If you use this, you must unbind_to() at the end of your
1118 function! */ 1172 function! */
1119 1173
1120 #define MALLOC_OR_ALLOCA(size) \ 1174 #define MALLOC_OR_ALLOCA(size) \
1121 (__temp_alloca_size__ = (size), \ 1175 (__temp_alloca_size__ = (size), \
1155 void xfree (void *); 1209 void xfree (void *);
1156 #endif /* ERROR_CHECK_MALLOC */ 1210 #endif /* ERROR_CHECK_MALLOC */
1157 1211
1158 /* ------------------------ dynamic arrays ------------------- */ 1212 /* ------------------------ dynamic arrays ------------------- */
1159 1213
1214 #ifdef ERROR_CHECK_STRUCTURES
1215 #define Dynarr_declare(type) \
1216 type *base; \
1217 int locked; \
1218 int elsize; \
1219 int cur; \
1220 int largest; \
1221 int max
1222 #else
1160 #define Dynarr_declare(type) \ 1223 #define Dynarr_declare(type) \
1161 type *base; \ 1224 type *base; \
1162 int elsize; \ 1225 int elsize; \
1163 int cur; \ 1226 int cur; \
1164 int largest; \ 1227 int largest; \
1165 int max 1228 int max
1229 #endif /* ERROR_CHECK_STRUCTURES */
1166 1230
1167 typedef struct dynarr 1231 typedef struct dynarr
1168 { 1232 {
1169 Dynarr_declare (void); 1233 Dynarr_declare (void);
1170 } Dynarr; 1234 } Dynarr;
1194 assert_at_line (dy->cur >= 0 && dy->cur <= dy->largest && 1258 assert_at_line (dy->cur >= 0 && dy->cur <= dy->largest &&
1195 dy->largest <= dy->max, file, line); 1259 dy->largest <= dy->max, file, line);
1196 return dy; 1260 return dy;
1197 } 1261 }
1198 1262
1263 DECLARE_INLINE_HEADER (
1264 Dynarr *
1265 Dynarr_verify_mod_1 (void *d, const char *file, int line)
1266 )
1267 {
1268 Dynarr *dy = (Dynarr *) d;
1269 assert_at_line (!dy->locked, file, line);
1270 assert_at_line (dy->cur >= 0 && dy->cur <= dy->largest &&
1271 dy->largest <= dy->max, file, line);
1272 return dy;
1273 }
1274
1199 #define Dynarr_verify(d) Dynarr_verify_1 (d, __FILE__, __LINE__) 1275 #define Dynarr_verify(d) Dynarr_verify_1 (d, __FILE__, __LINE__)
1276 #define Dynarr_verify_mod(d) Dynarr_verify_mod_1 (d, __FILE__, __LINE__)
1277 #define Dynarr_lock(d) (Dynarr_verify_mod (d)->locked = 1)
1278 #define Dynarr_unlock(d) ((d)->locked = 0)
1200 #else 1279 #else
1201 #define Dynarr_verify(d) (d) 1280 #define Dynarr_verify(d) (d)
1281 #define Dynarr_verify_mod(d) (d)
1282 #define Dynarr_lock(d)
1283 #define Dynarr_unlock(d)
1202 #endif /* ERROR_CHECK_STRUCTURES */ 1284 #endif /* ERROR_CHECK_STRUCTURES */
1203 1285
1204 #define Dynarr_length(d) (Dynarr_verify (d)->cur) 1286 #define Dynarr_length(d) (Dynarr_verify (d)->cur)
1205 #define Dynarr_largest(d) (Dynarr_verify (d)->largest) 1287 #define Dynarr_largest(d) (Dynarr_verify (d)->largest)
1206 #define Dynarr_reset(d) (Dynarr_verify (d)->cur = 0) 1288 #define Dynarr_reset(d) (Dynarr_verify_mod (d)->cur = 0)
1207 #define Dynarr_add_many(d, el, len) Dynarr_insert_many (d, el, len, (d)->cur) 1289 #define Dynarr_add_many(d, el, len) Dynarr_insert_many (d, el, len, (d)->cur)
1208 #define Dynarr_insert_many_at_start(d, el, len) \ 1290 #define Dynarr_insert_many_at_start(d, el, len) \
1209 Dynarr_insert_many (d, el, len, 0) 1291 Dynarr_insert_many (d, el, len, 0)
1210 #define Dynarr_add_literal_string(d, s) Dynarr_add_many (d, s, sizeof (s) - 1) 1292 #define Dynarr_add_literal_string(d, s) Dynarr_add_many (d, s, sizeof (s) - 1)
1211 #define Dynarr_add_lisp_string(d, s, codesys) \ 1293 #define Dynarr_add_lisp_string(d, s, codesys) \
1212 do { \ 1294 do { \
1213 Lisp_Object dyna_ls_s = (s); \ 1295 Lisp_Object dyna_ls_s = (s); \
1214 Lisp_Object dyna_ls_cs = (codesys); \ 1296 Lisp_Object dyna_ls_cs = (codesys); \
1215 Extbyte *dyna_ls_eb; \ 1297 Extbyte *dyna_ls_eb; \
1216 Bytecount dyna_ls_bc; \ 1298 Bytecount dyna_ls_bc; \
1217 \ 1299 \
1218 TO_EXTERNAL_FORMAT (LISP_STRING, dyna_ls_s, \ 1300 LISP_STRING_TO_SIZED_EXTERNAL (dyna_ls_s, dyna_ls_eb, \
1219 ALLOCA, (dyna_ls_eb, dyna_ls_bc), \ 1301 dyna_ls_bc, dyna_ls_cs); \
1220 dyna_ls_cs); \ 1302 Dynarr_add_many (d, dyna_ls_eb, dyna_ls_bc); \
1221 Dynarr_add_many (d, dyna_ls_eb, dyna_ls_bc); \
1222 } while (0) 1303 } while (0)
1223 1304
1224 #define Dynarr_add(d, el) ( \ 1305 #define Dynarr_add(d, el) ( \
1225 Dynarr_verify (d)->cur >= (d)->max ? Dynarr_resize ((d), (d)->cur+1) : \ 1306 Dynarr_verify_mod (d)->cur >= (d)->max ? Dynarr_resize ((d), (d)->cur+1) : \
1226 (void) 0, \ 1307 (void) 0, \
1227 ((d)->base)[(d)->cur++] = (el), \ 1308 ((d)->base)[(d)->cur++] = (el), \
1228 (d)->cur > (d)->largest ? (d)->largest = (d)->cur : (int) 0) 1309 (d)->cur > (d)->largest ? (d)->largest = (d)->cur : (int) 0)
1229 1310
1230 /* The following defines will get you into real trouble if you aren't 1311 /* The following defines will get you into real trouble if you aren't
1231 careful. But they can save a lot of execution time when used wisely. */ 1312 careful. But they can save a lot of execution time when used wisely. */
1232 #define Dynarr_increment(d) ((d)->cur++) 1313 #define Dynarr_increment(d) (Dynarr_verify_mod (d)->cur++)
1233 #define Dynarr_set_size(d, n) ((d)->cur = n) 1314 #define Dynarr_set_size(d, n) (Dynarr_verify_mod (d)->cur = n)
1234 1315
1235 #define Dynarr_pop(d) \ 1316 #define Dynarr_pop(d) \
1236 (assert ((d)->cur > 0), (d)->cur--, Dynarr_at (d, (d)->cur)) 1317 (assert ((d)->cur > 0), Dynarr_verify_mod (d)->cur--, \
1237 #define Dynarr_delete(d, i) Dynarr_delete_many (d, i, len) 1318 Dynarr_at (d, (d)->cur))
1319 #define Dynarr_delete(d, i) Dynarr_delete_many (d, i, 1)
1238 #define Dynarr_delete_by_pointer(d, p) \ 1320 #define Dynarr_delete_by_pointer(d, p) \
1239 Dynarr_delete_many (d, (p) - ((d)->base), 1) 1321 Dynarr_delete_many (d, (p) - ((d)->base), 1)
1240 1322
1241 #define Dynarr_delete_object(d, el) \ 1323 #define Dynarr_delete_object(d, el) \
1242 do { \ 1324 do \
1243 if (d != NULL) { \ 1325 { \
1244 REGISTER int i; \ 1326 REGISTER int i; \
1245 for (i = Dynarr_length (d) - 1; i >= 0; i--) { \ 1327 for (i = Dynarr_length (d) - 1; i >= 0; i--) \
1246 if (el == Dynarr_at (d, i)) { \ 1328 { \
1247 Dynarr_delete_many (d, i, 1); \ 1329 if (el == Dynarr_at (d, i)) \
1248 } \ 1330 Dynarr_delete_many (d, i, 1); \
1249 } \ 1331 } \
1250 } \
1251 } while (0) 1332 } while (0)
1252 1333
1253 #ifdef MEMORY_USAGE_STATS 1334 #ifdef MEMORY_USAGE_STATS
1254 struct overhead_stats; 1335 struct overhead_stats;
1255 Bytecount Dynarr_memory_usage (void *d, struct overhead_stats *stats); 1336 Bytecount Dynarr_memory_usage (void *d, struct overhead_stats *stats);
1631 #define NILP(x) EQ (x, Qnil) 1712 #define NILP(x) EQ (x, Qnil)
1632 #define cons_car(a) ((a)->car_) 1713 #define cons_car(a) ((a)->car_)
1633 #define cons_cdr(a) ((a)->cdr_) 1714 #define cons_cdr(a) ((a)->cdr_)
1634 #define XCAR(a) (XCONS (a)->car_) 1715 #define XCAR(a) (XCONS (a)->car_)
1635 #define XCDR(a) (XCONS (a)->cdr_) 1716 #define XCDR(a) (XCONS (a)->cdr_)
1717 #define XCADR(a) (XCAR (XCDR (a)))
1718 #define XCDDR(a) (XCDR (XCDR (a)))
1719 #define XCADDR(a) (XCAR (XCDDR (a)))
1720 #define XCDDDR(a) (XCDR (XCDDR (a)))
1721 #define XCADDDR(a) (XCAR (XCDDDR (a)))
1722 #define XCDDDDR(a) (XCDR (XCDDDR (a)))
1723 #define XCADDDDR(a) (XCAR (XCDDDDR (a)))
1724 #define XCDDDDDR(a) (XCDR (XCDDDDR (a)))
1725 #define XCADDDDDR(a) (XCAR (XCDDDDDR (a)))
1726 #define XCDDDDDDR(a) (XCDR (XCDDDDDR (a)))
1727 #define X1ST(a) XCAR (a)
1728 #define X2ND(a) XCADR (a)
1729 #define X3RD(a) XCADDR (a)
1730 #define X4TH(a) XCADDDR (a)
1731 #define X5TH(a) XCADDDDR (a)
1732 #define X6TH(a) XCADDDDDR (a)
1733
1636 #define XSETCAR(a, b) (XCONS (a)->car_ = (b)) 1734 #define XSETCAR(a, b) (XCONS (a)->car_ = (b))
1637 #define XSETCDR(a, b) (XCONS (a)->cdr_ = (b)) 1735 #define XSETCDR(a, b) (XCONS (a)->cdr_ = (b))
1638 #define LISTP(x) (CONSP(x) || NILP(x)) 1736 #define LISTP(x) (CONSP(x) || NILP(x))
1639 1737
1640 #define CHECK_LIST(x) do { \ 1738 #define CHECK_LIST(x) do { \
3957 Lisp_Object, 4055 Lisp_Object,
3958 Lisp_Object), 4056 Lisp_Object),
3959 Lisp_Object handler_arg, 4057 Lisp_Object handler_arg,
3960 Lisp_Object (*fun) (Lisp_Object), 4058 Lisp_Object (*fun) (Lisp_Object),
3961 Lisp_Object arg); 4059 Lisp_Object arg);
4060 int set_trapping_problems_flags (int flags);
3962 Lisp_Object call_trapping_problems (Lisp_Object warning_class, 4061 Lisp_Object call_trapping_problems (Lisp_Object warning_class,
3963 const char *warning_string, 4062 const char *warning_string,
3964 int flags, 4063 int flags,
3965 struct call_trapping_problems_result 4064 struct call_trapping_problems_result
3966 *problem, 4065 *problem,
4016 int nargs, ...); 4115 int nargs, ...);
4017 Lisp_Object call_with_suspended_errors (lisp_fn_t, Lisp_Object, 4116 Lisp_Object call_with_suspended_errors (lisp_fn_t, Lisp_Object,
4018 Lisp_Object, 4117 Lisp_Object,
4019 Error_Behavior, int, ...); 4118 Error_Behavior, int, ...);
4020 /* C Code should be using internal_catch, record_unwind_p, condition_case_1 */ 4119 /* C Code should be using internal_catch, record_unwind_p, condition_case_1 */
4120 int proper_redisplay_wrapping_in_place (void);
4021 Lisp_Object internal_catch (Lisp_Object, Lisp_Object (*) (Lisp_Object), 4121 Lisp_Object internal_catch (Lisp_Object, Lisp_Object (*) (Lisp_Object),
4022 Lisp_Object, int * volatile, 4122 Lisp_Object, int * volatile,
4023 Lisp_Object * volatile); 4123 Lisp_Object * volatile);
4024 Lisp_Object condition_case_1 (Lisp_Object, 4124 Lisp_Object condition_case_1 (Lisp_Object,
4025 Lisp_Object (*) (Lisp_Object), 4125 Lisp_Object (*) (Lisp_Object),