Mercurial > hg > xemacs-beta
diff src/eval.c @ 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 | 671b65f2b075 |
children | 0e48d8b45bdb |
line wrap: on
line diff
--- a/src/eval.c Thu Feb 20 22:52:51 2003 +0000 +++ b/src/eval.c Fri Feb 21 06:57:21 2003 +0000 @@ -404,7 +404,6 @@ #endif static int warning_will_be_discarded (Lisp_Object level); -static void check_proper_critical_section_nonlocal_exit_protection (void); /************************************************************************/ @@ -1442,6 +1441,34 @@ /* Non-local exits */ /************************************************************************/ +#ifdef ERROR_CHECK_TRAPPING_PROBLEMS + +int +proper_redisplay_wrapping_in_place (void) +{ + return !in_display + || ((get_inhibit_flags () & INTERNAL_INHIBIT_ERRORS) + && (get_inhibit_flags () & INTERNAL_INHIBIT_THROWS)); +} + +static void +check_proper_critical_section_nonlocal_exit_protection (void) +{ + assert_with_message + (proper_redisplay_wrapping_in_place (), + "Attempted non-local exit from within redisplay without being properly wrapped"); +} + +static void +check_proper_critical_section_lisp_protection (void) +{ + assert_with_message + (proper_redisplay_wrapping_in_place (), + "Attempt to call Lisp code from within redisplay without being properly wrapped"); +} + +#endif /* ERROR_CHECK_TRAPPING_PROBLEMS */ + DEFUN ("catch", Fcatch, 1, UNEVALLED, 0, /* \(catch TAG BODY...): eval BODY allowing nonlocal exits using `throw'. TAG is evalled to get the tag to use. Then the BODY is executed. @@ -1613,7 +1640,9 @@ abort (); #endif +#ifdef ERROR_CHECK_TRAPPING_PROBLEMS check_proper_critical_section_nonlocal_exit_protection (); +#endif /* If bomb_out_p is t, this is being called from Fsignal as a "last resort" when there is no handler for this error and @@ -2135,9 +2164,6 @@ #endif } -extern int in_display; -extern int gc_currently_forbidden; - /************************************************************************/ /* the workhorse error-signaling function */ @@ -2155,28 +2181,6 @@ { } -#ifdef ERROR_CHECK_TRAPPING_PROBLEMS - -static void -check_proper_critical_section_gc_protection (void) -{ - assert_with_message - (!in_display || gc_currently_forbidden, - "Potential GC from within redisplay without being properly wrapped"); -} - -#endif /* ERROR_CHECK_TRAPPING_PROBLEMS */ - -static void -check_proper_critical_section_nonlocal_exit_protection (void) -{ - assert_with_message - (!in_display - || ((get_inhibit_flags () & INTERNAL_INHIBIT_ERRORS) - && (get_inhibit_flags () & INTERNAL_INHIBIT_THROWS)), - "Attempted non-local exit from within redisplay without being properly wrapped"); -} - /* #### This function has not been synched with FSF. It diverges significantly. */ @@ -2234,7 +2238,9 @@ messy, difficult-to-debug ways. See enter_redisplay_critical_section(). */ +#ifdef ERROR_CHECK_TRAPPING_PROBLEMS check_proper_critical_section_nonlocal_exit_protection (); +#endif conditions = Fget (error_symbol, Qerror_conditions, Qnil); @@ -3464,6 +3470,10 @@ int nargs; struct backtrace backtrace; +#ifdef ERROR_CHECK_TRAPPING_PROBLEMS + check_proper_critical_section_lisp_protection (); +#endif + /* I think this is a pretty safe place to call Lisp code, don't you? */ while (!in_warnings && !NILP (Vpending_warnings) /* well, perhaps not so safe after all! */ @@ -3505,9 +3515,6 @@ } QUIT; -#ifdef ERROR_CHECK_TRAPPING_PROBLEMS - check_proper_critical_section_gc_protection (); -#endif if (need_to_garbage_collect) { struct gcpro gcpro1; @@ -3759,13 +3766,12 @@ Lisp_Object *fun_args = args + 1; Lisp_Object orig_fun; + /* QUIT will check for proper redisplay wrapping */ + QUIT; if (funcall_allocation_flag) { -#ifdef ERROR_CHECK_TRAPPING_PROBLEMS - check_proper_critical_section_gc_protection (); -#endif if (need_to_garbage_collect) /* Callers should gcpro lexpr args */ garbage_collect_1 (); @@ -4876,6 +4882,52 @@ call_trapping_problems_2, opaque); } +/* Turn on the trapping flags in FLAGS -- see call_trapping_problems(). + This cannot handle INTERNAL_INHIBIT_THROWS() or INTERNAL_INHIBIT_ERRORS + (because they ultimately boil down to a setjmp()!) -- you must directly + use call_trapping_problems() for that. Turn the flags off with + unbind_to(). Returns the "canonicalized" flags (particularly in the + case of INHIBIT_ANY_CHANGE_AFFECTING_REDISPLAY, which is shorthand for + various other flags). */ + +int +set_trapping_problems_flags (int flags) +{ + int new_inhibit_flags; + + if (flags & INHIBIT_ANY_CHANGE_AFFECTING_REDISPLAY) + flags |= INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION + | INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION + | INHIBIT_ENTERING_DEBUGGER + | INHIBIT_WARNING_ISSUE + | INHIBIT_GC; + + new_inhibit_flags = inhibit_flags | flags; + if (new_inhibit_flags != inhibit_flags) + internal_bind_int (&inhibit_flags, new_inhibit_flags); + + if (flags & INHIBIT_QUIT) + specbind (Qinhibit_quit, Qt); + + if (flags & UNINHIBIT_QUIT) + begin_do_check_for_quit (); + + if (flags & INHIBIT_GC) + begin_gc_forbidden (); + + /* #### If we have nested calls to call_trapping_problems(), and the + inner one creates some buffers/etc., should the outer one be able + to delete them? I think so, but it means we need to combine rather + than just reset the value. */ + if (flags & INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION) + internal_bind_lisp_object (&Vdeletable_permanent_display_objects, Qnil); + + if (flags & INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION) + internal_bind_lisp_object (&Vmodifiable_buffers, Qnil); + + return flags; +} + /* This is equivalent to (*fun) (arg), except that various conditions can be trapped or inhibited, according to FLAGS. @@ -5010,7 +5062,7 @@ Lisp_Object (*fun) (void *), void *arg) { - int speccount = specpdl_depth(); + int speccount = specpdl_depth (); struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; struct call_trapping_problems package; Lisp_Object opaque, thrown_tag, tem; @@ -5033,37 +5085,7 @@ package.data = Qnil; package.backtrace = Qnil; - if (flags & INHIBIT_ANY_CHANGE_AFFECTING_REDISPLAY) - flags |= INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION - | INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION - | INHIBIT_ENTERING_DEBUGGER - | INHIBIT_WARNING_ISSUE - | INHIBIT_GC; - - { - int new_inhibit_flags = inhibit_flags | flags; - if (new_inhibit_flags != inhibit_flags) - internal_bind_int (&inhibit_flags, new_inhibit_flags); - } - - if (flags & INHIBIT_QUIT) - specbind (Qinhibit_quit, Qt); - - if (flags & UNINHIBIT_QUIT) - begin_do_check_for_quit (); - - if (flags & INHIBIT_GC) - begin_gc_forbidden (); - - /* #### If we have nested calls to call_trapping_problems(), and the - inner one creates some buffers/etc., should the outer one be able - to delete them? I think so, but it means we need to combine rather - than just reset the value. */ - if (flags & INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION) - internal_bind_lisp_object (&Vdeletable_permanent_display_objects, Qnil); - - if (flags & INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION) - internal_bind_lisp_object (&Vmodifiable_buffers, Qnil); + flags = set_trapping_problems_flags (flags); if (flags & (INTERNAL_INHIBIT_THROWS | INTERNAL_INHIBIT_ERRORS)) opaque = make_opaque_ptr (&package);