From 0edbf0b6fb48eb11d1e28aee898532625455e484 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 22 Feb 2012 07:55:46 -0800 Subject: * src/lisp.h: Improve comment about USE_LSB_TAG. --- src/lisp.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lisp.h b/src/lisp.h index 8bfd7071e5f..375d376702b 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -195,12 +195,25 @@ extern int suppress_checking EXTERNALLY_VISIBLE; || defined DARWIN_OS || defined __sun) /* We also need to be able to specify mult-of-8 alignment on static vars. */ # if defined DECL_ALIGN -/* mark_maybe_object assumes that EMACS_INT values are contiguous, - but this is not true on some hosts where EMACS_INT is wider than a pointer, - as they may allocate the halves of an EMACS_INT separately. - On these hosts USE_LSB_TAG is not needed because the top bits of an - EMACS_INT are unused, so define USE_LSB_TAG only on hosts where it - might be useful. */ +/* On hosts where VALBITS is greater than the pointer width in bits, + USE_LSB_TAG is: + + a. unnecessary, because the top bits of an EMACS_INT are unused, + + b. slower, because it typically requires extra masking, and + + c. harmful, because it can create Lisp_Object values that are so scrambled + that mark_maybe_object cannot decipher them. mark_maybe_object assumes + that EMACS_INT values are contiguous, but a host where EMACS_INT is + wider than a pointer might allocate the top half of an EMACS_INT in + (say) a 32-bit word on the stack, putting the bottom half in a 32-bit + register that is saved elsewhere in a jmp_buf. When this happens, + since USE_LSB_TAG is not defined the bottom half alone is a valid + pointer that mark_maybe_pointer can follow; but if USE_LSB_TAG were + defined, the bottom half would not be a valid pointer and neither + mark_maybe_object nor mark_maybe_pointer would follow it. + + So, define USE_LSB_TAG only on hosts where it might be useful. */ # if UINTPTR_MAX >> VALBITS != 0 # define USE_LSB_TAG # endif -- cgit v1.2.1 From f01d3321d5a7ca4147b675f02d5aa51dc65c2b55 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Thu, 23 Feb 2012 15:28:21 +0800 Subject: Avoid infloop in next-frame during frame creation. See thread at http://lists.gnu.org/archive/html/emacs-devel/2012-02/msg00573.html * src/window.c (inhibit_window_configuration_change_hook): New var. (run_window_configuration_change_hook): Obey it. * src/xfns.c (Fx_create_frame): Avoid window-configuration-change-hook call when setting menu-bar-lines and tool-bar-lines parameters. (unwind_create_frame_1): New helper function. --- src/ChangeLog | 9 +++++++++ src/window.c | 5 ++++- src/window.h | 4 ++++ src/xfns.c | 42 +++++++++++++++++++++++++++++++----------- 4 files changed, 48 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 5a376c4ad5b..3d660159a1a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2012-02-23 Chong Yidong + + * xfns.c (Fx_create_frame): Avoid window-configuration-change-hook + call when setting menu-bar-lines and tool-bar-lines parameters. + (unwind_create_frame_1): New helper function. + + * window.c (inhibit_window_configuration_change_hook): New var. + (run_window_configuration_change_hook): Obey it. + 2012-02-22 Chong Yidong * xterm.c (x_draw_image_relief): Add missing type check for diff --git a/src/window.c b/src/window.c index 95e7d8a5685..397d84a8b05 100644 --- a/src/window.c +++ b/src/window.c @@ -122,6 +122,9 @@ static int window_initialized; /* Hook to run when window config changes. */ static Lisp_Object Qwindow_configuration_change_hook; +/* If non-nil, run_window_configuration_change_hook does nothing. */ +Lisp_Object inhibit_window_configuration_change_hook; + /* Used by the function window_scroll_pixel_based */ static int window_scroll_pixel_based_preserve_x; static int window_scroll_pixel_based_preserve_y; @@ -2894,7 +2897,7 @@ run_window_configuration_change_hook (struct frame *f) = Fdefault_value (Qwindow_configuration_change_hook); XSETFRAME (frame, f); - if (NILP (Vrun_hooks)) + if (NILP (Vrun_hooks) || !NILP (inhibit_window_configuration_change_hook)) return; /* Use the right buffer. Matters when running the local hooks. */ diff --git a/src/window.h b/src/window.h index ea127ca95a8..f4a5f52b9a5 100644 --- a/src/window.h +++ b/src/window.h @@ -810,6 +810,10 @@ extern Lisp_Object Vmouse_window; extern Lisp_Object Vmouse_event; +/* If non-nil, run_window_configuration_change_hook does nothing. */ + +extern Lisp_Object inhibit_window_configuration_change_hook; + EXFUN (Fnext_window, 3); EXFUN (Fselect_window, 2); EXFUN (Fset_window_buffer, 3); diff --git a/src/xfns.c b/src/xfns.c index f00335b5d03..6fcd129e4a4 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -2949,6 +2949,12 @@ unwind_create_frame (Lisp_Object frame) return Qnil; } +static Lisp_Object +unwind_create_frame_1 (Lisp_Object val) +{ + inhibit_window_configuration_change_hook = val; + return Qnil; +} static void x_default_font_parameter (struct frame *f, Lisp_Object parms) @@ -3321,17 +3327,31 @@ This function is an internal primitive--use `make-frame' instead. */) happen. */ init_frame_faces (f); - /* The X resources controlling the menu-bar and tool-bar are - processed specially at startup, and reflected in the mode - variables; ignore them here. */ - x_default_parameter (f, parms, Qmenu_bar_lines, - NILP (Vmenu_bar_mode) - ? make_number (0) : make_number (1), - NULL, NULL, RES_TYPE_NUMBER); - x_default_parameter (f, parms, Qtool_bar_lines, - NILP (Vtool_bar_mode) - ? make_number (0) : make_number (1), - NULL, NULL, RES_TYPE_NUMBER); + /* Set the menu-bar-lines and tool-bar-lines parameters. We don't + look up the X resources controlling the menu-bar and tool-bar + here; they are processed specially at startup, and reflected in + the values of the mode variables. + + Avoid calling window-configuration-change-hook; otherwise we + could get an infloop in next_frame since the frame is not yet in + Vframe_list. */ + { + int count2 = SPECPDL_INDEX (); + record_unwind_protect (unwind_create_frame_1, + inhibit_window_configuration_change_hook); + inhibit_window_configuration_change_hook = Qt; + + x_default_parameter (f, parms, Qmenu_bar_lines, + NILP (Vmenu_bar_mode) + ? make_number (0) : make_number (1), + NULL, NULL, RES_TYPE_NUMBER); + x_default_parameter (f, parms, Qtool_bar_lines, + NILP (Vtool_bar_mode) + ? make_number (0) : make_number (1), + NULL, NULL, RES_TYPE_NUMBER); + + unbind_to (count2, Qnil); + } x_default_parameter (f, parms, Qbuffer_predicate, Qnil, "bufferPredicate", "BufferPredicate", -- cgit v1.2.1