aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in9
-rw-r--r--src/atimer.c11
-rw-r--r--src/bidi.c1
-rw-r--r--src/blockinput.h13
-rw-r--r--src/buffer.c1
-rw-r--r--src/bytecode.c5
-rw-r--r--src/callint.c1
-rw-r--r--src/callproc.c26
-rw-r--r--src/casefiddle.c2
-rw-r--r--src/casetab.c2
-rw-r--r--src/category.c1
-rw-r--r--src/ccl.c1
-rw-r--r--src/character.c1
-rw-r--r--src/charset.c1
-rw-r--r--src/chartab.c2
-rw-r--r--src/cm.c1
-rw-r--r--src/cmds.c2
-rw-r--r--src/coding.c1
-rw-r--r--src/composite.c1
-rw-r--r--src/conf_post.h17
-rw-r--r--src/data.c1
-rw-r--r--src/dbusbind.c2
-rw-r--r--src/dired.c1
-rw-r--r--src/dispextern.h1
-rw-r--r--src/dispnew.c3
-rw-r--r--src/doc.c1
-rw-r--r--src/doprnt.c1
-rw-r--r--src/dosfns.c2
-rw-r--r--src/editfns.c1
-rw-r--r--src/emacs.c19
-rw-r--r--src/emacsgtkfixed.c29
-rw-r--r--src/eval.c42
-rw-r--r--src/fileio.c1
-rw-r--r--src/filelock.c1
-rw-r--r--src/floatfns.c233
-rw-r--r--src/fns.c1
-rw-r--r--src/font.c68
-rw-r--r--src/fontset.c1
-rw-r--r--src/frame.c6
-rw-r--r--src/fringe.c1
-rw-r--r--src/ftfont.c2
-rw-r--r--src/ftxfont.c1
-rw-r--r--src/gnutls.c1
-rw-r--r--src/gtkutil.c1
-rw-r--r--src/image.c217
-rw-r--r--src/indent.c1
-rw-r--r--src/insdel.c32
-rw-r--r--src/intervals.c4
-rw-r--r--src/keyboard.c128
-rw-r--r--src/keymap.c2
-rw-r--r--src/lisp.h36
-rw-r--r--src/lread.c1
-rw-r--r--src/macros.c2
-rw-r--r--src/makefile.w32-in1
-rw-r--r--src/marker.c2
-rw-r--r--src/menu.c1
-rw-r--r--src/minibuf.c1
-rw-r--r--src/ns.mk39
-rw-r--r--src/nsfns.m14
-rw-r--r--src/nsfont.m1
-rw-r--r--src/nsimage.m1
-rw-r--r--src/nsmenu.m6
-rw-r--r--src/nsselect.m1
-rw-r--r--src/print.c2
-rw-r--r--src/process.c79
-rw-r--r--src/ralloc.c14
-rw-r--r--src/regex.c7
-rw-r--r--src/region-cache.c1
-rw-r--r--src/scroll.c2
-rw-r--r--src/search.c26
-rw-r--r--src/sheap.c3
-rw-r--r--src/sound.c14
-rw-r--r--src/syntax.c2
-rw-r--r--src/sysdep.c117
-rw-r--r--src/syssignal.h25
-rw-r--r--src/systty.h13
-rw-r--r--src/term.c4
-rw-r--r--src/termcap.c1
-rw-r--r--src/terminal.c1
-rw-r--r--src/terminfo.c1
-rw-r--r--src/textprop.c2
-rw-r--r--src/tparam.c2
-rw-r--r--src/undo.c2
-rw-r--r--src/unexaix.c1
-rw-r--r--src/unexcoff.c1
-rw-r--r--src/unexcw.c1
-rw-r--r--src/unexsol.c1
-rw-r--r--src/vm-limit.c1
-rw-r--r--src/w16select.c1
-rw-r--r--src/w32.c1
-rw-r--r--src/w32console.c1
-rw-r--r--src/w32fns.c1
-rw-r--r--src/w32font.c1
-rw-r--r--src/w32heap.c1
-rw-r--r--src/w32inevt.c1
-rw-r--r--src/w32menu.c1
-rw-r--r--src/w32proc.c1
-rw-r--r--src/w32reg.c1
-rw-r--r--src/w32select.c1
-rw-r--r--src/w32term.c2
-rw-r--r--src/w32uniscribe.c1
-rw-r--r--src/w32xfns.c1
-rw-r--r--src/widget.c2
-rw-r--r--src/window.c23
-rw-r--r--src/xdisp.c23
-rw-r--r--src/xfaces.c1
-rw-r--r--src/xfns.c1
-rw-r--r--src/xfont.c1
-rw-r--r--src/xftfont.c1
-rw-r--r--src/xgselect.c2
-rw-r--r--src/xmenu.c1
-rw-r--r--src/xml.c1
-rw-r--r--src/xrdb.c1
-rw-r--r--src/xselect.c1
-rw-r--r--src/xsettings.c5
-rw-r--r--src/xsmfns.c1
-rw-r--r--src/xterm.c18
117 files changed, 463 insertions, 966 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index a84fdd1caf8..cdae2c89fa1 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -264,9 +264,6 @@ MSDOS_OBJ =
264## w16select.o termcap.o if MSDOS && HAVE_X_WINDOWS. 264## w16select.o termcap.o if MSDOS && HAVE_X_WINDOWS.
265MSDOS_X_OBJ = 265MSDOS_X_OBJ =
266 266
267ns_appdir=@ns_appdir@
268ns_appbindir=@ns_appbindir@
269ns_appsrc=@ns_appsrc@
270NS_OBJ=@NS_OBJ@ 267NS_OBJ=@NS_OBJ@
271## nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o if HAVE_NS. 268## nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o if HAVE_NS.
272NS_OBJC_OBJ=@NS_OBJC_OBJ@ 269NS_OBJC_OBJ=@NS_OBJC_OBJ@
@@ -514,8 +511,9 @@ $(OLDXMENU): $(OLDXMENU_TARGET)
514doc.o: buildobj.h 511doc.o: buildobj.h
515 512
516 513
517## If HAVE_NS, some ns-specific rules (for OTHER_FILES) are inserted here. 514ns-app: emacs$(EXEEXT)
518@ns_frag@ 515 cd ../nextstep && $(MAKE) $(MFLAGS) all
516
519 517
520.PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean 518.PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
521.PHONY: versionclean extraclean frc 519.PHONY: versionclean extraclean frc
@@ -529,7 +527,6 @@ mostlyclean:
529clean: mostlyclean 527clean: mostlyclean
530 rm -f emacs-*.*.*$(EXEEXT) emacs$(EXEEXT) 528 rm -f emacs-*.*.*$(EXEEXT) emacs$(EXEEXT)
531 -rm -rf $(DEPDIR) 529 -rm -rf $(DEPDIR)
532 test "X$(ns_appdir)" = "X" || rm -rf $(ns_appdir)
533 530
534## bootstrap-clean is used to clean up just before a bootstrap. 531## bootstrap-clean is used to clean up just before a bootstrap.
535## It should remove all files generated during a compilation/bootstrap, 532## It should remove all files generated during a compilation/bootstrap,
diff --git a/src/atimer.c b/src/atimer.c
index 34731920af5..5dbd807872a 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -18,7 +18,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20#include <stdio.h> 20#include <stdio.h>
21#include <setjmp.h> 21
22#include "lisp.h" 22#include "lisp.h"
23#include "syssignal.h" 23#include "syssignal.h"
24#include "systime.h" 24#include "systime.h"
@@ -369,7 +369,6 @@ run_timers (void)
369 if (! atimers) 369 if (! atimers)
370 pending_atimers = 0; 370 pending_atimers = 0;
371 371
372#ifdef SYNC_INPUT
373 if (pending_atimers) 372 if (pending_atimers)
374 pending_signals = 1; 373 pending_signals = 1;
375 else 374 else
@@ -377,10 +376,6 @@ run_timers (void)
377 pending_signals = interrupt_input_pending; 376 pending_signals = interrupt_input_pending;
378 set_alarm (); 377 set_alarm ();
379 } 378 }
380#else
381 if (! pending_atimers)
382 set_alarm ();
383#endif
384} 379}
385 380
386 381
@@ -391,11 +386,7 @@ static void
391handle_alarm_signal (int sig) 386handle_alarm_signal (int sig)
392{ 387{
393 pending_atimers = 1; 388 pending_atimers = 1;
394#ifdef SYNC_INPUT
395 pending_signals = 1; 389 pending_signals = 1;
396#else
397 run_timers ();
398#endif
399} 390}
400 391
401static void 392static void
diff --git a/src/bidi.c b/src/bidi.c
index 4186a46e19e..af0209565e2 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -56,7 +56,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
56 56
57#include <config.h> 57#include <config.h>
58#include <stdio.h> 58#include <stdio.h>
59#include <setjmp.h>
60 59
61#include "lisp.h" 60#include "lisp.h"
62#include "character.h" 61#include "character.h"
diff --git a/src/blockinput.h b/src/blockinput.h
index 3f61b2b27b9..7501bfc91a0 100644
--- a/src/blockinput.h
+++ b/src/blockinput.h
@@ -67,15 +67,10 @@ extern int pending_atimers;
67 If doing signal-driven input, and a signal came in when input was 67 If doing signal-driven input, and a signal came in when input was
68 blocked, reinvoke the signal handler now to deal with it. 68 blocked, reinvoke the signal handler now to deal with it.
69 69
70 We used to have two possible definitions of this macro - one for 70 Always test interrupt_input_pending; that's not too expensive, and
71 when SIGIO was #defined, and one for when it wasn't; when SIGIO 71 it'll never get set if we don't need to resignal. This is simpler
72 wasn't #defined, we wouldn't bother to check if we should re-invoke 72 than dealing here with every configuration option that might affect
73 the signal handler. But that doesn't work very well; some of the 73 whether interrupt_input_pending can be nonzero. */
74 files which use this macro don't #include the right files to get
75 SIGIO.
76
77 So, we always test interrupt_input_pending now; that's not too
78 expensive, and it'll never get set if we don't need to resignal. */
79 74
80#define UNBLOCK_INPUT \ 75#define UNBLOCK_INPUT \
81 do \ 76 do \
diff --git a/src/buffer.c b/src/buffer.c
index d512547d34e..b020edb9962 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26#include <sys/param.h> 26#include <sys/param.h>
27#include <errno.h> 27#include <errno.h>
28#include <stdio.h> 28#include <stdio.h>
29#include <setjmp.h>
30#include <unistd.h> 29#include <unistd.h>
31 30
32#include <verify.h> 31#include <verify.h>
diff --git a/src/bytecode.c b/src/bytecode.c
index 97730636d0e..5f4fdcc5eff 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -33,7 +33,7 @@ by Hallvard:
33 */ 33 */
34 34
35#include <config.h> 35#include <config.h>
36#include <setjmp.h> 36
37#include "lisp.h" 37#include "lisp.h"
38#include "character.h" 38#include "character.h"
39#include "buffer.h" 39#include "buffer.h"
@@ -458,7 +458,8 @@ unmark_byte_stack (void)
458 Fsignal (Qquit, Qnil); \ 458 Fsignal (Qquit, Qnil); \
459 AFTER_POTENTIAL_GC (); \ 459 AFTER_POTENTIAL_GC (); \
460 } \ 460 } \
461 ELSE_PENDING_SIGNALS \ 461 else if (pending_signals) \
462 process_pending_signals (); \
462 } while (0) 463 } while (0)
463 464
464 465
diff --git a/src/callint.c b/src/callint.c
index b11545ddea2..c4c087e83d7 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h>
23 22
24#include "lisp.h" 23#include "lisp.h"
25#include "character.h" 24#include "character.h"
diff --git a/src/callproc.c b/src/callproc.c
index a92959a1559..2604d295f3e 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#include <config.h> 21#include <config.h>
22#include <errno.h> 22#include <errno.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25#include <sys/types.h> 24#include <sys/types.h>
26#include <unistd.h> 25#include <unistd.h>
27 26
@@ -497,11 +496,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
497 register char **save_environ = environ; 496 register char **save_environ = environ;
498 register int fd1 = fd[1]; 497 register int fd1 = fd[1];
499 int fd_error = fd1; 498 int fd_error = fd1;
500#ifdef HAVE_WORKING_VFORK
501 sigset_t procmask;
502 sigset_t blocked;
503 struct sigaction sigpipe_action;
504#endif
505 499
506 if (fd_output >= 0) 500 if (fd_output >= 0)
507 fd1 = fd_output; 501 fd1 = fd_output;
@@ -588,17 +582,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
588 0, current_dir); 582 0, current_dir);
589#else /* not WINDOWSNT */ 583#else /* not WINDOWSNT */
590 584
591#ifdef HAVE_WORKING_VFORK
592 /* On many hosts (e.g. Solaris 2.4), if a vforked child calls `signal',
593 this sets the parent's signal handlers as well as the child's.
594 So delay all interrupts whose handlers the child might munge,
595 and record the current handlers so they can be restored later. */
596 sigemptyset (&blocked);
597 sigaddset (&blocked, SIGPIPE);
598 sigaction (SIGPIPE, 0, &sigpipe_action);
599 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
600#endif
601
602 BLOCK_INPUT; 585 BLOCK_INPUT;
603 586
604 /* vfork, and prevent local vars from being clobbered by the vfork. */ 587 /* vfork, and prevent local vars from being clobbered by the vfork. */
@@ -646,9 +629,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
646 /* GConf causes us to ignore SIGPIPE, make sure it is restored 629 /* GConf causes us to ignore SIGPIPE, make sure it is restored
647 in the child. */ 630 in the child. */
648 signal (SIGPIPE, SIG_DFL); 631 signal (SIGPIPE, SIG_DFL);
649#ifdef HAVE_WORKING_VFORK
650 pthread_sigmask (SIG_SETMASK, &procmask, 0);
651#endif
652 632
653 child_setup (filefd, fd1, fd_error, (char **) new_argv, 633 child_setup (filefd, fd1, fd_error, (char **) new_argv,
654 0, current_dir); 634 0, current_dir);
@@ -656,12 +636,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
656 636
657 UNBLOCK_INPUT; 637 UNBLOCK_INPUT;
658 638
659#ifdef HAVE_WORKING_VFORK
660 /* Restore the signal state. */
661 sigaction (SIGPIPE, &sigpipe_action, 0);
662 pthread_sigmask (SIG_SETMASK, &procmask, 0);
663#endif
664
665#endif /* not WINDOWSNT */ 639#endif /* not WINDOWSNT */
666 640
667 /* The MSDOS case did this already. */ 641 /* The MSDOS case did this already. */
diff --git a/src/casefiddle.c b/src/casefiddle.c
index 1102054b153..e3654627576 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -19,7 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h> 22
23#include "lisp.h" 23#include "lisp.h"
24#include "character.h" 24#include "character.h"
25#include "buffer.h" 25#include "buffer.h"
diff --git a/src/casetab.c b/src/casetab.c
index 3e22d0d0b77..a84bc9202d0 100644
--- a/src/casetab.c
+++ b/src/casetab.c
@@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h> 22
23#include "lisp.h" 23#include "lisp.h"
24#include "character.h" 24#include "character.h"
25#include "buffer.h" 25#include "buffer.h"
diff --git a/src/category.c b/src/category.c
index 80dc6938d8b..01a6f54ad17 100644
--- a/src/category.c
+++ b/src/category.c
@@ -32,7 +32,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
32 32
33#define CATEGORY_INLINE EXTERN_INLINE 33#define CATEGORY_INLINE EXTERN_INLINE
34 34
35#include <setjmp.h>
36#include "lisp.h" 35#include "lisp.h"
37#include "character.h" 36#include "character.h"
38#include "buffer.h" 37#include "buffer.h"
diff --git a/src/ccl.c b/src/ccl.c
index dd37934451d..34cc1c98eea 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26#include <config.h> 26#include <config.h>
27 27
28#include <stdio.h> 28#include <stdio.h>
29#include <setjmp.h>
30#include <limits.h> 29#include <limits.h>
31 30
32#include "lisp.h" 31#include "lisp.h"
diff --git a/src/character.c b/src/character.c
index 37963d1878c..def1ad090fd 100644
--- a/src/character.c
+++ b/src/character.c
@@ -36,7 +36,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
36#ifdef emacs 36#ifdef emacs
37 37
38#include <sys/types.h> 38#include <sys/types.h>
39#include <setjmp.h>
40#include <intprops.h> 39#include <intprops.h>
41#include "lisp.h" 40#include "lisp.h"
42#include "character.h" 41#include "character.h"
diff --git a/src/charset.c b/src/charset.c
index 972a0598059..d8c38e5ea3b 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -32,7 +32,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
32#include <unistd.h> 32#include <unistd.h>
33#include <limits.h> 33#include <limits.h>
34#include <sys/types.h> 34#include <sys/types.h>
35#include <setjmp.h>
36#include <c-ctype.h> 35#include <c-ctype.h>
37#include "lisp.h" 36#include "lisp.h"
38#include "character.h" 37#include "character.h"
diff --git a/src/chartab.c b/src/chartab.c
index c14df0ebac6..e864514e336 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h> 22
23#include "lisp.h" 23#include "lisp.h"
24#include "character.h" 24#include "character.h"
25#include "charset.h" 25#include "charset.h"
diff --git a/src/cm.c b/src/cm.c
index 4b17b92eebc..eda6430bafa 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <setjmp.h>
24 23
25#include "lisp.h" 24#include "lisp.h"
26#include "frame.h" 25#include "frame.h"
diff --git a/src/cmds.c b/src/cmds.c
index 90d3cd6dced..45f7df948ae 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -19,7 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h> 22
23#include "lisp.h" 23#include "lisp.h"
24#include "commands.h" 24#include "commands.h"
25#include "character.h" 25#include "character.h"
diff --git a/src/coding.c b/src/coding.c
index 94a2d9fea80..4b3d22f956c 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -285,7 +285,6 @@ encode_coding_XXX (struct coding_system *coding)
285 285
286#include <config.h> 286#include <config.h>
287#include <stdio.h> 287#include <stdio.h>
288#include <setjmp.h>
289 288
290#include "lisp.h" 289#include "lisp.h"
291#include "character.h" 290#include "character.h"
diff --git a/src/composite.c b/src/composite.c
index eddabb66d33..ae46df0a573 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26 26
27#define COMPOSITE_INLINE EXTERN_INLINE 27#define COMPOSITE_INLINE EXTERN_INLINE
28 28
29#include <setjmp.h>
30#include "lisp.h" 29#include "lisp.h"
31#include "character.h" 30#include "character.h"
32#include "buffer.h" 31#include "buffer.h"
diff --git a/src/conf_post.h b/src/conf_post.h
index 1bf40af260b..0c4d029bc5d 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -90,7 +90,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
90char *_getpty(); 90char *_getpty();
91#endif 91#endif
92 92
93#undef SA_RESTART /* not the same as defining BROKEN_SA_RESTART */
94#endif /* IRIX6_5 */ 93#endif /* IRIX6_5 */
95 94
96#ifdef MSDOS 95#ifdef MSDOS
@@ -133,22 +132,6 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
133#endif 132#endif
134#endif /* MSDOS */ 133#endif /* MSDOS */
135 134
136#ifdef USG5_4
137/* Get FIONREAD from <sys/filio.h>. Get <sys/ttold.h> to get struct tchars.
138 But get <termio.h> first to make sure ttold.h doesn't interfere. */
139#include <sys/wait.h>
140
141#ifdef emacs
142#include <sys/filio.h>
143#include <termio.h>
144#include <sys/ttold.h>
145#include <signal.h>
146#include <sys/stream.h>
147#include <sys/stropts.h>
148#include <sys/termios.h>
149#endif
150#endif /* USG5_4 */
151
152/* Mac OS X / GNUstep need a bit more pure memory. Of the existing knobs, 135/* Mac OS X / GNUstep need a bit more pure memory. Of the existing knobs,
153 SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems. */ 136 SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems. */
154#ifdef HAVE_NS 137#ifdef HAVE_NS
diff --git a/src/data.c b/src/data.c
index 5d7f036b70d..72d7c8ccf9a 100644
--- a/src/data.c
+++ b/src/data.c
@@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <setjmp.h>
24 23
25#include <intprops.h> 24#include <intprops.h>
26 25
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 901820648cb..c2eefd605bb 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#ifdef HAVE_DBUS 21#ifdef HAVE_DBUS
22#include <stdio.h> 22#include <stdio.h>
23#include <dbus/dbus.h> 23#include <dbus/dbus.h>
24#include <setjmp.h> 24
25#include "lisp.h" 25#include "lisp.h"
26#include "frame.h" 26#include "frame.h"
27#include "termhooks.h" 27#include "termhooks.h"
diff --git a/src/dired.c b/src/dired.c
index 9af5f76821b..3aa27ecf920 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22#include <stdio.h> 22#include <stdio.h>
23#include <sys/types.h> 23#include <sys/types.h>
24#include <sys/stat.h> 24#include <sys/stat.h>
25#include <setjmp.h>
26 25
27#ifdef HAVE_PWD_H 26#ifdef HAVE_PWD_H
28#include <pwd.h> 27#include <pwd.h>
diff --git a/src/dispextern.h b/src/dispextern.h
index 11243d23db9..6f5cd55504b 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3221,6 +3221,7 @@ void unrequest_sigio (void);
3221int tabs_safe_p (int); 3221int tabs_safe_p (int);
3222void init_baud_rate (int); 3222void init_baud_rate (int);
3223void init_sigio (int); 3223void init_sigio (int);
3224void ignore_sigio (void);
3224 3225
3225/* Defined in xfaces.c */ 3226/* Defined in xfaces.c */
3226 3227
diff --git a/src/dispnew.c b/src/dispnew.c
index bc9141a575d..9cc7349f1b0 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#define DISPEXTERN_INLINE EXTERN_INLINE 21#define DISPEXTERN_INLINE EXTERN_INLINE
22 22
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25#include <unistd.h> 24#include <unistd.h>
26 25
27#include "lisp.h" 26#include "lisp.h"
@@ -5982,7 +5981,7 @@ sit_for (Lisp_Object timeout, bool reading, int do_display)
5982 wrong_type_argument (Qnumberp, timeout); 5981 wrong_type_argument (Qnumberp, timeout);
5983 5982
5984 5983
5985#ifdef SIGIO 5984#ifdef USABLE_SIGIO
5986 gobble_input (0); 5985 gobble_input (0);
5987#endif 5986#endif
5988 5987
diff --git a/src/doc.c b/src/doc.c
index 02a5b4b8143..d2d664df266 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22 22
23#include <sys/types.h> 23#include <sys/types.h>
24#include <sys/file.h> /* Must be after sys/types.h for USG*/ 24#include <sys/file.h> /* Must be after sys/types.h for USG*/
25#include <setjmp.h>
26#include <fcntl.h> 25#include <fcntl.h>
27#include <unistd.h> 26#include <unistd.h>
28 27
diff --git a/src/doprnt.c b/src/doprnt.c
index 3b7391f07d4..caa56d6ae88 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -102,7 +102,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
102 102
103#include <config.h> 103#include <config.h>
104#include <stdio.h> 104#include <stdio.h>
105#include <setjmp.h>
106#include <float.h> 105#include <float.h>
107#include <unistd.h> 106#include <unistd.h>
108#include <limits.h> 107#include <limits.h>
diff --git a/src/dosfns.c b/src/dosfns.c
index 21676f4b4f5..3c649f4d534 100644
--- a/src/dosfns.c
+++ b/src/dosfns.c
@@ -30,7 +30,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
30#include <dos.h> 30#include <dos.h>
31#undef gettime 31#undef gettime
32#undef settime 32#undef settime
33#include <setjmp.h> 33
34#include "lisp.h" 34#include "lisp.h"
35#include "character.h" 35#include "character.h"
36#include "buffer.h" 36#include "buffer.h"
diff --git a/src/editfns.c b/src/editfns.c
index 299cad07fd7..c6744648bc5 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#include <config.h> 21#include <config.h>
22#include <sys/types.h> 22#include <sys/types.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25 24
26#ifdef HAVE_PWD_H 25#ifdef HAVE_PWD_H
27#include <pwd.h> 26#include <pwd.h>
diff --git a/src/emacs.c b/src/emacs.c
index d0e2f1e021d..7e4f25abe6e 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -25,7 +25,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25 25
26#include <sys/types.h> 26#include <sys/types.h>
27#include <sys/file.h> 27#include <sys/file.h>
28#include <setjmp.h>
29#include <unistd.h> 28#include <unistd.h>
30 29
31#include "lisp.h" 30#include "lisp.h"
@@ -92,7 +91,7 @@ extern void moncontrol (int mode);
92#endif 91#endif
93 92
94static const char emacs_version[] = VERSION; 93static const char emacs_version[] = VERSION;
95static const char emacs_copyright[] = "Copyright (C) 2012 Free Software Foundation, Inc."; 94static const char emacs_copyright[] = COPYRIGHT;
96 95
97/* Empty lisp strings. To avoid having to build any others. */ 96/* Empty lisp strings. To avoid having to build any others. */
98Lisp_Object empty_unibyte_string, empty_multibyte_string; 97Lisp_Object empty_unibyte_string, empty_multibyte_string;
@@ -852,14 +851,10 @@ main (int argc, char **argv)
852 /* Arrange to get warning messages as memory fills up. */ 851 /* Arrange to get warning messages as memory fills up. */
853 memory_warnings (0, malloc_warning); 852 memory_warnings (0, malloc_warning);
854 853
855 /* Call malloc at least once, to run the initial __malloc_hook. 854 /* Call malloc at least once, to run malloc_initialize_hook.
856 Also call realloc and free for consistency. */ 855 Also call realloc and free for consistency. */
857 free (realloc (malloc (4), 4)); 856 free (realloc (malloc (4), 4));
858 857
859# ifndef SYNC_INPUT
860 /* Arrange to disable interrupt input inside malloc etc. */
861 uninterrupt_malloc ();
862# endif /* not SYNC_INPUT */
863#endif /* not SYSTEM_MALLOC */ 858#endif /* not SYSTEM_MALLOC */
864 859
865#if defined (MSDOS) || defined (WINDOWSNT) 860#if defined (MSDOS) || defined (WINDOWSNT)
@@ -2041,12 +2036,10 @@ shut_down_emacs (int sig, Lisp_Object stuff)
2041 unlock_all_files (); 2036 unlock_all_files ();
2042#endif 2037#endif
2043 2038
2044#ifdef SIGIO
2045 /* There is a tendency for a SIGIO signal to arrive within exit, 2039 /* There is a tendency for a SIGIO signal to arrive within exit,
2046 and cause a SIGHUP because the input descriptor is already closed. */ 2040 and cause a SIGHUP because the input descriptor is already closed. */
2047 unrequest_sigio (); 2041 unrequest_sigio ();
2048 signal (SIGIO, SIG_IGN); 2042 ignore_sigio ();
2049#endif
2050 2043
2051#ifdef WINDOWSNT 2044#ifdef WINDOWSNT
2052 term_ntproc (); 2045 term_ntproc ();
@@ -2152,12 +2145,6 @@ You must run Emacs in batch mode in order to dump it. */)
2152 memory_warnings (my_edata, malloc_warning); 2145 memory_warnings (my_edata, malloc_warning);
2153 } 2146 }
2154#endif /* not WINDOWSNT */ 2147#endif /* not WINDOWSNT */
2155#if defined (HAVE_PTHREAD) && !defined SYNC_INPUT
2156 /* Pthread may call malloc before main, and then we will get an endless
2157 loop, because pthread_self (see alloc.c) calls malloc the first time
2158 it is called on some systems. */
2159 reset_malloc_hooks ();
2160#endif
2161#endif /* not SYSTEM_MALLOC */ 2148#endif /* not SYSTEM_MALLOC */
2162#ifdef DOUG_LEA_MALLOC 2149#ifdef DOUG_LEA_MALLOC
2163 malloc_state_ptr = malloc_get_state (); 2150 malloc_state_ptr = malloc_get_state ();
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index 5f90a5b90aa..d23f3e21f24 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.c
@@ -22,13 +22,40 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22 22
23#include "emacsgtkfixed.h" 23#include "emacsgtkfixed.h"
24#include <stdio.h> 24#include <stdio.h>
25#include <setjmp.h> 25
26#include "lisp.h" 26#include "lisp.h"
27#include "frame.h" 27#include "frame.h"
28#include "xterm.h" 28#include "xterm.h"
29#ifdef HAVE_XWIDGETS 29#ifdef HAVE_XWIDGETS
30#include "xwidget.h" 30#include "xwidget.h"
31#endif 31#endif
32/* Silence a bogus diagnostic; see GNOME bug 683906. */
33#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
34# pragma GCC diagnostic push
35# pragma GCC diagnostic ignored "-Wunused-local-typedefs"
36#endif
37
38#define EMACS_TYPE_FIXED emacs_fixed_get_type ()
39#define EMACS_FIXED(obj) \
40 G_TYPE_CHECK_INSTANCE_CAST (obj, EMACS_TYPE_FIXED, EmacsFixed)
41
42typedef struct _EmacsFixed EmacsFixed;
43typedef struct _EmacsFixedPrivate EmacsFixedPrivate;
44typedef struct _EmacsFixedClass EmacsFixedClass;
45
46struct _EmacsFixed
47{
48 GtkFixed container;
49
50 /*< private >*/
51 EmacsFixedPrivate *priv;
52};
53
54struct _EmacsFixedClass
55{
56 GtkFixedClass parent_class;
57};
58
32struct _EmacsFixedPrivate 59struct _EmacsFixedPrivate
33{ 60{
34 struct frame *f; 61 struct frame *f;
diff --git a/src/eval.c b/src/eval.c
index 8a8a507a1b6..1c565e233c6 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20#include <config.h> 20#include <config.h>
21#include <limits.h> 21#include <limits.h>
22#include <setjmp.h>
23#include <stdio.h> 22#include <stdio.h>
24#include "lisp.h" 23#include "lisp.h"
25#include "blockinput.h" 24#include "blockinput.h"
@@ -118,12 +117,6 @@ static EMACS_INT when_entered_debugger;
118 117
119Lisp_Object Vsignaling_function; 118Lisp_Object Vsignaling_function;
120 119
121/* Set to non-zero while processing X events. Checked in Feval to
122 make sure the Lisp interpreter isn't called from a signal handler,
123 which is unsafe because the interpreter isn't reentrant. */
124
125int handling_signal;
126
127/* If non-nil, Lisp code must not be run since some part of Emacs is 120/* If non-nil, Lisp code must not be run since some part of Emacs is
128 in an inconsistent state. Currently, x-create-frame uses this to 121 in an inconsistent state. Currently, x-create-frame uses this to
129 avoid triggering window-configuration-change-hook while the new 122 avoid triggering window-configuration-change-hook while the new
@@ -707,7 +700,7 @@ usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */)
707 else 700 else
708 { /* Check if there is really a global binding rather than just a let 701 { /* Check if there is really a global binding rather than just a let
709 binding that shadows the global unboundness of the var. */ 702 binding that shadows the global unboundness of the var. */
710 volatile struct specbinding *pdl = specpdl_ptr; 703 struct specbinding *pdl = specpdl_ptr;
711 while (pdl > specpdl) 704 while (pdl > specpdl)
712 { 705 {
713 if (EQ ((--pdl)->symbol, sym) && !pdl->func 706 if (EQ ((--pdl)->symbol, sym) && !pdl->func
@@ -1072,7 +1065,7 @@ internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object
1072 catchlist = &c; 1065 catchlist = &c;
1073 1066
1074 /* Call FUNC. */ 1067 /* Call FUNC. */
1075 if (! _setjmp (c.jmp)) 1068 if (! sys_setjmp (c.jmp))
1076 c.val = (*func) (arg); 1069 c.val = (*func) (arg);
1077 1070
1078 /* Throw works by a longjmp that comes right here. */ 1071 /* Throw works by a longjmp that comes right here. */
@@ -1107,7 +1100,6 @@ unwind_to_catch (struct catchtag *catch, Lisp_Object value)
1107 /* Restore certain special C variables. */ 1100 /* Restore certain special C variables. */
1108 set_poll_suppress_count (catch->poll_suppress_count); 1101 set_poll_suppress_count (catch->poll_suppress_count);
1109 UNBLOCK_INPUT_TO (catch->interrupt_input_blocked); 1102 UNBLOCK_INPUT_TO (catch->interrupt_input_blocked);
1110 handling_signal = 0;
1111 immediate_quit = 0; 1103 immediate_quit = 0;
1112 1104
1113 do 1105 do
@@ -1140,7 +1132,7 @@ unwind_to_catch (struct catchtag *catch, Lisp_Object value)
1140 backtrace_list = catch->backlist; 1132 backtrace_list = catch->backlist;
1141 lisp_eval_depth = catch->lisp_eval_depth; 1133 lisp_eval_depth = catch->lisp_eval_depth;
1142 1134
1143 _longjmp (catch->jmp, 1); 1135 sys_longjmp (catch->jmp, 1);
1144} 1136}
1145 1137
1146DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0, 1138DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0,
@@ -1204,12 +1196,9 @@ See also the function `signal' for more info.
1204usage: (condition-case VAR BODYFORM &rest HANDLERS) */) 1196usage: (condition-case VAR BODYFORM &rest HANDLERS) */)
1205 (Lisp_Object args) 1197 (Lisp_Object args)
1206{ 1198{
1207 register Lisp_Object bodyform, handlers; 1199 Lisp_Object var = Fcar (args);
1208 volatile Lisp_Object var; 1200 Lisp_Object bodyform = Fcar (Fcdr (args));
1209 1201 Lisp_Object handlers = Fcdr (Fcdr (args));
1210 var = Fcar (args);
1211 bodyform = Fcar (Fcdr (args));
1212 handlers = Fcdr (Fcdr (args));
1213 1202
1214 return internal_lisp_condition_case (var, bodyform, handlers); 1203 return internal_lisp_condition_case (var, bodyform, handlers);
1215} 1204}
@@ -1249,7 +1238,7 @@ internal_lisp_condition_case (volatile Lisp_Object var, Lisp_Object bodyform,
1249 c.interrupt_input_blocked = interrupt_input_blocked; 1238 c.interrupt_input_blocked = interrupt_input_blocked;
1250 c.gcpro = gcprolist; 1239 c.gcpro = gcprolist;
1251 c.byte_stack = byte_stack_list; 1240 c.byte_stack = byte_stack_list;
1252 if (_setjmp (c.jmp)) 1241 if (sys_setjmp (c.jmp))
1253 { 1242 {
1254 if (!NILP (h.var)) 1243 if (!NILP (h.var))
1255 specbind (h.var, c.val); 1244 specbind (h.var, c.val);
@@ -1304,7 +1293,7 @@ internal_condition_case (Lisp_Object (*bfun) (void), Lisp_Object handlers,
1304 c.interrupt_input_blocked = interrupt_input_blocked; 1293 c.interrupt_input_blocked = interrupt_input_blocked;
1305 c.gcpro = gcprolist; 1294 c.gcpro = gcprolist;
1306 c.byte_stack = byte_stack_list; 1295 c.byte_stack = byte_stack_list;
1307 if (_setjmp (c.jmp)) 1296 if (sys_setjmp (c.jmp))
1308 { 1297 {
1309 return (*hfun) (c.val); 1298 return (*hfun) (c.val);
1310 } 1299 }
@@ -1342,7 +1331,7 @@ internal_condition_case_1 (Lisp_Object (*bfun) (Lisp_Object), Lisp_Object arg,
1342 c.interrupt_input_blocked = interrupt_input_blocked; 1331 c.interrupt_input_blocked = interrupt_input_blocked;
1343 c.gcpro = gcprolist; 1332 c.gcpro = gcprolist;
1344 c.byte_stack = byte_stack_list; 1333 c.byte_stack = byte_stack_list;
1345 if (_setjmp (c.jmp)) 1334 if (sys_setjmp (c.jmp))
1346 { 1335 {
1347 return (*hfun) (c.val); 1336 return (*hfun) (c.val);
1348 } 1337 }
@@ -1384,7 +1373,7 @@ internal_condition_case_2 (Lisp_Object (*bfun) (Lisp_Object, Lisp_Object),
1384 c.interrupt_input_blocked = interrupt_input_blocked; 1373 c.interrupt_input_blocked = interrupt_input_blocked;
1385 c.gcpro = gcprolist; 1374 c.gcpro = gcprolist;
1386 c.byte_stack = byte_stack_list; 1375 c.byte_stack = byte_stack_list;
1387 if (_setjmp (c.jmp)) 1376 if (sys_setjmp (c.jmp))
1388 { 1377 {
1389 return (*hfun) (c.val); 1378 return (*hfun) (c.val);
1390 } 1379 }
@@ -1428,7 +1417,7 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *),
1428 c.interrupt_input_blocked = interrupt_input_blocked; 1417 c.interrupt_input_blocked = interrupt_input_blocked;
1429 c.gcpro = gcprolist; 1418 c.gcpro = gcprolist;
1430 c.byte_stack = byte_stack_list; 1419 c.byte_stack = byte_stack_list;
1431 if (_setjmp (c.jmp)) 1420 if (sys_setjmp (c.jmp))
1432 { 1421 {
1433 return (*hfun) (c.val, nargs, args); 1422 return (*hfun) (c.val, nargs, args);
1434 } 1423 }
@@ -1490,7 +1479,7 @@ See also the function `condition-case'. */)
1490 struct handler *h; 1479 struct handler *h;
1491 struct backtrace *bp; 1480 struct backtrace *bp;
1492 1481
1493 immediate_quit = handling_signal = 0; 1482 immediate_quit = 0;
1494 abort_on_gc = 0; 1483 abort_on_gc = 0;
1495 if (gc_in_progress || waiting_for_input) 1484 if (gc_in_progress || waiting_for_input)
1496 emacs_abort (); 1485 emacs_abort ();
@@ -2043,9 +2032,6 @@ eval_sub (Lisp_Object form)
2043 struct backtrace backtrace; 2032 struct backtrace backtrace;
2044 struct gcpro gcpro1, gcpro2, gcpro3; 2033 struct gcpro gcpro1, gcpro2, gcpro3;
2045 2034
2046 if (handling_signal)
2047 emacs_abort ();
2048
2049 if (SYMBOLP (form)) 2035 if (SYMBOLP (form))
2050 { 2036 {
2051 /* Look up its binding in the lexical environment. 2037 /* Look up its binding in the lexical environment.
@@ -3108,8 +3094,6 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3108{ 3094{
3109 struct Lisp_Symbol *sym; 3095 struct Lisp_Symbol *sym;
3110 3096
3111 eassert (!handling_signal);
3112
3113 CHECK_SYMBOL (symbol); 3097 CHECK_SYMBOL (symbol);
3114 sym = XSYMBOL (symbol); 3098 sym = XSYMBOL (symbol);
3115 if (specpdl_ptr == specpdl + specpdl_size) 3099 if (specpdl_ptr == specpdl + specpdl_size)
@@ -3203,8 +3187,6 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3203void 3187void
3204record_unwind_protect (Lisp_Object (*function) (Lisp_Object), Lisp_Object arg) 3188record_unwind_protect (Lisp_Object (*function) (Lisp_Object), Lisp_Object arg)
3205{ 3189{
3206 eassert (!handling_signal);
3207
3208 if (specpdl_ptr == specpdl + specpdl_size) 3190 if (specpdl_ptr == specpdl + specpdl_size)
3209 grow_specpdl (); 3191 grow_specpdl ();
3210 specpdl_ptr->func = function; 3192 specpdl_ptr->func = function;
diff --git a/src/fileio.c b/src/fileio.c
index f0b3f0cc2fd..ca71af7ed95 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23#include <stdio.h> 23#include <stdio.h>
24#include <sys/types.h> 24#include <sys/types.h>
25#include <sys/stat.h> 25#include <sys/stat.h>
26#include <setjmp.h>
27#include <unistd.h> 26#include <unistd.h>
28 27
29#ifdef HAVE_PWD_H 28#ifdef HAVE_PWD_H
diff --git a/src/filelock.c b/src/filelock.c
index 1f599c68912..17f3f253249 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23#include <sys/stat.h> 23#include <sys/stat.h>
24#include <signal.h> 24#include <signal.h>
25#include <stdio.h> 25#include <stdio.h>
26#include <setjmp.h>
27 26
28#ifdef HAVE_PWD_H 27#ifdef HAVE_PWD_H
29#include <pwd.h> 28#include <pwd.h>
diff --git a/src/floatfns.c b/src/floatfns.c
index 8a9a9fd0886..4fe209fcb61 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -22,13 +22,14 @@ You should have received a copy of the GNU General Public License
22along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 22along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23 23
24 24
25/* C89 requires only these math.h functions: 25/* C89 requires only the following math.h functions, and Emacs omits
26 acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, fmod, 26 the starred functions since we haven't found a use for them:
27 frexp, ldexp, log, log10, modf, pow, sin, sinh, sqrt, tan, tanh. 27 acos, asin, atan, atan2, ceil, cos, *cosh, exp, fabs, floor, fmod,
28 frexp, ldexp, log, log10, *modf, pow, sin, *sinh, sqrt, tan, *tanh.
28 */ 29 */
29 30
30#include <config.h> 31#include <config.h>
31#include <setjmp.h> 32
32#include "lisp.h" 33#include "lisp.h"
33#include "syssignal.h" 34#include "syssignal.h"
34 35
@@ -42,10 +43,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
42 43
43#include <math.h> 44#include <math.h>
44 45
45/* This declaration is omitted on some systems, like Ultrix. */ 46#ifndef isfinite
46#if !defined (HPUX) && defined (HAVE_LOGB) && !defined (logb) 47# define isfinite(x) ((x) - (x) == 0)
47extern double logb (double); 48#endif
48#endif /* not HPUX and HAVE_LOGB and no logb macro */ 49#ifndef isnan
50# define isnan(x) ((x) != (x))
51#endif
49 52
50/* Extract a Lisp number as a `double', or signal an error. */ 53/* Extract a Lisp number as a `double', or signal an error. */
51 54
@@ -126,9 +129,6 @@ DEFUN ("tan", Ftan, Stan, 1, 1, 0,
126 return make_float (d); 129 return make_float (d);
127} 130}
128 131
129#undef isnan
130#define isnan(x) ((x) != (x))
131
132DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0, 132DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0,
133 doc: /* Return non nil iff argument X is a NaN. */) 133 doc: /* Return non nil iff argument X is a NaN. */)
134 (Lisp_Object x) 134 (Lisp_Object x)
@@ -153,6 +153,7 @@ Cause an error if X1 or X2 is not a float. */)
153 153
154 return make_float (copysign (f1, f2)); 154 return make_float (copysign (f1, f2));
155} 155}
156#endif
156 157
157DEFUN ("frexp", Ffrexp, Sfrexp, 1, 1, 0, 158DEFUN ("frexp", Ffrexp, Sfrexp, 1, 1, 0,
158 doc: /* Get significand and exponent of a floating point number. 159 doc: /* Get significand and exponent of a floating point number.
@@ -167,15 +168,9 @@ If X is zero, both parts (SGNFCAND and EXP) are zero. */)
167 (Lisp_Object x) 168 (Lisp_Object x)
168{ 169{
169 double f = XFLOATINT (x); 170 double f = XFLOATINT (x);
170 171 int exponent;
171 if (f == 0.0) 172 double sgnfcand = frexp (f, &exponent);
172 return Fcons (make_float (0.0), make_number (0)); 173 return Fcons (make_float (sgnfcand), make_number (exponent));
173 else
174 {
175 int exponent;
176 double sgnfcand = frexp (f, &exponent);
177 return Fcons (make_float (sgnfcand), make_number (exponent));
178 }
179} 174}
180 175
181DEFUN ("ldexp", Fldexp, Sldexp, 1, 2, 0, 176DEFUN ("ldexp", Fldexp, Sldexp, 1, 2, 0,
@@ -187,118 +182,6 @@ Returns the floating point value resulting from multiplying SGNFCAND
187 CHECK_NUMBER (exponent); 182 CHECK_NUMBER (exponent);
188 return make_float (ldexp (XFLOATINT (sgnfcand), XINT (exponent))); 183 return make_float (ldexp (XFLOATINT (sgnfcand), XINT (exponent)));
189} 184}
190#endif
191
192#if 0 /* Leave these out unless we find there's a reason for them. */
193
194DEFUN ("bessel-j0", Fbessel_j0, Sbessel_j0, 1, 1, 0,
195 doc: /* Return the bessel function j0 of ARG. */)
196 (Lisp_Object arg)
197{
198 double d = extract_float (arg);
199 d = j0 (d);
200 return make_float (d);
201}
202
203DEFUN ("bessel-j1", Fbessel_j1, Sbessel_j1, 1, 1, 0,
204 doc: /* Return the bessel function j1 of ARG. */)
205 (Lisp_Object arg)
206{
207 double d = extract_float (arg);
208 d = j1 (d);
209 return make_float (d);
210}
211
212DEFUN ("bessel-jn", Fbessel_jn, Sbessel_jn, 2, 2, 0,
213 doc: /* Return the order N bessel function output jn of ARG.
214The first arg (the order) is truncated to an integer. */)
215 (Lisp_Object n, Lisp_Object arg)
216{
217 int i1 = extract_float (n);
218 double f2 = extract_float (arg);
219
220 f2 = jn (i1, f2);
221 return make_float (f2);
222}
223
224DEFUN ("bessel-y0", Fbessel_y0, Sbessel_y0, 1, 1, 0,
225 doc: /* Return the bessel function y0 of ARG. */)
226 (Lisp_Object arg)
227{
228 double d = extract_float (arg);
229 d = y0 (d);
230 return make_float (d);
231}
232
233DEFUN ("bessel-y1", Fbessel_y1, Sbessel_y1, 1, 1, 0,
234 doc: /* Return the bessel function y1 of ARG. */)
235 (Lisp_Object arg)
236{
237 double d = extract_float (arg);
238 d = y1 (d);
239 return make_float (d);
240}
241
242DEFUN ("bessel-yn", Fbessel_yn, Sbessel_yn, 2, 2, 0,
243 doc: /* Return the order N bessel function output yn of ARG.
244The first arg (the order) is truncated to an integer. */)
245 (Lisp_Object n, Lisp_Object arg)
246{
247 int i1 = extract_float (n);
248 double f2 = extract_float (arg);
249
250 f2 = yn (i1, f2);
251 return make_float (f2);
252}
253
254#endif
255
256#if 0 /* Leave these out unless we see they are worth having. */
257
258DEFUN ("erf", Ferf, Serf, 1, 1, 0,
259 doc: /* Return the mathematical error function of ARG. */)
260 (Lisp_Object arg)
261{
262 double d = extract_float (arg);
263 d = erf (d);
264 return make_float (d);
265}
266
267DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0,
268 doc: /* Return the complementary error function of ARG. */)
269 (Lisp_Object arg)
270{
271 double d = extract_float (arg);
272 d = erfc (d);
273 return make_float (d);
274}
275
276DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0,
277 doc: /* Return the log gamma of ARG. */)
278 (Lisp_Object arg)
279{
280 double d = extract_float (arg);
281 d = lgamma (d);
282 return make_float (d);
283}
284
285DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0,
286 doc: /* Return the cube root of ARG. */)
287 (Lisp_Object arg)
288{
289 double d = extract_float (arg);
290#ifdef HAVE_CBRT
291 d = cbrt (d);
292#else
293 if (d >= 0.0)
294 d = pow (d, 1.0/3.0);
295 else
296 d = -pow (-d, 1.0/3.0);
297#endif
298 return make_float (d);
299}
300
301#endif
302 185
303DEFUN ("exp", Fexp, Sexp, 1, 1, 0, 186DEFUN ("exp", Fexp, Sexp, 1, 1, 0,
304 doc: /* Return the exponential base e of ARG. */) 187 doc: /* Return the exponential base e of ARG. */)
@@ -383,63 +266,6 @@ DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0,
383 return make_float (d); 266 return make_float (d);
384} 267}
385 268
386#if 0 /* Not clearly worth adding. */
387
388DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0,
389 doc: /* Return the inverse hyperbolic cosine of ARG. */)
390 (Lisp_Object arg)
391{
392 double d = extract_float (arg);
393 d = acosh (d);
394 return make_float (d);
395}
396
397DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0,
398 doc: /* Return the inverse hyperbolic sine of ARG. */)
399 (Lisp_Object arg)
400{
401 double d = extract_float (arg);
402 d = asinh (d);
403 return make_float (d);
404}
405
406DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0,
407 doc: /* Return the inverse hyperbolic tangent of ARG. */)
408 (Lisp_Object arg)
409{
410 double d = extract_float (arg);
411 d = atanh (d);
412 return make_float (d);
413}
414
415DEFUN ("cosh", Fcosh, Scosh, 1, 1, 0,
416 doc: /* Return the hyperbolic cosine of ARG. */)
417 (Lisp_Object arg)
418{
419 double d = extract_float (arg);
420 d = cosh (d);
421 return make_float (d);
422}
423
424DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0,
425 doc: /* Return the hyperbolic sine of ARG. */)
426 (Lisp_Object arg)
427{
428 double d = extract_float (arg);
429 d = sinh (d);
430 return make_float (d);
431}
432
433DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0,
434 doc: /* Return the hyperbolic tangent of ARG. */)
435 (Lisp_Object arg)
436{
437 double d = extract_float (arg);
438 d = tanh (d);
439 return make_float (d);
440}
441#endif
442
443DEFUN ("abs", Fabs, Sabs, 1, 1, 0, 269DEFUN ("abs", Fabs, Sabs, 1, 1, 0,
444 doc: /* Return the absolute value of ARG. */) 270 doc: /* Return the absolute value of ARG. */)
445 (register Lisp_Object arg) 271 (register Lisp_Object arg)
@@ -477,16 +303,15 @@ This is the same as the exponent of a float. */)
477 303
478 if (f == 0.0) 304 if (f == 0.0)
479 value = MOST_NEGATIVE_FIXNUM; 305 value = MOST_NEGATIVE_FIXNUM;
480 else 306 else if (isfinite (f))
481 { 307 {
482#ifdef HAVE_LOGB
483 value = logb (f);
484#else
485 int ivalue; 308 int ivalue;
486 frexp (f, &ivalue); 309 frexp (f, &ivalue);
487 value = ivalue - 1; 310 value = ivalue - 1;
488#endif
489 } 311 }
312 else
313 value = MOST_POSITIVE_FIXNUM;
314
490 XSETINT (val, value); 315 XSETINT (val, value);
491 return val; 316 return val;
492} 317}
@@ -719,27 +544,9 @@ syms_of_floatfns (void)
719 defsubr (&Sisnan); 544 defsubr (&Sisnan);
720#ifdef HAVE_COPYSIGN 545#ifdef HAVE_COPYSIGN
721 defsubr (&Scopysign); 546 defsubr (&Scopysign);
547#endif
722 defsubr (&Sfrexp); 548 defsubr (&Sfrexp);
723 defsubr (&Sldexp); 549 defsubr (&Sldexp);
724#endif
725#if 0
726 defsubr (&Sacosh);
727 defsubr (&Sasinh);
728 defsubr (&Satanh);
729 defsubr (&Scosh);
730 defsubr (&Ssinh);
731 defsubr (&Stanh);
732 defsubr (&Sbessel_y0);
733 defsubr (&Sbessel_y1);
734 defsubr (&Sbessel_yn);
735 defsubr (&Sbessel_j0);
736 defsubr (&Sbessel_j1);
737 defsubr (&Sbessel_jn);
738 defsubr (&Serf);
739 defsubr (&Serfc);
740 defsubr (&Slog_gamma);
741 defsubr (&Scube_root);
742#endif
743 defsubr (&Sfceiling); 550 defsubr (&Sfceiling);
744 defsubr (&Sffloor); 551 defsubr (&Sffloor);
745 defsubr (&Sfround); 552 defsubr (&Sfround);
diff --git a/src/fns.c b/src/fns.c
index 91dc6639150..42c4f817f29 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#include <unistd.h> 22#include <unistd.h>
23#include <time.h> 23#include <time.h>
24#include <setjmp.h>
25 24
26#include <intprops.h> 25#include <intprops.h>
27 26
diff --git a/src/font.c b/src/font.c
index 49a09bced28..1f22fee88ee 100644
--- a/src/font.c
+++ b/src/font.c
@@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23#include <config.h> 23#include <config.h>
24#include <float.h> 24#include <float.h>
25#include <stdio.h> 25#include <stdio.h>
26#include <setjmp.h>
27 26
28#include <c-ctype.h> 27#include <c-ctype.h>
29 28
@@ -4296,12 +4295,15 @@ to get the correct visual image of character sequences set in the
4296header of the glyph-string. 4295header of the glyph-string.
4297 4296
4298If the shaping was successful, the value is GSTRING itself or a newly 4297If the shaping was successful, the value is GSTRING itself or a newly
4299created glyph-string. Otherwise, the value is nil. */) 4298created glyph-string. Otherwise, the value is nil.
4299
4300See the documentation of `composition-get-gstring' for the format of
4301GSTRING. */)
4300 (Lisp_Object gstring) 4302 (Lisp_Object gstring)
4301{ 4303{
4302 struct font *font; 4304 struct font *font;
4303 Lisp_Object font_object, n, glyph; 4305 Lisp_Object font_object, n, glyph;
4304 ptrdiff_t i, j, from, to; 4306 ptrdiff_t i, from, to;
4305 4307
4306 if (! composition_gstring_p (gstring)) 4308 if (! composition_gstring_p (gstring))
4307 signal_error ("Invalid glyph-string: ", gstring); 4309 signal_error ("Invalid glyph-string: ", gstring);
@@ -4327,44 +4329,42 @@ created glyph-string. Otherwise, the value is nil. */)
4327 if (XINT (n) < LGSTRING_GLYPH_LEN (gstring)) 4329 if (XINT (n) < LGSTRING_GLYPH_LEN (gstring))
4328 LGSTRING_SET_GLYPH (gstring, XINT (n), Qnil); 4330 LGSTRING_SET_GLYPH (gstring, XINT (n), Qnil);
4329 4331
4332 /* Check FROM_IDX and TO_IDX of each GLYPH in GSTRING to assure that
4333 GLYPHS covers all characters (except for the last few ones) in
4334 GSTRING. More formally, provided that NCHARS is the number of
4335 characters in GSTRING and GLYPHS[i] is the ith glyph, FROM_IDX
4336 and TO_IDX of each glyph must satisfy these conditions:
4337
4338 GLYPHS[0].FROM_IDX == 0
4339 GLYPHS[i].FROM_IDX <= GLYPHS[i].TO_IDX
4340 if (GLYPHS[i].FROM_IDX == GLYPHS[i-1].FROM_IDX)
4341 ;; GLYPHS[i] and GLYPHS[i-1] belongs to the same grapheme cluster
4342 GLYPHS[i].TO_IDX == GLYPHS[i-1].TO_IDX
4343 else
4344 ;; Be sure to cover all characters.
4345 GLYPHS[i].FROM_IDX == GLYPHS[i-1].TO_IDX + 1 */
4330 glyph = LGSTRING_GLYPH (gstring, 0); 4346 glyph = LGSTRING_GLYPH (gstring, 0);
4331 from = LGLYPH_FROM (glyph); 4347 from = LGLYPH_FROM (glyph);
4332 to = LGLYPH_TO (glyph); 4348 to = LGLYPH_TO (glyph);
4333 for (i = 1, j = 0; i < LGSTRING_GLYPH_LEN (gstring); i++) 4349 if (from != 0 || to < from)
4350 goto shaper_error;
4351 for (i = 1; i < LGSTRING_GLYPH_LEN (gstring); i++)
4334 { 4352 {
4335 Lisp_Object this = LGSTRING_GLYPH (gstring, i); 4353 glyph = LGSTRING_GLYPH (gstring, i);
4336 4354 if (NILP (glyph))
4337 if (NILP (this))
4338 break; 4355 break;
4339 if (NILP (LGLYPH_ADJUSTMENT (this))) 4356 if (! (LGLYPH_FROM (glyph) <= LGLYPH_TO (glyph)
4340 { 4357 && (LGLYPH_FROM (glyph) == from
4341 if (j < i - 1) 4358 ? LGLYPH_TO (glyph) == to
4342 for (; j < i; j++) 4359 : LGLYPH_FROM (glyph) == to + 1)))
4343 { 4360 goto shaper_error;
4344 glyph = LGSTRING_GLYPH (gstring, j); 4361 from = LGLYPH_FROM (glyph);
4345 LGLYPH_SET_FROM (glyph, from); 4362 to = LGLYPH_TO (glyph);
4346 LGLYPH_SET_TO (glyph, to);
4347 }
4348 from = LGLYPH_FROM (this);
4349 to = LGLYPH_TO (this);
4350 j = i;
4351 }
4352 else
4353 {
4354 if (from > LGLYPH_FROM (this))
4355 from = LGLYPH_FROM (this);
4356 if (to < LGLYPH_TO (this))
4357 to = LGLYPH_TO (this);
4358 }
4359 } 4363 }
4360 if (j < i - 1)
4361 for (; j < i; j++)
4362 {
4363 glyph = LGSTRING_GLYPH (gstring, j);
4364 LGLYPH_SET_FROM (glyph, from);
4365 LGLYPH_SET_TO (glyph, to);
4366 }
4367 return composition_gstring_put_cache (gstring, XINT (n)); 4364 return composition_gstring_put_cache (gstring, XINT (n));
4365
4366 shaper_error:
4367 return Qnil;
4368} 4368}
4369 4369
4370DEFUN ("font-variation-glyphs", Ffont_variation_glyphs, Sfont_variation_glyphs, 4370DEFUN ("font-variation-glyphs", Ffont_variation_glyphs, Sfont_variation_glyphs,
diff --git a/src/fontset.c b/src/fontset.c
index 2b955fe6b11..35d4bfb367e 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26 26
27#include <config.h> 27#include <config.h>
28#include <stdio.h> 28#include <stdio.h>
29#include <setjmp.h>
30 29
31#include "lisp.h" 30#include "lisp.h"
32#include "blockinput.h" 31#include "blockinput.h"
diff --git a/src/frame.c b/src/frame.c
index 9b12842bf89..6930dac3ce8 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -24,7 +24,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
24#include <stdio.h> 24#include <stdio.h>
25#include <errno.h> 25#include <errno.h>
26#include <limits.h> 26#include <limits.h>
27#include <setjmp.h>
28 27
29#include <c-ctype.h> 28#include <c-ctype.h>
30 29
@@ -1299,6 +1298,11 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1299 structures can still refer to it. */ 1298 structures can still refer to it. */
1300 fset_menu_bar_vector (f, Qnil); 1299 fset_menu_bar_vector (f, Qnil);
1301 1300
1301 /* If FRAME's buffer lists contains killed
1302 buffers, this helps GC to reclaim them. */
1303 fset_buffer_list (f, Qnil);
1304 fset_buried_buffer_list (f, Qnil);
1305
1302 free_font_driver_list (f); 1306 free_font_driver_list (f);
1303 xfree (f->namebuf); 1307 xfree (f->namebuf);
1304 xfree (f->decode_mode_spec_buffer); 1308 xfree (f->decode_mode_spec_buffer);
diff --git a/src/fringe.c b/src/fringe.c
index 0c2109a0f8e..6e6deeddb08 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -18,7 +18,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20#include <stdio.h> 20#include <stdio.h>
21#include <setjmp.h>
22 21
23#include "lisp.h" 22#include "lisp.h"
24#include "frame.h" 23#include "frame.h"
diff --git a/src/ftfont.c b/src/ftfont.c
index a85773a9a21..f07ad6f33c7 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -21,8 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25
26#include <fontconfig/fontconfig.h> 24#include <fontconfig/fontconfig.h>
27#include <fontconfig/fcfreetype.h> 25#include <fontconfig/fcfreetype.h>
28 26
diff --git a/src/ftxfont.c b/src/ftxfont.c
index c705ede62c4..466250bd43f 100644
--- a/src/ftxfont.c
+++ b/src/ftxfont.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25#include <X11/Xlib.h> 24#include <X11/Xlib.h>
26 25
27#include "lisp.h" 26#include "lisp.h"
diff --git a/src/gnutls.c b/src/gnutls.c
index a2573f6bd99..1c4693aee32 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -18,7 +18,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20#include <errno.h> 20#include <errno.h>
21#include <setjmp.h>
22 21
23#include "lisp.h" 22#include "lisp.h"
24#include "process.h" 23#include "process.h"
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 884574e1062..1eb4b2cabdf 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22#ifdef USE_GTK 22#ifdef USE_GTK
23#include <float.h> 23#include <float.h>
24#include <stdio.h> 24#include <stdio.h>
25#include <setjmp.h>
26 25
27#include <c-ctype.h> 26#include <c-ctype.h>
28 27
diff --git a/src/image.c b/src/image.c
index cf01602050f..8fc1c8637eb 100644
--- a/src/image.c
+++ b/src/image.c
@@ -5514,6 +5514,15 @@ init_png_functions (Lisp_Object libraries)
5514 5514
5515#endif /* HAVE_NTGUI */ 5515#endif /* HAVE_NTGUI */
5516 5516
5517/* Possibly inefficient/inexact substitutes for _setjmp and _longjmp.
5518 Do not use sys_setjmp, as PNG supports only jmp_buf. The _longjmp
5519 substitute may munge the signal mask, but that should be OK here.
5520 MinGW (MS-Windows) uses _setjmp and defines setjmp to _setjmp in
5521 the system header setjmp.h; don't mess up that. */
5522#ifndef HAVE__SETJMP
5523# define _setjmp(j) setjmp (j)
5524# define _longjmp longjmp
5525#endif
5517 5526
5518#if (PNG_LIBPNG_VER < 10500) 5527#if (PNG_LIBPNG_VER < 10500)
5519#define PNG_LONGJMP(ptr) (_longjmp ((ptr)->jmpbuf, 1)) 5528#define PNG_LONGJMP(ptr) (_longjmp ((ptr)->jmpbuf, 1))
@@ -5591,20 +5600,31 @@ png_read_from_file (png_structp png_ptr, png_bytep data, png_size_t length)
5591/* Load PNG image IMG for use on frame F. Value is non-zero if 5600/* Load PNG image IMG for use on frame F. Value is non-zero if
5592 successful. */ 5601 successful. */
5593 5602
5603struct png_load_context
5604{
5605 /* These are members so that longjmp doesn't munge local variables. */
5606 png_struct *png_ptr;
5607 png_info *info_ptr;
5608 png_info *end_info;
5609 FILE *fp;
5610 png_byte *pixels;
5611 png_byte **rows;
5612};
5613
5594static int 5614static int
5595png_load (struct frame *f, struct image *img) 5615png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5596{ 5616{
5597 Lisp_Object file, specified_file; 5617 Lisp_Object file, specified_file;
5598 Lisp_Object specified_data; 5618 Lisp_Object specified_data;
5599 int x, y; 5619 int x, y;
5600 ptrdiff_t i; 5620 ptrdiff_t i;
5601 XImagePtr ximg, mask_img = NULL; 5621 XImagePtr ximg, mask_img = NULL;
5602 png_struct *png_ptr = NULL; 5622 png_struct *png_ptr;
5603 png_info *info_ptr = NULL, *end_info = NULL; 5623 png_info *info_ptr = NULL, *end_info = NULL;
5604 FILE *volatile fp = NULL; 5624 FILE *fp = NULL;
5605 png_byte sig[8]; 5625 png_byte sig[8];
5606 png_byte * volatile pixels = NULL; 5626 png_byte *pixels = NULL;
5607 png_byte ** volatile rows = NULL; 5627 png_byte **rows = NULL;
5608 png_uint_32 width, height; 5628 png_uint_32 width, height;
5609 int bit_depth, color_type, interlace_type; 5629 int bit_depth, color_type, interlace_type;
5610 png_byte channels; 5630 png_byte channels;
@@ -5671,24 +5691,26 @@ png_load (struct frame *f, struct image *img)
5671 png_ptr = fn_png_create_read_struct (PNG_LIBPNG_VER_STRING, 5691 png_ptr = fn_png_create_read_struct (PNG_LIBPNG_VER_STRING,
5672 NULL, my_png_error, 5692 NULL, my_png_error,
5673 my_png_warning); 5693 my_png_warning);
5674 if (!png_ptr) 5694 if (png_ptr)
5675 { 5695 {
5676 if (fp) fclose (fp); 5696 info_ptr = fn_png_create_info_struct (png_ptr);
5677 return 0; 5697 end_info = fn_png_create_info_struct (png_ptr);
5678 } 5698 }
5679 5699
5680 info_ptr = fn_png_create_info_struct (png_ptr); 5700 c->png_ptr = png_ptr;
5681 if (!info_ptr) 5701 c->info_ptr = info_ptr;
5702 c->end_info = end_info;
5703 c->fp = fp;
5704 c->pixels = pixels;
5705 c->rows = rows;
5706
5707 if (! (info_ptr && end_info))
5682 { 5708 {
5683 fn_png_destroy_read_struct (&png_ptr, NULL, NULL); 5709 fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info);
5684 if (fp) fclose (fp); 5710 png_ptr = 0;
5685 return 0;
5686 } 5711 }
5687 5712 if (! png_ptr)
5688 end_info = fn_png_create_info_struct (png_ptr);
5689 if (!end_info)
5690 { 5713 {
5691 fn_png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
5692 if (fp) fclose (fp); 5714 if (fp) fclose (fp);
5693 return 0; 5715 return 0;
5694 } 5716 }
@@ -5698,14 +5720,18 @@ png_load (struct frame *f, struct image *img)
5698 if (_setjmp (PNG_JMPBUF (png_ptr))) 5720 if (_setjmp (PNG_JMPBUF (png_ptr)))
5699 { 5721 {
5700 error: 5722 error:
5701 if (png_ptr) 5723 if (c->png_ptr)
5702 fn_png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); 5724 fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info);
5703 xfree (pixels); 5725 xfree (c->pixels);
5704 xfree (rows); 5726 xfree (c->rows);
5705 if (fp) fclose (fp); 5727 if (c->fp)
5728 fclose (c->fp);
5706 return 0; 5729 return 0;
5707 } 5730 }
5708 5731
5732 /* Silence a bogus diagnostic; see GCC bug 54561. */
5733 IF_LINT (fp = c->fp);
5734
5709 /* Read image info. */ 5735 /* Read image info. */
5710 if (!NILP (specified_data)) 5736 if (!NILP (specified_data))
5711 fn_png_set_read_fn (png_ptr, (void *) &tbr, png_read_from_memory); 5737 fn_png_set_read_fn (png_ptr, (void *) &tbr, png_read_from_memory);
@@ -5821,8 +5847,8 @@ png_load (struct frame *f, struct image *img)
5821 if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height 5847 if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height
5822 || min (PTRDIFF_MAX, SIZE_MAX) / sizeof *pixels / height < row_bytes) 5848 || min (PTRDIFF_MAX, SIZE_MAX) / sizeof *pixels / height < row_bytes)
5823 memory_full (SIZE_MAX); 5849 memory_full (SIZE_MAX);
5824 pixels = xmalloc (sizeof *pixels * row_bytes * height); 5850 c->pixels = pixels = xmalloc (sizeof *pixels * row_bytes * height);
5825 rows = xmalloc (height * sizeof *rows); 5851 c->rows = rows = xmalloc (height * sizeof *rows);
5826 for (i = 0; i < height; ++i) 5852 for (i = 0; i < height; ++i)
5827 rows[i] = pixels + i * row_bytes; 5853 rows[i] = pixels + i * row_bytes;
5828 5854
@@ -5832,7 +5858,7 @@ png_load (struct frame *f, struct image *img)
5832 if (fp) 5858 if (fp)
5833 { 5859 {
5834 fclose (fp); 5860 fclose (fp);
5835 fp = NULL; 5861 c->fp = NULL;
5836 } 5862 }
5837 5863
5838 /* Create an image and pixmap serving as mask if the PNG image 5864 /* Create an image and pixmap serving as mask if the PNG image
@@ -5907,7 +5933,7 @@ png_load (struct frame *f, struct image *img)
5907#endif /* COLOR_TABLE_SUPPORT */ 5933#endif /* COLOR_TABLE_SUPPORT */
5908 5934
5909 /* Clean up. */ 5935 /* Clean up. */
5910 fn_png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); 5936 fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info);
5911 xfree (rows); 5937 xfree (rows);
5912 xfree (pixels); 5938 xfree (pixels);
5913 5939
@@ -5936,6 +5962,13 @@ png_load (struct frame *f, struct image *img)
5936 return 1; 5962 return 1;
5937} 5963}
5938 5964
5965static int
5966png_load (struct frame *f, struct image *img)
5967{
5968 struct png_load_context c;
5969 return png_load_body (f, img, &c);
5970}
5971
5939#else /* HAVE_PNG */ 5972#else /* HAVE_PNG */
5940 5973
5941#ifdef HAVE_NS 5974#ifdef HAVE_NS
@@ -6105,7 +6138,20 @@ jpeg_resync_to_restart_wrapper (j_decompress_ptr cinfo, int desired)
6105struct my_jpeg_error_mgr 6138struct my_jpeg_error_mgr
6106{ 6139{
6107 struct jpeg_error_mgr pub; 6140 struct jpeg_error_mgr pub;
6108 jmp_buf setjmp_buffer; 6141 sys_jmp_buf setjmp_buffer;
6142
6143 /* The remaining members are so that longjmp doesn't munge local
6144 variables. */
6145 struct jpeg_decompress_struct cinfo;
6146 enum
6147 {
6148 MY_JPEG_ERROR_EXIT,
6149 MY_JPEG_INVALID_IMAGE_SIZE,
6150 MY_JPEG_CANNOT_CREATE_X
6151 } failure_code;
6152#ifdef lint
6153 FILE *fp;
6154#endif
6109}; 6155};
6110 6156
6111 6157
@@ -6113,7 +6159,8 @@ static _Noreturn void
6113my_error_exit (j_common_ptr cinfo) 6159my_error_exit (j_common_ptr cinfo)
6114{ 6160{
6115 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err; 6161 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err;
6116 _longjmp (mgr->setjmp_buffer, 1); 6162 mgr->failure_code = MY_JPEG_ERROR_EXIT;
6163 sys_longjmp (mgr->setjmp_buffer, 1);
6117} 6164}
6118 6165
6119 6166
@@ -6319,17 +6366,15 @@ jpeg_file_src (j_decompress_ptr cinfo, FILE *fp)
6319 from the JPEG lib. */ 6366 from the JPEG lib. */
6320 6367
6321static int 6368static int
6322jpeg_load (struct frame *f, struct image *img) 6369jpeg_load_body (struct frame *f, struct image *img,
6370 struct my_jpeg_error_mgr *mgr)
6323{ 6371{
6324 struct jpeg_decompress_struct cinfo;
6325 struct my_jpeg_error_mgr mgr;
6326 Lisp_Object file, specified_file; 6372 Lisp_Object file, specified_file;
6327 Lisp_Object specified_data; 6373 Lisp_Object specified_data;
6328 FILE * volatile fp = NULL; 6374 FILE *fp = NULL;
6329 JSAMPARRAY buffer; 6375 JSAMPARRAY buffer;
6330 int row_stride, x, y; 6376 int row_stride, x, y;
6331 XImagePtr ximg = NULL; 6377 XImagePtr ximg = NULL;
6332 int rc;
6333 unsigned long *colors; 6378 unsigned long *colors;
6334 int width, height; 6379 int width, height;
6335 6380
@@ -6359,26 +6404,37 @@ jpeg_load (struct frame *f, struct image *img)
6359 return 0; 6404 return 0;
6360 } 6405 }
6361 6406
6407 IF_LINT (mgr->fp = fp);
6408
6362 /* Customize libjpeg's error handling to call my_error_exit when an 6409 /* Customize libjpeg's error handling to call my_error_exit when an
6363 error is detected. This function will perform a longjmp. */ 6410 error is detected. This function will perform a longjmp. */
6364 cinfo.err = fn_jpeg_std_error (&mgr.pub); 6411 mgr->cinfo.err = fn_jpeg_std_error (&mgr->pub);
6365 mgr.pub.error_exit = my_error_exit; 6412 mgr->pub.error_exit = my_error_exit;
6366 6413 if (sys_setjmp (mgr->setjmp_buffer))
6367 if ((rc = _setjmp (mgr.setjmp_buffer)) != 0)
6368 { 6414 {
6369 if (rc == 1) 6415 switch (mgr->failure_code)
6370 { 6416 {
6371 /* Called from my_error_exit. Display a JPEG error. */ 6417 case MY_JPEG_ERROR_EXIT:
6372 char buf[JMSG_LENGTH_MAX]; 6418 {
6373 cinfo.err->format_message ((j_common_ptr) &cinfo, buf); 6419 char buf[JMSG_LENGTH_MAX];
6374 image_error ("Error reading JPEG image `%s': %s", img->spec, 6420 mgr->cinfo.err->format_message ((j_common_ptr) &mgr->cinfo, buf);
6375 build_string (buf)); 6421 image_error ("Error reading JPEG image `%s': %s", img->spec,
6422 build_string (buf));
6423 break;
6424 }
6425
6426 case MY_JPEG_INVALID_IMAGE_SIZE:
6427 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
6428 break;
6429
6430 case MY_JPEG_CANNOT_CREATE_X:
6431 break;
6376 } 6432 }
6377 6433
6378 /* Close the input file and destroy the JPEG object. */ 6434 /* Close the input file and destroy the JPEG object. */
6379 if (fp) 6435 if (fp)
6380 fclose ((FILE *) fp); 6436 fclose (fp);
6381 fn_jpeg_destroy_decompress (&cinfo); 6437 fn_jpeg_destroy_decompress (&mgr->cinfo);
6382 6438
6383 /* If we already have an XImage, free that. */ 6439 /* If we already have an XImage, free that. */
6384 x_destroy_x_image (ximg); 6440 x_destroy_x_image (ximg);
@@ -6388,46 +6444,52 @@ jpeg_load (struct frame *f, struct image *img)
6388 return 0; 6444 return 0;
6389 } 6445 }
6390 6446
6447 /* Silence a bogus diagnostic; see GCC bug 54561. */
6448 IF_LINT (fp = mgr->fp);
6449
6391 /* Create the JPEG decompression object. Let it read from fp. 6450 /* Create the JPEG decompression object. Let it read from fp.
6392 Read the JPEG image header. */ 6451 Read the JPEG image header. */
6393 fn_jpeg_CreateDecompress (&cinfo, JPEG_LIB_VERSION, sizeof (cinfo)); 6452 fn_jpeg_CreateDecompress (&mgr->cinfo, JPEG_LIB_VERSION, sizeof *&mgr->cinfo);
6394 6453
6395 if (NILP (specified_data)) 6454 if (NILP (specified_data))
6396 jpeg_file_src (&cinfo, (FILE *) fp); 6455 jpeg_file_src (&mgr->cinfo, fp);
6397 else 6456 else
6398 jpeg_memory_src (&cinfo, SDATA (specified_data), 6457 jpeg_memory_src (&mgr->cinfo, SDATA (specified_data),
6399 SBYTES (specified_data)); 6458 SBYTES (specified_data));
6400 6459
6401 fn_jpeg_read_header (&cinfo, 1); 6460 fn_jpeg_read_header (&mgr->cinfo, 1);
6402 6461
6403 /* Customize decompression so that color quantization will be used. 6462 /* Customize decompression so that color quantization will be used.
6404 Start decompression. */ 6463 Start decompression. */
6405 cinfo.quantize_colors = 1; 6464 mgr->cinfo.quantize_colors = 1;
6406 fn_jpeg_start_decompress (&cinfo); 6465 fn_jpeg_start_decompress (&mgr->cinfo);
6407 width = img->width = cinfo.output_width; 6466 width = img->width = mgr->cinfo.output_width;
6408 height = img->height = cinfo.output_height; 6467 height = img->height = mgr->cinfo.output_height;
6409 6468
6410 if (!check_image_size (f, width, height)) 6469 if (!check_image_size (f, width, height))
6411 { 6470 {
6412 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 6471 mgr->failure_code = MY_JPEG_INVALID_IMAGE_SIZE;
6413 _longjmp (mgr.setjmp_buffer, 2); 6472 sys_longjmp (mgr->setjmp_buffer, 1);
6414 } 6473 }
6415 6474
6416 /* Create X image and pixmap. */ 6475 /* Create X image and pixmap. */
6417 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) 6476 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
6418 _longjmp (mgr.setjmp_buffer, 2); 6477 {
6478 mgr->failure_code = MY_JPEG_CANNOT_CREATE_X;
6479 sys_longjmp (mgr->setjmp_buffer, 1);
6480 }
6419 6481
6420 /* Allocate colors. When color quantization is used, 6482 /* Allocate colors. When color quantization is used,
6421 cinfo.actual_number_of_colors has been set with the number of 6483 mgr->cinfo.actual_number_of_colors has been set with the number of
6422 colors generated, and cinfo.colormap is a two-dimensional array 6484 colors generated, and mgr->cinfo.colormap is a two-dimensional array
6423 of color indices in the range 0..cinfo.actual_number_of_colors. 6485 of color indices in the range 0..mgr->cinfo.actual_number_of_colors.
6424 No more than 255 colors will be generated. */ 6486 No more than 255 colors will be generated. */
6425 { 6487 {
6426 int i, ir, ig, ib; 6488 int i, ir, ig, ib;
6427 6489
6428 if (cinfo.out_color_components > 2) 6490 if (mgr->cinfo.out_color_components > 2)
6429 ir = 0, ig = 1, ib = 2; 6491 ir = 0, ig = 1, ib = 2;
6430 else if (cinfo.out_color_components > 1) 6492 else if (mgr->cinfo.out_color_components > 1)
6431 ir = 0, ig = 1, ib = 0; 6493 ir = 0, ig = 1, ib = 0;
6432 else 6494 else
6433 ir = 0, ig = 0, ib = 0; 6495 ir = 0, ig = 0, ib = 0;
@@ -6437,15 +6499,15 @@ jpeg_load (struct frame *f, struct image *img)
6437 a default color, and we don't have to care about which colors 6499 a default color, and we don't have to care about which colors
6438 can be freed safely, and which can't. */ 6500 can be freed safely, and which can't. */
6439 init_color_table (); 6501 init_color_table ();
6440 colors = alloca (cinfo.actual_number_of_colors * sizeof *colors); 6502 colors = alloca (mgr->cinfo.actual_number_of_colors * sizeof *colors);
6441 6503
6442 for (i = 0; i < cinfo.actual_number_of_colors; ++i) 6504 for (i = 0; i < mgr->cinfo.actual_number_of_colors; ++i)
6443 { 6505 {
6444 /* Multiply RGB values with 255 because X expects RGB values 6506 /* Multiply RGB values with 255 because X expects RGB values
6445 in the range 0..0xffff. */ 6507 in the range 0..0xffff. */
6446 int r = cinfo.colormap[ir][i] << 8; 6508 int r = mgr->cinfo.colormap[ir][i] << 8;
6447 int g = cinfo.colormap[ig][i] << 8; 6509 int g = mgr->cinfo.colormap[ig][i] << 8;
6448 int b = cinfo.colormap[ib][i] << 8; 6510 int b = mgr->cinfo.colormap[ib][i] << 8;
6449 colors[i] = lookup_rgb_color (f, r, g, b); 6511 colors[i] = lookup_rgb_color (f, r, g, b);
6450 } 6512 }
6451 6513
@@ -6457,21 +6519,21 @@ jpeg_load (struct frame *f, struct image *img)
6457 } 6519 }
6458 6520
6459 /* Read pixels. */ 6521 /* Read pixels. */
6460 row_stride = width * cinfo.output_components; 6522 row_stride = width * mgr->cinfo.output_components;
6461 buffer = cinfo.mem->alloc_sarray ((j_common_ptr) &cinfo, JPOOL_IMAGE, 6523 buffer = mgr->cinfo.mem->alloc_sarray ((j_common_ptr) &mgr->cinfo,
6462 row_stride, 1); 6524 JPOOL_IMAGE, row_stride, 1);
6463 for (y = 0; y < height; ++y) 6525 for (y = 0; y < height; ++y)
6464 { 6526 {
6465 fn_jpeg_read_scanlines (&cinfo, buffer, 1); 6527 fn_jpeg_read_scanlines (&mgr->cinfo, buffer, 1);
6466 for (x = 0; x < cinfo.output_width; ++x) 6528 for (x = 0; x < mgr->cinfo.output_width; ++x)
6467 XPutPixel (ximg, x, y, colors[buffer[0][x]]); 6529 XPutPixel (ximg, x, y, colors[buffer[0][x]]);
6468 } 6530 }
6469 6531
6470 /* Clean up. */ 6532 /* Clean up. */
6471 fn_jpeg_finish_decompress (&cinfo); 6533 fn_jpeg_finish_decompress (&mgr->cinfo);
6472 fn_jpeg_destroy_decompress (&cinfo); 6534 fn_jpeg_destroy_decompress (&mgr->cinfo);
6473 if (fp) 6535 if (fp)
6474 fclose ((FILE *) fp); 6536 fclose (fp);
6475 6537
6476 /* Maybe fill in the background field while we have ximg handy. */ 6538 /* Maybe fill in the background field while we have ximg handy. */
6477 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 6539 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
@@ -6484,6 +6546,13 @@ jpeg_load (struct frame *f, struct image *img)
6484 return 1; 6546 return 1;
6485} 6547}
6486 6548
6549static int
6550jpeg_load (struct frame *f, struct image *img)
6551{
6552 struct my_jpeg_error_mgr mgr;
6553 return jpeg_load_body (f, img, &mgr);
6554}
6555
6487#else /* HAVE_JPEG */ 6556#else /* HAVE_JPEG */
6488 6557
6489#ifdef HAVE_NS 6558#ifdef HAVE_NS
diff --git a/src/indent.c b/src/indent.c
index c60315a7f6e..053643e6319 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20#include <config.h> 20#include <config.h>
21#include <stdio.h> 21#include <stdio.h>
22#include <setjmp.h>
23 22
24#include "lisp.h" 23#include "lisp.h"
25#include "character.h" 24#include "character.h"
diff --git a/src/insdel.c b/src/insdel.c
index b12a390633e..87010cd8251 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h>
23 22
24#include <intprops.h> 23#include <intprops.h>
25 24
@@ -840,8 +839,7 @@ insert_1_both (const char *string,
840 PT + nchars, PT_BYTE + nbytes, 839 PT + nchars, PT_BYTE + nbytes,
841 before_markers); 840 before_markers);
842 841
843 if (buffer_intervals (current_buffer)) 842 offset_intervals (current_buffer, PT, nchars);
844 offset_intervals (current_buffer, PT, nchars);
845 843
846 if (!inherit && buffer_intervals (current_buffer)) 844 if (!inherit && buffer_intervals (current_buffer))
847 set_text_properties (make_number (PT), make_number (PT + nchars), 845 set_text_properties (make_number (PT), make_number (PT + nchars),
@@ -1153,8 +1151,7 @@ insert_from_buffer_1 (struct buffer *buf,
1153 PT_BYTE + outgoing_nbytes, 1151 PT_BYTE + outgoing_nbytes,
1154 0); 1152 0);
1155 1153
1156 if (buffer_intervals (current_buffer)) 1154 offset_intervals (current_buffer, PT, nchars);
1157 offset_intervals (current_buffer, PT, nchars);
1158 1155
1159 /* Get the intervals for the part of the string we are inserting. */ 1156 /* Get the intervals for the part of the string we are inserting. */
1160 intervals = buffer_intervals (buf); 1157 intervals = buffer_intervals (buf);
@@ -1222,8 +1219,7 @@ adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte,
1222 else if (len < nchars_del) 1219 else if (len < nchars_del)
1223 adjust_overlays_for_delete (from, nchars_del - len); 1220 adjust_overlays_for_delete (from, nchars_del - len);
1224 1221
1225 if (buffer_intervals (current_buffer)) 1222 offset_intervals (current_buffer, from, len - nchars_del);
1226 offset_intervals (current_buffer, from, len - nchars_del);
1227 1223
1228 if (from < PT) 1224 if (from < PT)
1229 adjust_point (len - nchars_del, len_byte - nbytes_del); 1225 adjust_point (len - nchars_del, len_byte - nbytes_del);
@@ -1394,16 +1390,16 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
1394 1390
1395 eassert (GPT <= GPT_BYTE); 1391 eassert (GPT <= GPT_BYTE);
1396 1392
1397 /* Adjust the overlay center as needed. This must be done after
1398 adjusting the markers that bound the overlays. */
1399 adjust_overlays_for_delete (from, nchars_del);
1400 adjust_overlays_for_insert (from, inschars);
1401
1402 /* Adjust markers for the deletion and the insertion. */ 1393 /* Adjust markers for the deletion and the insertion. */
1403 if (markers) 1394 if (markers)
1404 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, 1395 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
1405 inschars, outgoing_insbytes); 1396 inschars, outgoing_insbytes);
1406 1397
1398 /* Adjust the overlay center as needed. This must be done after
1399 adjusting the markers that bound the overlays. */
1400 adjust_overlays_for_delete (from, nchars_del);
1401 adjust_overlays_for_insert (from, inschars);
1402
1407 offset_intervals (current_buffer, from, inschars - nchars_del); 1403 offset_intervals (current_buffer, from, inschars - nchars_del);
1408 1404
1409 /* Get the intervals for the part of the string we are inserting-- 1405 /* Get the intervals for the part of the string we are inserting--
@@ -1510,6 +1506,12 @@ replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
1510 1506
1511 eassert (GPT <= GPT_BYTE); 1507 eassert (GPT <= GPT_BYTE);
1512 1508
1509 /* Adjust markers for the deletion and the insertion. */
1510 if (markers
1511 && ! (nchars_del == 1 && inschars == 1 && nbytes_del == insbytes))
1512 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
1513 inschars, insbytes);
1514
1513 /* Adjust the overlay center as needed. This must be done after 1515 /* Adjust the overlay center as needed. This must be done after
1514 adjusting the markers that bound the overlays. */ 1516 adjusting the markers that bound the overlays. */
1515 if (nchars_del != inschars) 1517 if (nchars_del != inschars)
@@ -1518,12 +1520,6 @@ replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
1518 adjust_overlays_for_delete (from + inschars, nchars_del); 1520 adjust_overlays_for_delete (from + inschars, nchars_del);
1519 } 1521 }
1520 1522
1521 /* Adjust markers for the deletion and the insertion. */
1522 if (markers
1523 && ! (nchars_del == 1 && inschars == 1 && nbytes_del == insbytes))
1524 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
1525 inschars, insbytes);
1526
1527 offset_intervals (current_buffer, from, inschars - nchars_del); 1523 offset_intervals (current_buffer, from, inschars - nchars_del);
1528 1524
1529 /* Relocate point as if it were a marker. */ 1525 /* Relocate point as if it were a marker. */
diff --git a/src/intervals.c b/src/intervals.c
index e508f968963..584ee1e923d 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -41,7 +41,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
41 41
42#define INTERVALS_INLINE EXTERN_INLINE 42#define INTERVALS_INLINE EXTERN_INLINE
43 43
44#include <setjmp.h>
45#include <intprops.h> 44#include <intprops.h>
46#include "lisp.h" 45#include "lisp.h"
47#include "intervals.h" 46#include "intervals.h"
@@ -674,8 +673,7 @@ find_interval (register INTERVAL tree, register ptrdiff_t position)
674 673
675 eassert (relative_position <= TOTAL_LENGTH (tree)); 674 eassert (relative_position <= TOTAL_LENGTH (tree));
676 675
677 if (!handling_signal) 676 tree = balance_possible_root_interval (tree);
678 tree = balance_possible_root_interval (tree);
679 677
680 while (1) 678 while (1)
681 { 679 {
diff --git a/src/keyboard.c b/src/keyboard.c
index de48b53053b..c80f1d61e77 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -22,7 +22,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22#define KEYBOARD_INLINE EXTERN_INLINE 22#define KEYBOARD_INLINE EXTERN_INLINE
23 23
24#include <stdio.h> 24#include <stdio.h>
25#include <setjmp.h> 25
26#include "lisp.h" 26#include "lisp.h"
27#include "termchar.h" 27#include "termchar.h"
28#include "termopts.h" 28#include "termopts.h"
@@ -56,6 +56,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
56#include <sys/ioctl.h> 56#include <sys/ioctl.h>
57#endif /* not MSDOS */ 57#endif /* not MSDOS */
58 58
59#if defined USABLE_FIONREAD && defined USG5_4
60# include <sys/filio.h>
61#endif
62
59#include "syssignal.h" 63#include "syssignal.h"
60 64
61#include <sys/types.h> 65#include <sys/types.h>
@@ -80,9 +84,7 @@ int interrupt_input_pending;
80 pending_atimers separately, to reduce code size. So, any code that 84 pending_atimers separately, to reduce code size. So, any code that
81 changes interrupt_input_pending or pending_atimers should update 85 changes interrupt_input_pending or pending_atimers should update
82 this too. */ 86 this too. */
83#ifdef SYNC_INPUT
84int pending_signals; 87int pending_signals;
85#endif
86 88
87#define KBD_BUFFER_SIZE 4096 89#define KBD_BUFFER_SIZE 4096
88 90
@@ -141,7 +143,7 @@ static ptrdiff_t before_command_echo_length;
141 143
142/* For longjmp to where kbd input is being done. */ 144/* For longjmp to where kbd input is being done. */
143 145
144static jmp_buf getcjmp; 146static sys_jmp_buf getcjmp;
145 147
146/* True while doing kbd input. */ 148/* True while doing kbd input. */
147int waiting_for_input; 149int waiting_for_input;
@@ -388,19 +390,6 @@ int interrupt_input;
388/* Nonzero while interrupts are temporarily deferred during redisplay. */ 390/* Nonzero while interrupts are temporarily deferred during redisplay. */
389int interrupts_deferred; 391int interrupts_deferred;
390 392
391/* Allow configure to inhibit use of FIONREAD. */
392#ifdef BROKEN_FIONREAD
393#undef FIONREAD
394#endif
395
396/* We are unable to use interrupts if FIONREAD is not available,
397 so flush SIGIO so we won't try. */
398#if !defined (FIONREAD)
399#ifdef SIGIO
400#undef SIGIO
401#endif
402#endif
403
404/* If we support a window system, turn on the code to poll periodically 393/* If we support a window system, turn on the code to poll periodically
405 to detect C-g. It isn't actually used when doing interrupt input. */ 394 to detect C-g. It isn't actually used when doing interrupt input. */
406#if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS) 395#if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS)
@@ -446,12 +435,12 @@ static Lisp_Object modify_event_symbol (ptrdiff_t, int, Lisp_Object,
446 Lisp_Object *, ptrdiff_t); 435 Lisp_Object *, ptrdiff_t);
447static Lisp_Object make_lispy_switch_frame (Lisp_Object); 436static Lisp_Object make_lispy_switch_frame (Lisp_Object);
448static int help_char_p (Lisp_Object); 437static int help_char_p (Lisp_Object);
449static void save_getcjmp (jmp_buf); 438static void save_getcjmp (sys_jmp_buf);
450static void restore_getcjmp (jmp_buf); 439static void restore_getcjmp (sys_jmp_buf);
451static Lisp_Object apply_modifiers (int, Lisp_Object); 440static Lisp_Object apply_modifiers (int, Lisp_Object);
452static void clear_event (struct input_event *); 441static void clear_event (struct input_event *);
453static Lisp_Object restore_kboard_configuration (Lisp_Object); 442static Lisp_Object restore_kboard_configuration (Lisp_Object);
454#ifdef SIGIO 443#ifdef USABLE_SIGIO
455static void deliver_input_available_signal (int signo); 444static void deliver_input_available_signal (int signo);
456#endif 445#endif
457static void handle_interrupt (void); 446static void handle_interrupt (void);
@@ -2022,17 +2011,9 @@ static struct atimer *poll_timer;
2022void 2011void
2023poll_for_input_1 (void) 2012poll_for_input_1 (void)
2024{ 2013{
2025/* Tell ns_read_socket() it is being called asynchronously so it can avoid
2026 doing anything dangerous. */
2027#ifdef HAVE_NS
2028 ++handling_signal;
2029#endif
2030 if (interrupt_input_blocked == 0 2014 if (interrupt_input_blocked == 0
2031 && !waiting_for_input) 2015 && !waiting_for_input)
2032 read_avail_input (0); 2016 read_avail_input (0);
2033#ifdef HAVE_NS
2034 --handling_signal;
2035#endif
2036} 2017}
2037 2018
2038/* Timer callback function for poll_timer. TIMER is equal to 2019/* Timer callback function for poll_timer. TIMER is equal to
@@ -2043,12 +2024,8 @@ poll_for_input (struct atimer *timer)
2043{ 2024{
2044 if (poll_suppress_count == 0) 2025 if (poll_suppress_count == 0)
2045 { 2026 {
2046#ifdef SYNC_INPUT
2047 interrupt_input_pending = 1; 2027 interrupt_input_pending = 1;
2048 pending_signals = 1; 2028 pending_signals = 1;
2049#else
2050 poll_for_input_1 ();
2051#endif
2052 } 2029 }
2053} 2030}
2054 2031
@@ -2327,8 +2304,8 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2327{ 2304{
2328 volatile Lisp_Object c; 2305 volatile Lisp_Object c;
2329 ptrdiff_t jmpcount; 2306 ptrdiff_t jmpcount;
2330 jmp_buf local_getcjmp; 2307 sys_jmp_buf local_getcjmp;
2331 jmp_buf save_jump; 2308 sys_jmp_buf save_jump;
2332 volatile int key_already_recorded = 0; 2309 volatile int key_already_recorded = 0;
2333 Lisp_Object tem, save; 2310 Lisp_Object tem, save;
2334 volatile Lisp_Object previous_echo_area_message; 2311 volatile Lisp_Object previous_echo_area_message;
@@ -2574,7 +2551,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2574 it *must not* be in effect when we call redisplay. */ 2551 it *must not* be in effect when we call redisplay. */
2575 2552
2576 jmpcount = SPECPDL_INDEX (); 2553 jmpcount = SPECPDL_INDEX ();
2577 if (_setjmp (local_getcjmp)) 2554 if (sys_setjmp (local_getcjmp))
2578 { 2555 {
2579 /* Handle quits while reading the keyboard. */ 2556 /* Handle quits while reading the keyboard. */
2580 /* We must have saved the outer value of getcjmp here, 2557 /* We must have saved the outer value of getcjmp here,
@@ -3406,13 +3383,13 @@ record_char (Lisp_Object c)
3406 See read_process_output. */ 3383 See read_process_output. */
3407 3384
3408static void 3385static void
3409save_getcjmp (jmp_buf temp) 3386save_getcjmp (sys_jmp_buf temp)
3410{ 3387{
3411 memcpy (temp, getcjmp, sizeof getcjmp); 3388 memcpy (temp, getcjmp, sizeof getcjmp);
3412} 3389}
3413 3390
3414static void 3391static void
3415restore_getcjmp (jmp_buf temp) 3392restore_getcjmp (sys_jmp_buf temp)
3416{ 3393{
3417 memcpy (getcjmp, temp, sizeof getcjmp); 3394 memcpy (getcjmp, temp, sizeof getcjmp);
3418} 3395}
@@ -3649,10 +3626,8 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3649 /* Don't read keyboard input until we have processed kbd_buffer. 3626 /* Don't read keyboard input until we have processed kbd_buffer.
3650 This happens when pasting text longer than KBD_BUFFER_SIZE/2. */ 3627 This happens when pasting text longer than KBD_BUFFER_SIZE/2. */
3651 hold_keyboard_input (); 3628 hold_keyboard_input ();
3652#ifdef SIGIO
3653 if (!noninteractive) 3629 if (!noninteractive)
3654 signal (SIGIO, SIG_IGN); 3630 ignore_sigio ();
3655#endif
3656 stop_polling (); 3631 stop_polling ();
3657 } 3632 }
3658#endif /* subprocesses */ 3633#endif /* subprocesses */
@@ -3821,14 +3796,14 @@ kbd_buffer_get_event (KBOARD **kbp,
3821 /* Start reading input again, we have processed enough so we can 3796 /* Start reading input again, we have processed enough so we can
3822 accept new events again. */ 3797 accept new events again. */
3823 unhold_keyboard_input (); 3798 unhold_keyboard_input ();
3824#ifdef SIGIO 3799#ifdef USABLE_SIGIO
3825 if (!noninteractive) 3800 if (!noninteractive)
3826 { 3801 {
3827 struct sigaction action; 3802 struct sigaction action;
3828 emacs_sigaction_init (&action, deliver_input_available_signal); 3803 emacs_sigaction_init (&action, deliver_input_available_signal);
3829 sigaction (SIGIO, &action, 0); 3804 sigaction (SIGIO, &action, 0);
3830 } 3805 }
3831#endif /* SIGIO */ 3806#endif
3832 start_polling (); 3807 start_polling ();
3833 } 3808 }
3834#endif /* subprocesses */ 3809#endif /* subprocesses */
@@ -3870,10 +3845,9 @@ kbd_buffer_get_event (KBOARD **kbp,
3870 /* One way or another, wait until input is available; then, if 3845 /* One way or another, wait until input is available; then, if
3871 interrupt handlers have not read it, read it now. */ 3846 interrupt handlers have not read it, read it now. */
3872 3847
3873/* Note SIGIO has been undef'd if FIONREAD is missing. */ 3848#ifdef USABLE_SIGIO
3874#ifdef SIGIO
3875 gobble_input (0); 3849 gobble_input (0);
3876#endif /* SIGIO */ 3850#endif
3877 if (kbd_fetch_ptr != kbd_store_ptr) 3851 if (kbd_fetch_ptr != kbd_store_ptr)
3878 break; 3852 break;
3879#if defined (HAVE_MOUSE) || defined (HAVE_GPM) 3853#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
@@ -4352,7 +4326,7 @@ decode_timer (Lisp_Object timer, EMACS_TIME *result)
4352 if (! NILP (vector[0])) 4326 if (! NILP (vector[0]))
4353 return 0; 4327 return 0;
4354 4328
4355 return decode_time_components (vector[1], vector[2], vector[3], vector[4], 4329 return decode_time_components (vector[1], vector[2], vector[3], vector[8],
4356 result, 0); 4330 result, 0);
4357} 4331}
4358 4332
@@ -4554,7 +4528,7 @@ in the same style as (current-time).
4554 4528
4555The value when Emacs is not idle is nil. 4529The value when Emacs is not idle is nil.
4556 4530
4557NSEC is a multiple of the system clock resolution. */) 4531PSEC is a multiple of the system clock resolution. */)
4558 (void) 4532 (void)
4559{ 4533{
4560 if (EMACS_TIME_VALID_P (timer_idleness_start_time)) 4534 if (EMACS_TIME_VALID_P (timer_idleness_start_time))
@@ -6785,7 +6759,7 @@ get_input_pending (int *addr, int flags)
6785void 6759void
6786gobble_input (int expected) 6760gobble_input (int expected)
6787{ 6761{
6788#ifdef SIGIO 6762#ifdef USABLE_SIGIO
6789 if (interrupt_input) 6763 if (interrupt_input)
6790 { 6764 {
6791 sigset_t blocked, procmask; 6765 sigset_t blocked, procmask;
@@ -6840,7 +6814,7 @@ record_asynch_buffer_change (void)
6840 return; 6814 return;
6841 6815
6842 /* Make sure no interrupt happens while storing the event. */ 6816 /* Make sure no interrupt happens while storing the event. */
6843#ifdef SIGIO 6817#ifdef USABLE_SIGIO
6844 if (interrupt_input) 6818 if (interrupt_input)
6845 { 6819 {
6846 sigset_t blocked, procmask; 6820 sigset_t blocked, procmask;
@@ -7066,7 +7040,7 @@ tty_read_avail_input (struct terminal *terminal,
7066#endif /* HAVE_GPM */ 7040#endif /* HAVE_GPM */
7067 7041
7068/* Determine how many characters we should *try* to read. */ 7042/* Determine how many characters we should *try* to read. */
7069#ifdef FIONREAD 7043#ifdef USABLE_FIONREAD
7070 /* Find out how much input is available. */ 7044 /* Find out how much input is available. */
7071 if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0) 7045 if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0)
7072 { 7046 {
@@ -7079,14 +7053,12 @@ tty_read_avail_input (struct terminal *terminal,
7079 return 0; 7053 return 0;
7080 if (n_to_read > sizeof cbuf) 7054 if (n_to_read > sizeof cbuf)
7081 n_to_read = sizeof cbuf; 7055 n_to_read = sizeof cbuf;
7082#else /* no FIONREAD */ 7056#elif defined USG || defined CYGWIN
7083#if defined (USG) || defined (CYGWIN)
7084 /* Read some input if available, but don't wait. */ 7057 /* Read some input if available, but don't wait. */
7085 n_to_read = sizeof cbuf; 7058 n_to_read = sizeof cbuf;
7086 fcntl (fileno (tty->input), F_SETFL, O_NDELAY); 7059 fcntl (fileno (tty->input), F_SETFL, O_NDELAY);
7087#else 7060#else
7088 you lose; 7061# error "Cannot read without possibly delaying"
7089#endif
7090#endif 7062#endif
7091 7063
7092#ifdef subprocesses 7064#ifdef subprocesses
@@ -7135,7 +7107,7 @@ tty_read_avail_input (struct terminal *terminal,
7135#endif 7107#endif
7136 ); 7108 );
7137 7109
7138#ifndef FIONREAD 7110#ifndef USABLE_FIONREAD
7139#if defined (USG) || defined (CYGWIN) 7111#if defined (USG) || defined (CYGWIN)
7140 fcntl (fileno (tty->input), F_SETFL, 0); 7112 fcntl (fileno (tty->input), F_SETFL, 0);
7141#endif /* USG or CYGWIN */ 7113#endif /* USG or CYGWIN */
@@ -7206,19 +7178,12 @@ tty_read_avail_input (struct terminal *terminal,
7206 return nread; 7178 return nread;
7207} 7179}
7208 7180
7209#if defined SYNC_INPUT || defined SIGIO
7210static void 7181static void
7211handle_async_input (void) 7182handle_async_input (void)
7212{ 7183{
7213 interrupt_input_pending = 0; 7184 interrupt_input_pending = 0;
7214#ifdef SYNC_INPUT
7215 pending_signals = pending_atimers; 7185 pending_signals = pending_atimers;
7216#endif 7186
7217/* Tell ns_read_socket() it is being called asynchronously so it can avoid
7218 doing anything dangerous. */
7219#ifdef HAVE_NS
7220 ++handling_signal;
7221#endif
7222 while (1) 7187 while (1)
7223 { 7188 {
7224 int nread; 7189 int nread;
@@ -7229,13 +7194,8 @@ handle_async_input (void)
7229 if (nread <= 0) 7194 if (nread <= 0)
7230 break; 7195 break;
7231 } 7196 }
7232#ifdef HAVE_NS
7233 --handling_signal;
7234#endif
7235} 7197}
7236#endif /* SYNC_INPUT || SIGIO */
7237 7198
7238#ifdef SYNC_INPUT
7239void 7199void
7240process_pending_signals (void) 7200process_pending_signals (void)
7241{ 7201{
@@ -7243,25 +7203,17 @@ process_pending_signals (void)
7243 handle_async_input (); 7203 handle_async_input ();
7244 do_pending_atimers (); 7204 do_pending_atimers ();
7245} 7205}
7246#endif
7247 7206
7248#ifdef SIGIO /* for entire page */ 7207#ifdef USABLE_SIGIO
7249/* Note SIGIO has been undef'd if FIONREAD is missing. */
7250 7208
7251static void 7209static void
7252handle_input_available_signal (int sig) 7210handle_input_available_signal (int sig)
7253{ 7211{
7254#ifdef SYNC_INPUT
7255 interrupt_input_pending = 1; 7212 interrupt_input_pending = 1;
7256 pending_signals = 1; 7213 pending_signals = 1;
7257#endif
7258 7214
7259 if (input_available_clear_time) 7215 if (input_available_clear_time)
7260 *input_available_clear_time = make_emacs_time (0, 0); 7216 *input_available_clear_time = make_emacs_time (0, 0);
7261
7262#ifndef SYNC_INPUT
7263 handle_async_input ();
7264#endif
7265} 7217}
7266 7218
7267static void 7219static void
@@ -7269,7 +7221,7 @@ deliver_input_available_signal (int sig)
7269{ 7221{
7270 handle_on_main_thread (sig, handle_input_available_signal); 7222 handle_on_main_thread (sig, handle_input_available_signal);
7271} 7223}
7272#endif /* SIGIO */ 7224#endif /* USABLE_SIGIO */
7273 7225
7274/* Send ourselves a SIGIO. 7226/* Send ourselves a SIGIO.
7275 7227
@@ -7280,7 +7232,7 @@ deliver_input_available_signal (int sig)
7280void 7232void
7281reinvoke_input_signal (void) 7233reinvoke_input_signal (void)
7282{ 7234{
7283#ifdef SIGIO 7235#ifdef USABLE_SIGIO
7284 handle_async_input (); 7236 handle_async_input ();
7285#endif 7237#endif
7286} 7238}
@@ -7354,7 +7306,7 @@ handle_user_signal (int sig)
7354 } 7306 }
7355 7307
7356 p->npending++; 7308 p->npending++;
7357#ifdef SIGIO 7309#ifdef USABLE_SIGIO
7358 if (interrupt_input) 7310 if (interrupt_input)
7359 kill (getpid (), SIGIO); 7311 kill (getpid (), SIGIO);
7360 else 7312 else
@@ -11010,7 +10962,7 @@ quit_throw_to_read_char (int from_signal)
11010 do_switch_frame (make_lispy_switch_frame (internal_last_event_frame), 10962 do_switch_frame (make_lispy_switch_frame (internal_last_event_frame),
11011 0, 0, Qnil); 10963 0, 0, Qnil);
11012 10964
11013 _longjmp (getcjmp, 1); 10965 sys_longjmp (getcjmp, 1);
11014} 10966}
11015 10967
11016DEFUN ("set-input-interrupt-mode", Fset_input_interrupt_mode, 10968DEFUN ("set-input-interrupt-mode", Fset_input_interrupt_mode,
@@ -11023,8 +10975,7 @@ See also `current-input-mode'. */)
11023 (Lisp_Object interrupt) 10975 (Lisp_Object interrupt)
11024{ 10976{
11025 int new_interrupt_input; 10977 int new_interrupt_input;
11026#ifdef SIGIO 10978#ifdef USABLE_SIGIO
11027/* Note SIGIO has been undef'd if FIONREAD is missing. */
11028#ifdef HAVE_X_WINDOWS 10979#ifdef HAVE_X_WINDOWS
11029 if (x_display_list != NULL) 10980 if (x_display_list != NULL)
11030 { 10981 {
@@ -11035,9 +10986,9 @@ See also `current-input-mode'. */)
11035 else 10986 else
11036#endif /* HAVE_X_WINDOWS */ 10987#endif /* HAVE_X_WINDOWS */
11037 new_interrupt_input = !NILP (interrupt); 10988 new_interrupt_input = !NILP (interrupt);
11038#else /* not SIGIO */ 10989#else /* not USABLE_SIGIO */
11039 new_interrupt_input = 0; 10990 new_interrupt_input = 0;
11040#endif /* not SIGIO */ 10991#endif /* not USABLE_SIGIO */
11041 10992
11042 if (new_interrupt_input != interrupt_input) 10993 if (new_interrupt_input != interrupt_input)
11043 { 10994 {
@@ -11397,9 +11348,7 @@ init_keyboard (void)
11397 input_pending = 0; 11348 input_pending = 0;
11398 interrupt_input_blocked = 0; 11349 interrupt_input_blocked = 0;
11399 interrupt_input_pending = 0; 11350 interrupt_input_pending = 0;
11400#ifdef SYNC_INPUT
11401 pending_signals = 0; 11351 pending_signals = 0;
11402#endif
11403 11352
11404 /* This means that command_loop_1 won't try to select anything the first 11353 /* This means that command_loop_1 won't try to select anything the first
11405 time through. */ 11354 time through. */
@@ -11431,15 +11380,14 @@ init_keyboard (void)
11431 sigaction (SIGQUIT, &action, 0); 11380 sigaction (SIGQUIT, &action, 0);
11432#endif /* not DOS_NT */ 11381#endif /* not DOS_NT */
11433 } 11382 }
11434/* Note SIGIO has been undef'd if FIONREAD is missing. */ 11383#ifdef USABLE_SIGIO
11435#ifdef SIGIO
11436 if (!noninteractive) 11384 if (!noninteractive)
11437 { 11385 {
11438 struct sigaction action; 11386 struct sigaction action;
11439 emacs_sigaction_init (&action, deliver_input_available_signal); 11387 emacs_sigaction_init (&action, deliver_input_available_signal);
11440 sigaction (SIGIO, &action, 0); 11388 sigaction (SIGIO, &action, 0);
11441 } 11389 }
11442#endif /* SIGIO */ 11390#endif
11443 11391
11444/* Use interrupt input by default, if it works and noninterrupt input 11392/* Use interrupt input by default, if it works and noninterrupt input
11445 has deficiencies. */ 11393 has deficiencies. */
diff --git a/src/keymap.c b/src/keymap.c
index d79ff89ed67..66fb52061f9 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -40,7 +40,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
40 40
41#include <config.h> 41#include <config.h>
42#include <stdio.h> 42#include <stdio.h>
43#include <setjmp.h> 43
44#include "lisp.h" 44#include "lisp.h"
45#include "commands.h" 45#include "commands.h"
46#include "character.h" 46#include "character.h"
diff --git a/src/lisp.h b/src/lisp.h
index 41fa274a562..37416dc9464 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20#ifndef EMACS_LISP_H 20#ifndef EMACS_LISP_H
21#define EMACS_LISP_H 21#define EMACS_LISP_H
22 22
23#include <setjmp.h>
23#include <stdalign.h> 24#include <stdalign.h>
24#include <stdarg.h> 25#include <stdarg.h>
25#include <stdbool.h> 26#include <stdbool.h>
@@ -1968,7 +1969,25 @@ extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int);
1968 static struct Lisp_Kboard_Objfwd ko_fwd; \ 1969 static struct Lisp_Kboard_Objfwd ko_fwd; \
1969 defvar_kboard (&ko_fwd, lname, offsetof (KBOARD, vname ## _)); \ 1970 defvar_kboard (&ko_fwd, lname, offsetof (KBOARD, vname ## _)); \
1970 } while (0) 1971 } while (0)
1971 1972
1973/* Save and restore the instruction and environment pointers,
1974 without affecting the signal mask. */
1975
1976#ifdef HAVE__SETJMP
1977typedef jmp_buf sys_jmp_buf;
1978# define sys_setjmp(j) _setjmp (j)
1979# define sys_longjmp(j, v) _longjmp (j, v)
1980#elif defined HAVE_SIGSETJMP
1981typedef sigjmp_buf sys_jmp_buf;
1982# define sys_setjmp(j) sigsetjmp (j, 0)
1983# define sys_longjmp(j, v) siglongjmp (j, v)
1984#else
1985/* A platform that uses neither _longjmp nor siglongjmp; assume
1986 longjmp does not affect the sigmask. */
1987typedef jmp_buf sys_jmp_buf;
1988# define sys_setjmp(j) setjmp (j)
1989# define sys_longjmp(j, v) longjmp (j, v)
1990#endif
1972 1991
1973 1992
1974/* Structure for recording Lisp call stack for backtrace purposes. */ 1993/* Structure for recording Lisp call stack for backtrace purposes. */
@@ -2061,7 +2080,7 @@ struct catchtag
2061 Lisp_Object volatile val; 2080 Lisp_Object volatile val;
2062 struct catchtag *volatile next; 2081 struct catchtag *volatile next;
2063 struct gcpro *gcpro; 2082 struct gcpro *gcpro;
2064 jmp_buf jmp; 2083 sys_jmp_buf jmp;
2065 struct backtrace *backlist; 2084 struct backtrace *backlist;
2066 struct handler *handlerlist; 2085 struct handler *handlerlist;
2067 EMACS_INT lisp_eval_depth; 2086 EMACS_INT lisp_eval_depth;
@@ -2093,22 +2112,16 @@ extern char *stack_bottom;
2093 If quit-flag is set to `kill-emacs' the SIGINT handler has received 2112 If quit-flag is set to `kill-emacs' the SIGINT handler has received
2094 a request to exit Emacs when it is safe to do. */ 2113 a request to exit Emacs when it is safe to do. */
2095 2114
2096#ifdef SYNC_INPUT
2097extern void process_pending_signals (void); 2115extern void process_pending_signals (void);
2098extern int pending_signals; 2116extern int pending_signals;
2099#define ELSE_PENDING_SIGNALS \
2100 else if (pending_signals) \
2101 process_pending_signals ();
2102#else /* not SYNC_INPUT */
2103#define ELSE_PENDING_SIGNALS
2104#endif /* not SYNC_INPUT */
2105 2117
2106extern void process_quit_flag (void); 2118extern void process_quit_flag (void);
2107#define QUIT \ 2119#define QUIT \
2108 do { \ 2120 do { \
2109 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \ 2121 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \
2110 process_quit_flag (); \ 2122 process_quit_flag (); \
2111 ELSE_PENDING_SIGNALS \ 2123 else if (pending_signals) \
2124 process_pending_signals (); \
2112 } while (0) 2125 } while (0)
2113 2126
2114 2127
@@ -2832,8 +2845,6 @@ extern void memory_warnings (void *, void (*warnfun) (const char *));
2832/* Defined in alloc.c. */ 2845/* Defined in alloc.c. */
2833extern void check_pure_size (void); 2846extern void check_pure_size (void);
2834extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT); 2847extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT);
2835extern void reset_malloc_hooks (void);
2836extern void uninterrupt_malloc (void);
2837extern void malloc_warning (const char *); 2848extern void malloc_warning (const char *);
2838extern _Noreturn void memory_full (size_t); 2849extern _Noreturn void memory_full (size_t);
2839extern _Noreturn void buffer_memory_full (ptrdiff_t); 2850extern _Noreturn void buffer_memory_full (ptrdiff_t);
@@ -3029,7 +3040,6 @@ extern Lisp_Object Qand_rest;
3029extern Lisp_Object Vautoload_queue; 3040extern Lisp_Object Vautoload_queue;
3030extern Lisp_Object Vsignaling_function; 3041extern Lisp_Object Vsignaling_function;
3031extern Lisp_Object inhibit_lisp_code; 3042extern Lisp_Object inhibit_lisp_code;
3032extern int handling_signal;
3033#if BYTE_MARK_STACK 3043#if BYTE_MARK_STACK
3034extern struct catchtag *catchlist; 3044extern struct catchtag *catchlist;
3035extern struct handler *handlerlist; 3045extern struct handler *handlerlist;
diff --git a/src/lread.c b/src/lread.c
index 08a2e856c00..08d5f97292b 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -25,7 +25,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25#include <sys/file.h> 25#include <sys/file.h>
26#include <errno.h> 26#include <errno.h>
27#include <limits.h> /* For CHAR_BIT. */ 27#include <limits.h> /* For CHAR_BIT. */
28#include <setjmp.h>
29#include <stat-time.h> 28#include <stat-time.h>
30#include "lisp.h" 29#include "lisp.h"
31#include "intervals.h" 30#include "intervals.h"
diff --git a/src/macros.c b/src/macros.c
index e81068181b9..a507f12e343 100644
--- a/src/macros.c
+++ b/src/macros.c
@@ -19,7 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h> 22
23#include "lisp.h" 23#include "lisp.h"
24#include "macros.h" 24#include "macros.h"
25#include "commands.h" 25#include "commands.h"
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index 7b9c67bf135..24ecb2676da 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -482,7 +482,6 @@ WINDOW_H = $(SRC)/window.h \
482$(BLD)/alloc.$(O) : \ 482$(BLD)/alloc.$(O) : \
483 $(SRC)/alloc.c \ 483 $(SRC)/alloc.c \
484 $(SRC)/puresize.h \ 484 $(SRC)/puresize.h \
485 $(SRC)/syssignal.h \
486 $(SRC)/w32.h \ 485 $(SRC)/w32.h \
487 $(NT_INC)/unistd.h \ 486 $(NT_INC)/unistd.h \
488 $(GNU_LIB)/verify.h \ 487 $(GNU_LIB)/verify.h \
diff --git a/src/marker.c b/src/marker.c
index bfbb161a71d..0c4e8cb3b55 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -18,7 +18,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19 19
20#include <config.h> 20#include <config.h>
21#include <setjmp.h> 21
22#include "lisp.h" 22#include "lisp.h"
23#include "character.h" 23#include "character.h"
24#include "buffer.h" 24#include "buffer.h"
diff --git a/src/menu.c b/src/menu.c
index bfdc68ca118..7b01d1faefc 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <setjmp.h>
24#include <limits.h> /* for INT_MAX */ 23#include <limits.h> /* for INT_MAX */
25 24
26#include "lisp.h" 25#include "lisp.h"
diff --git a/src/minibuf.c b/src/minibuf.c
index 4ed480a8408..8a1e0ddde86 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#include <config.h> 21#include <config.h>
22#include <errno.h> 22#include <errno.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25 24
26#include "lisp.h" 25#include "lisp.h"
27#include "commands.h" 26#include "commands.h"
diff --git a/src/ns.mk b/src/ns.mk
deleted file mode 100644
index 77fbf5845d9..00000000000
--- a/src/ns.mk
+++ /dev/null
@@ -1,39 +0,0 @@
1### autodeps.mk --- src/Makefile fragment for GNU Emacs
2
3## Copyright (C) 2008-2012 Free Software Foundation, Inc.
4
5## This file is part of GNU Emacs.
6
7## GNU Emacs is free software: you can redistribute it and/or modify
8## it under the terms of the GNU General Public License as published by
9## the Free Software Foundation, either version 3 of the License, or
10## (at your option) any later version.
11##
12## GNU Emacs is distributed in the hope that it will be useful,
13## but WITHOUT ANY WARRANTY; without even the implied warranty of
14## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15## GNU General Public License for more details.
16##
17## You should have received a copy of the GNU General Public License
18## along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19
20### Commentary:
21
22## This is inserted in src/Makefile if HAVE_NS.
23
24## The only reason this is in a separate file is because $ns_appdir,
25## which appears as a target, is empty on non-NS builds. Some makes
26## do not like empty targets, even if they are never used.
27
28${ns_appdir}: ${ns_appsrc}
29 rm -fr ${ns_appdir}
30 ${MKDIR_P} ${ns_appdir}
31 ( cd ${ns_appsrc} ; tar cfh - . ) | ( cd ${ns_appdir} ; umask 022; tar xf - )
32
33${ns_appbindir}/Emacs: emacs${EXEEXT}
34 ${MKDIR_P} ${ns_appbindir}
35 cp -f emacs${EXEEXT} ${ns_appbindir}/Emacs
36
37ns-app: ${ns_appdir} ${ns_appbindir}/Emacs
38
39### ns.mk ends here
diff --git a/src/nsfns.m b/src/nsfns.m
index f73086eeee9..072005d2d3d 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -31,7 +31,6 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
31#include <config.h> 31#include <config.h>
32 32
33#include <math.h> 33#include <math.h>
34#include <setjmp.h>
35#include <c-strcase.h> 34#include <c-strcase.h>
36 35
37#include "lisp.h" 36#include "lisp.h"
@@ -1797,19 +1796,6 @@ terminate Emacs if we can't open the connection.
1797 SSDATA (display)); 1796 SSDATA (display));
1798 } 1797 }
1799 1798
1800 /* Register our external input/output types, used for determining
1801 applicable services and also drag/drop eligibility. */
1802 ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain];
1803 ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil]
1804 retain];
1805 ns_drag_types = [[NSArray arrayWithObjects:
1806 NSStringPboardType,
1807 NSTabularTextPboardType,
1808 NSFilenamesPboardType,
1809 NSURLPboardType,
1810 NSColorPboardType,
1811 NSFontPboardType, nil] retain];
1812
1813 return Qnil; 1799 return Qnil;
1814} 1800}
1815 1801
diff --git a/src/nsfont.m b/src/nsfont.m
index 1c9976ec6cc..eba1eb04765 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -23,7 +23,6 @@ Author: Adrian Robert (arobert@cogsci.ucsd.edu)
23/* This should be the first include, as it may set up #defines affecting 23/* This should be the first include, as it may set up #defines affecting
24 interpretation of even the system includes. */ 24 interpretation of even the system includes. */
25#include <config.h> 25#include <config.h>
26#include <setjmp.h>
27 26
28#include "lisp.h" 27#include "lisp.h"
29#include "dispextern.h" 28#include "dispextern.h"
diff --git a/src/nsimage.m b/src/nsimage.m
index 8a8a3ddaae4..668664c7a20 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -28,7 +28,6 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
28/* This should be the first include, as it may set up #defines affecting 28/* This should be the first include, as it may set up #defines affecting
29 interpretation of even the system includes. */ 29 interpretation of even the system includes. */
30#include <config.h> 30#include <config.h>
31#include <setjmp.h>
32 31
33#include "lisp.h" 32#include "lisp.h"
34#include "dispextern.h" 33#include "dispextern.h"
diff --git a/src/nsmenu.m b/src/nsmenu.m
index d0f3e45e939..907d3eac622 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -24,7 +24,6 @@ Carbon version by Yamamoto Mitsuharu. */
24/* This should be the first include, as it may set up #defines affecting 24/* This should be the first include, as it may set up #defines affecting
25 interpretation of even the system includes. */ 25 interpretation of even the system includes. */
26#include <config.h> 26#include <config.h>
27#include <setjmp.h>
28 27
29#include "lisp.h" 28#include "lisp.h"
30#include "window.h" 29#include "window.h"
@@ -589,10 +588,7 @@ extern NSString *NSMenuDidBeginTrackingNotification;
589 From 10.6 on, we could also use -[NSMenu propertiesToUpdate]: In the 588 From 10.6 on, we could also use -[NSMenu propertiesToUpdate]: In the
590 key press case, NSMenuPropertyItemImage (e.g.) won't be set. 589 key press case, NSMenuPropertyItemImage (e.g.) won't be set.
591 */ 590 */
592 if (trackingMenu == 0 591 if (trackingMenu == 0)
593 /* Also, don't try this if from an event picked up asynchronously,
594 as lots of lisp evaluation happens in ns_update_menubar. */
595 || handling_signal != 0)
596 return; 592 return;
597/*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */ 593/*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */
598 ns_update_menubar (frame, 1, self); 594 ns_update_menubar (frame, 1, self);
diff --git a/src/nsselect.m b/src/nsselect.m
index e0bbfe58636..95bc1a95957 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -28,7 +28,6 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
28/* This should be the first include, as it may set up #defines affecting 28/* This should be the first include, as it may set up #defines affecting
29 interpretation of even the system includes. */ 29 interpretation of even the system includes. */
30#include <config.h> 30#include <config.h>
31#include <setjmp.h>
32 31
33#include "lisp.h" 32#include "lisp.h"
34#include "nsterm.h" 33#include "nsterm.h"
diff --git a/src/print.c b/src/print.c
index 5643ff06774..6ae33ee23ef 100644
--- a/src/print.c
+++ b/src/print.c
@@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h> 24
25#include "lisp.h" 25#include "lisp.h"
26#include "character.h" 26#include "character.h"
27#include "buffer.h" 27#include "buffer.h"
diff --git a/src/process.c b/src/process.c
index f80b5e80c76..c654369627d 100644
--- a/src/process.c
+++ b/src/process.c
@@ -25,12 +25,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25 25
26#include <stdio.h> 26#include <stdio.h>
27#include <errno.h> 27#include <errno.h>
28#include <setjmp.h>
29#include <sys/types.h> /* Some typedefs are used in sys/file.h. */ 28#include <sys/types.h> /* Some typedefs are used in sys/file.h. */
30#include <sys/file.h> 29#include <sys/file.h>
31#include <sys/stat.h> 30#include <sys/stat.h>
32#include <setjmp.h>
33
34#include <unistd.h> 31#include <unistd.h>
35#include <fcntl.h> 32#include <fcntl.h>
36 33
@@ -75,6 +72,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
75#include <bsdtty.h> 72#include <bsdtty.h>
76#endif 73#endif
77 74
75#ifdef USG5_4
76# include <sys/stream.h>
77# include <sys/stropts.h>
78#endif
79
78#ifdef HAVE_RES_INIT 80#ifdef HAVE_RES_INIT
79#include <netinet/in.h> 81#include <netinet/in.h>
80#include <arpa/nameser.h> 82#include <arpa/nameser.h>
@@ -212,17 +214,13 @@ static EMACS_INT update_tick;
212 "non-destructive" select. So we require either native select, 214 "non-destructive" select. So we require either native select,
213 or emulation of select using FIONREAD. */ 215 or emulation of select using FIONREAD. */
214 216
215#ifdef BROKEN_DATAGRAM_SOCKETS 217#ifndef BROKEN_DATAGRAM_SOCKETS
216#undef DATAGRAM_SOCKETS 218# if defined HAVE_SELECT || defined USABLE_FIONREAD
217#else 219# if defined HAVE_SENDTO && defined HAVE_RECVFROM && defined EMSGSIZE
218#ifndef DATAGRAM_SOCKETS 220# define DATAGRAM_SOCKETS
219#if defined (HAVE_SELECT) || defined (FIONREAD) 221# endif
220#if defined (HAVE_SENDTO) && defined (HAVE_RECVFROM) && defined (EMSGSIZE) 222# endif
221#define DATAGRAM_SOCKETS 223#endif
222#endif /* HAVE_SENDTO && HAVE_RECVFROM && EMSGSIZE */
223#endif /* HAVE_SELECT || FIONREAD */
224#endif /* DATAGRAM_SOCKETS */
225#endif /* BROKEN_DATAGRAM_SOCKETS */
226 224
227#if defined HAVE_LOCAL_SOCKETS && defined DATAGRAM_SOCKETS 225#if defined HAVE_LOCAL_SOCKETS && defined DATAGRAM_SOCKETS
228# define HAVE_SEQPACKET 226# define HAVE_SEQPACKET
@@ -251,7 +249,7 @@ static int process_output_skip;
251#endif 249#endif
252 250
253static void create_process (Lisp_Object, char **, Lisp_Object); 251static void create_process (Lisp_Object, char **, Lisp_Object);
254#ifdef SIGIO 252#ifdef USABLE_SIGIO
255static int keyboard_bit_set (SELECT_TYPE *); 253static int keyboard_bit_set (SELECT_TYPE *);
256#endif 254#endif
257static void deactivate_process (Lisp_Object); 255static void deactivate_process (Lisp_Object);
@@ -1611,14 +1609,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1611#if !defined (WINDOWSNT) && defined (FD_CLOEXEC) 1609#if !defined (WINDOWSNT) && defined (FD_CLOEXEC)
1612 int wait_child_setup[2]; 1610 int wait_child_setup[2];
1613#endif 1611#endif
1612#ifdef SIGCHLD
1614 sigset_t blocked, procmask; 1613 sigset_t blocked, procmask;
1615 struct sigaction sigint_action;
1616 struct sigaction sigquit_action;
1617 struct sigaction sigpipe_action;
1618#ifdef AIX
1619 struct sigaction sighup_action;
1620#endif 1614#endif
1621 /* Use volatile to protect variables from being clobbered by longjmp. */ 1615 /* Use volatile to protect variables from being clobbered by vfork. */
1622 volatile int forkin, forkout; 1616 volatile int forkin, forkout;
1623 volatile int pty_flag = 0; 1617 volatile int pty_flag = 0;
1624 1618
@@ -1710,25 +1704,13 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1710 XPROCESS (process)->pty_flag = pty_flag; 1704 XPROCESS (process)->pty_flag = pty_flag;
1711 pset_status (XPROCESS (process), Qrun); 1705 pset_status (XPROCESS (process), Qrun);
1712 1706
1707#ifdef SIGCHLD
1713 /* Delay interrupts until we have a chance to store 1708 /* Delay interrupts until we have a chance to store
1714 the new fork's pid in its process structure */ 1709 the new fork's pid in its process structure */
1715 sigemptyset (&blocked); 1710 sigemptyset (&blocked);
1716#ifdef SIGCHLD
1717 sigaddset (&blocked, SIGCHLD); 1711 sigaddset (&blocked, SIGCHLD);
1718#endif
1719#ifdef HAVE_WORKING_VFORK
1720 /* On many hosts (e.g. Solaris 2.4), if a vforked child calls `signal',
1721 this sets the parent's signal handlers as well as the child's.
1722 So delay all interrupts whose handlers the child might munge,
1723 and record the current handlers so they can be restored later. */
1724 sigaddset (&blocked, SIGINT ); sigaction (SIGINT , 0, &sigint_action );
1725 sigaddset (&blocked, SIGQUIT); sigaction (SIGQUIT, 0, &sigquit_action);
1726 sigaddset (&blocked, SIGPIPE); sigaction (SIGPIPE, 0, &sigpipe_action);
1727#ifdef AIX
1728 sigaddset (&blocked, SIGHUP ); sigaction (SIGHUP , 0, &sighup_action );
1729#endif
1730#endif /* HAVE_WORKING_VFORK */
1731 pthread_sigmask (SIG_BLOCK, &blocked, &procmask); 1712 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
1713#endif
1732 1714
1733 FD_SET (inchannel, &input_wait_mask); 1715 FD_SET (inchannel, &input_wait_mask);
1734 FD_SET (inchannel, &non_keyboard_wait_mask); 1716 FD_SET (inchannel, &non_keyboard_wait_mask);
@@ -1881,8 +1863,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1881 in the child. */ 1863 in the child. */
1882 signal (SIGPIPE, SIG_DFL); 1864 signal (SIGPIPE, SIG_DFL);
1883 1865
1866#ifdef SIGCHLD
1884 /* Stop blocking signals in the child. */ 1867 /* Stop blocking signals in the child. */
1885 pthread_sigmask (SIG_SETMASK, &procmask, 0); 1868 pthread_sigmask (SIG_SETMASK, &procmask, 0);
1869#endif
1886 1870
1887 if (pty_flag) 1871 if (pty_flag)
1888 child_setup_tty (xforkout); 1872 child_setup_tty (xforkout);
@@ -1961,19 +1945,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1961#endif 1945#endif
1962 } 1946 }
1963 1947
1964 /* Restore the signal state whether vfork succeeded or not. 1948#ifdef SIGCHLD
1965 (We will signal an error, below, if it failed.) */
1966#ifdef HAVE_WORKING_VFORK
1967 /* Restore the parent's signal handlers. */
1968 sigaction (SIGINT, &sigint_action, 0);
1969 sigaction (SIGQUIT, &sigquit_action, 0);
1970 sigaction (SIGPIPE, &sigpipe_action, 0);
1971#ifdef AIX
1972 sigaction (SIGHUP, &sighup_action, 0);
1973#endif
1974#endif /* HAVE_WORKING_VFORK */
1975 /* Stop blocking signals in the parent. */ 1949 /* Stop blocking signals in the parent. */
1976 pthread_sigmask (SIG_SETMASK, &procmask, 0); 1950 pthread_sigmask (SIG_SETMASK, &procmask, 0);
1951#endif
1977 1952
1978 /* Now generate the error if vfork failed. */ 1953 /* Now generate the error if vfork failed. */
1979 if (pid < 0) 1954 if (pid < 0)
@@ -4397,10 +4372,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4397 Otherwise, do pending quit if requested. */ 4372 Otherwise, do pending quit if requested. */
4398 if (read_kbd >= 0) 4373 if (read_kbd >= 0)
4399 QUIT; 4374 QUIT;
4400#ifdef SYNC_INPUT
4401 else 4375 else
4402 process_pending_signals (); 4376 process_pending_signals ();
4403#endif
4404 4377
4405 /* Exit now if the cell we're waiting for became non-nil. */ 4378 /* Exit now if the cell we're waiting for became non-nil. */
4406 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) 4379 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
@@ -4836,7 +4809,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4836 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) 4809 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
4837 break; 4810 break;
4838 4811
4839#ifdef SIGIO 4812#ifdef USABLE_SIGIO
4840 /* If we think we have keyboard input waiting, but didn't get SIGIO, 4813 /* If we think we have keyboard input waiting, but didn't get SIGIO,
4841 go read it. This can happen with X on BSD after logging out. 4814 go read it. This can happen with X on BSD after logging out.
4842 In that case, there really is no input and no SIGIO, 4815 In that case, there really is no input and no SIGIO,
@@ -5420,7 +5393,7 @@ read_process_output (Lisp_Object proc, register int channel)
5420 5393
5421/* Sending data to subprocess */ 5394/* Sending data to subprocess */
5422 5395
5423static jmp_buf send_process_frame; 5396static sys_jmp_buf send_process_frame;
5424static Lisp_Object process_sent_to; 5397static Lisp_Object process_sent_to;
5425 5398
5426static _Noreturn void 5399static _Noreturn void
@@ -5430,7 +5403,7 @@ handle_pipe_signal (int sig)
5430 sigemptyset (&unblocked); 5403 sigemptyset (&unblocked);
5431 sigaddset (&unblocked, SIGPIPE); 5404 sigaddset (&unblocked, SIGPIPE);
5432 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0); 5405 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
5433 _longjmp (send_process_frame, 1); 5406 sys_longjmp (send_process_frame, 1);
5434} 5407}
5435 5408
5436static void 5409static void
@@ -5639,7 +5612,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5639 /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2, 5612 /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2,
5640 CFLAGS="-g -O": The value of the parameter `proc' is clobbered 5613 CFLAGS="-g -O": The value of the parameter `proc' is clobbered
5641 when returning with longjmp despite being declared volatile. */ 5614 when returning with longjmp despite being declared volatile. */
5642 if (!_setjmp (send_process_frame)) 5615 if (!sys_setjmp (send_process_frame))
5643 { 5616 {
5644 p = XPROCESS (proc); /* Repair any setjmp clobbering. */ 5617 p = XPROCESS (proc); /* Repair any setjmp clobbering. */
5645 process_sent_to = proc; 5618 process_sent_to = proc;
@@ -6853,7 +6826,7 @@ delete_gpm_wait_descriptor (int desc)
6853 6826
6854# endif 6827# endif
6855 6828
6856# ifdef SIGIO 6829# ifdef USABLE_SIGIO
6857 6830
6858/* Return nonzero if *MASK has a bit set 6831/* Return nonzero if *MASK has a bit set
6859 that corresponds to one of the keyboard input descriptors. */ 6832 that corresponds to one of the keyboard input descriptors. */
diff --git a/src/ralloc.c b/src/ralloc.c
index 74834333aa3..9a4b1ada229 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -25,7 +25,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25#ifdef emacs 25#ifdef emacs
26 26
27#include <config.h> 27#include <config.h>
28#include <setjmp.h> 28
29#include "lisp.h" /* Needed for VALBITS. */ 29#include "lisp.h" /* Needed for VALBITS. */
30#include "blockinput.h" 30#include "blockinput.h"
31 31
@@ -1204,9 +1204,15 @@ r_alloc_init (void)
1204 UNBLOCK_INPUT; 1204 UNBLOCK_INPUT;
1205#else 1205#else
1206#ifndef SYSTEM_MALLOC 1206#ifndef SYSTEM_MALLOC
1207 /* Give GNU malloc's morecore some hysteresis 1207 /* Give GNU malloc's morecore some hysteresis so that we move all
1208 so that we move all the relocatable blocks much less often. */ 1208 the relocatable blocks much less often. The number used to be
1209 __malloc_extra_blocks = 64; 1209 64, but alloc.c would override that with 32 in code that was
1210 removed when SYNC_INPUT became the only input handling mode.
1211 That code was conditioned on !DOUG_LEA_MALLOC, so the call to
1212 mallopt above is left unchanged. (Actually, I think there's no
1213 system nowadays that uses DOUG_LEA_MALLOC and also uses
1214 REL_ALLOC.) */
1215 __malloc_extra_blocks = 32;
1210#endif 1216#endif
1211#endif 1217#endif
1212 1218
diff --git a/src/regex.c b/src/regex.c
index 472ef727979..17562043df1 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -126,7 +126,6 @@
126 that make sense only in Emacs. */ 126 that make sense only in Emacs. */
127#ifdef emacs 127#ifdef emacs
128 128
129# include <setjmp.h>
130# include "lisp.h" 129# include "lisp.h"
131# include "character.h" 130# include "character.h"
132# include "buffer.h" 131# include "buffer.h"
@@ -1832,9 +1831,9 @@ typedef struct
1832/* The next available element. */ 1831/* The next available element. */
1833#define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) 1832#define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail])
1834 1833
1835/* Explicit quit checking is only used on NTemacs and whenever we 1834/* Explicit quit checking is needed for Emacs, which uses polling to
1836 use polling to process input events. */ 1835 process input events. */
1837#if defined emacs && (defined WINDOWSNT || defined SYNC_INPUT) && defined QUIT 1836#ifdef emacs
1838extern int immediate_quit; 1837extern int immediate_quit;
1839# define IMMEDIATE_QUIT_CHECK \ 1838# define IMMEDIATE_QUIT_CHECK \
1840 do { \ 1839 do { \
diff --git a/src/region-cache.c b/src/region-cache.c
index c3eb087aade..832f4bfd214 100644
--- a/src/region-cache.c
+++ b/src/region-cache.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25 24
26#include "lisp.h" 25#include "lisp.h"
27#include "character.h" 26#include "character.h"
diff --git a/src/scroll.c b/src/scroll.c
index 79dd464b29e..71ce43b2e48 100644
--- a/src/scroll.c
+++ b/src/scroll.c
@@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h> 24
25#include "lisp.h" 25#include "lisp.h"
26#include "termchar.h" 26#include "termchar.h"
27#include "dispextern.h" 27#include "dispextern.h"
diff --git a/src/search.c b/src/search.c
index 72bd5605709..1735ade5d8a 100644
--- a/src/search.c
+++ b/src/search.c
@@ -20,7 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21 21
22#include <config.h> 22#include <config.h>
23#include <setjmp.h> 23
24#include "lisp.h" 24#include "lisp.h"
25#include "syntax.h" 25#include "syntax.h"
26#include "category.h" 26#include "category.h"
@@ -674,7 +674,7 @@ scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end,
674 obstacle --- the last character the dumb search loop should 674 obstacle --- the last character the dumb search loop should
675 examine. */ 675 examine. */
676 ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end) - 1; 676 ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end) - 1;
677 ptrdiff_t start_byte = CHAR_TO_BYTE (start); 677 ptrdiff_t start_byte;
678 ptrdiff_t tem; 678 ptrdiff_t tem;
679 679
680 /* If we're looking for a newline, consult the newline cache 680 /* If we're looking for a newline, consult the newline cache
@@ -684,18 +684,22 @@ scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end,
684 ptrdiff_t next_change; 684 ptrdiff_t next_change;
685 immediate_quit = 0; 685 immediate_quit = 0;
686 while (region_cache_forward 686 while (region_cache_forward
687 (current_buffer, newline_cache, start_byte, &next_change)) 687 (current_buffer, newline_cache, start, &next_change))
688 start_byte = next_change; 688 start = next_change;
689 immediate_quit = allow_quit; 689 immediate_quit = allow_quit;
690 690
691 start_byte = CHAR_TO_BYTE (start);
692
691 /* START should never be after END. */ 693 /* START should never be after END. */
692 if (start_byte > ceiling_byte) 694 if (start_byte > ceiling_byte)
693 start_byte = ceiling_byte; 695 start_byte = ceiling_byte;
694 696
695 /* Now the text after start is an unknown region, and 697 /* Now the text after start is an unknown region, and
696 next_change is the position of the next known region. */ 698 next_change is the position of the next known region. */
697 ceiling_byte = min (next_change - 1, ceiling_byte); 699 ceiling_byte = min (CHAR_TO_BYTE (next_change) - 1, ceiling_byte);
698 } 700 }
701 else
702 start_byte = CHAR_TO_BYTE (start);
699 703
700 /* The dumb loop can only scan text stored in contiguous 704 /* The dumb loop can only scan text stored in contiguous
701 bytes. BUFFER_CEILING_OF returns the last character 705 bytes. BUFFER_CEILING_OF returns the last character
@@ -747,7 +751,7 @@ scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end,
747 { 751 {
748 /* The last character to check before the next obstacle. */ 752 /* The last character to check before the next obstacle. */
749 ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end); 753 ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end);
750 ptrdiff_t start_byte = CHAR_TO_BYTE (start); 754 ptrdiff_t start_byte;
751 ptrdiff_t tem; 755 ptrdiff_t tem;
752 756
753 /* Consult the newline cache, if appropriate. */ 757 /* Consult the newline cache, if appropriate. */
@@ -756,18 +760,22 @@ scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end,
756 ptrdiff_t next_change; 760 ptrdiff_t next_change;
757 immediate_quit = 0; 761 immediate_quit = 0;
758 while (region_cache_backward 762 while (region_cache_backward
759 (current_buffer, newline_cache, start_byte, &next_change)) 763 (current_buffer, newline_cache, start, &next_change))
760 start_byte = next_change; 764 start = next_change;
761 immediate_quit = allow_quit; 765 immediate_quit = allow_quit;
762 766
767 start_byte = CHAR_TO_BYTE (start);
768
763 /* Start should never be at or before end. */ 769 /* Start should never be at or before end. */
764 if (start_byte <= ceiling_byte) 770 if (start_byte <= ceiling_byte)
765 start_byte = ceiling_byte + 1; 771 start_byte = ceiling_byte + 1;
766 772
767 /* Now the text before start is an unknown region, and 773 /* Now the text before start is an unknown region, and
768 next_change is the position of the next known region. */ 774 next_change is the position of the next known region. */
769 ceiling_byte = max (next_change, ceiling_byte); 775 ceiling_byte = max (CHAR_TO_BYTE (next_change), ceiling_byte);
770 } 776 }
777 else
778 start_byte = CHAR_TO_BYTE (start);
771 779
772 /* Stop scanning before the gap. */ 780 /* Stop scanning before the gap. */
773 tem = BUFFER_FLOOR_OF (start_byte - 1); 781 tem = BUFFER_FLOOR_OF (start_byte - 1);
diff --git a/src/sheap.c b/src/sheap.c
index 3ae14b5daec..f6022ea3ce7 100644
--- a/src/sheap.c
+++ b/src/sheap.c
@@ -20,7 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <setjmp.h> 23
24#include "lisp.h" 24#include "lisp.h"
25 25
26#include <unistd.h> 26#include <unistd.h>
@@ -93,4 +93,3 @@ report_sheap_usage (int die_if_pure_storage_exceeded)
93 bss_sbrk_ptr - bss_sbrk_buffer, STATIC_HEAP_SIZE); 93 bss_sbrk_ptr - bss_sbrk_buffer, STATIC_HEAP_SIZE);
94 message ("%s", buf); 94 message ("%s", buf);
95} 95}
96
diff --git a/src/sound.c b/src/sound.c
index 5729d704b6a..0ee85312fd3 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -44,7 +44,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
44#include <unistd.h> 44#include <unistd.h>
45#include <sys/types.h> 45#include <sys/types.h>
46#include <errno.h> 46#include <errno.h>
47#include <setjmp.h> 47
48#include "lisp.h" 48#include "lisp.h"
49#include "dispextern.h" 49#include "dispextern.h"
50#include "atimer.h" 50#include "atimer.h"
@@ -314,7 +314,7 @@ sound_perror (const char *msg)
314 int saved_errno = errno; 314 int saved_errno = errno;
315 315
316 turn_on_atimers (1); 316 turn_on_atimers (1);
317#ifdef SIGIO 317#ifdef USABLE_SIGIO
318 { 318 {
319 sigset_t unblocked; 319 sigset_t unblocked;
320 sigemptyset (&unblocked); 320 sigemptyset (&unblocked);
@@ -732,7 +732,7 @@ static void
732vox_configure (struct sound_device *sd) 732vox_configure (struct sound_device *sd)
733{ 733{
734 int val; 734 int val;
735#ifdef SIGIO 735#ifdef USABLE_SIGIO
736 sigset_t blocked; 736 sigset_t blocked;
737#endif 737#endif
738 738
@@ -742,7 +742,7 @@ vox_configure (struct sound_device *sd)
742 interrupted by a signal. Block the ones we know to cause 742 interrupted by a signal. Block the ones we know to cause
743 troubles. */ 743 troubles. */
744 turn_on_atimers (0); 744 turn_on_atimers (0);
745#ifdef SIGIO 745#ifdef USABLE_SIGIO
746 sigemptyset (&blocked); 746 sigemptyset (&blocked);
747 sigaddset (&blocked, SIGIO); 747 sigaddset (&blocked, SIGIO);
748 pthread_sigmask (SIG_BLOCK, &blocked, 0); 748 pthread_sigmask (SIG_BLOCK, &blocked, 0);
@@ -778,7 +778,7 @@ vox_configure (struct sound_device *sd)
778 } 778 }
779 779
780 turn_on_atimers (1); 780 turn_on_atimers (1);
781#ifdef SIGIO 781#ifdef USABLE_SIGIO
782 pthread_sigmask (SIG_UNBLOCK, &blocked, 0); 782 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
783#endif 783#endif
784} 784}
@@ -794,7 +794,7 @@ vox_close (struct sound_device *sd)
794 /* On GNU/Linux, it seems that the device driver doesn't like to 794 /* On GNU/Linux, it seems that the device driver doesn't like to
795 be interrupted by a signal. Block the ones we know to cause 795 be interrupted by a signal. Block the ones we know to cause
796 troubles. */ 796 troubles. */
797#ifdef SIGIO 797#ifdef USABLE_SIGIO
798 sigset_t blocked; 798 sigset_t blocked;
799 sigemptyset (&blocked); 799 sigemptyset (&blocked);
800 sigaddset (&blocked, SIGIO); 800 sigaddset (&blocked, SIGIO);
@@ -806,7 +806,7 @@ vox_close (struct sound_device *sd)
806 ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL); 806 ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL);
807 807
808 turn_on_atimers (1); 808 turn_on_atimers (1);
809#ifdef SIGIO 809#ifdef USABLE_SIGIO
810 pthread_sigmask (SIG_UNBLOCK, &blocked, 0); 810 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
811#endif 811#endif
812 812
diff --git a/src/syntax.c b/src/syntax.c
index fdd9353bb87..91ef4e66663 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#include <config.h> 21#include <config.h>
22 22
23#include <sys/types.h> 23#include <sys/types.h>
24#include <setjmp.h> 24
25#include "lisp.h" 25#include "lisp.h"
26#include "commands.h" 26#include "commands.h"
27#include "character.h" 27#include "character.h"
diff --git a/src/sysdep.c b/src/sysdep.c
index 0f16d1a7645..dbfd9efc7d4 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23 23
24#include <execinfo.h> 24#include <execinfo.h>
25#include <stdio.h> 25#include <stdio.h>
26#include <setjmp.h>
27#ifdef HAVE_PWD_H 26#ifdef HAVE_PWD_H
28#include <pwd.h> 27#include <pwd.h>
29#include <grp.h> 28#include <grp.h>
@@ -107,9 +106,6 @@ extern char *getwd (char *);
107 106
108static int emacs_get_tty (int, struct emacs_tty *); 107static int emacs_get_tty (int, struct emacs_tty *);
109static int emacs_set_tty (int, struct emacs_tty *, int); 108static int emacs_set_tty (int, struct emacs_tty *, int);
110#if defined TIOCNOTTY || defined USG5 || defined CYGWIN
111static _Noreturn void croak (char *);
112#endif
113 109
114/* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */ 110/* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */
115#ifndef ULLONG_MAX 111#ifndef ULLONG_MAX
@@ -513,7 +509,7 @@ sys_subshell (void)
513 saved_handlers[0].code = SIGINT; 509 saved_handlers[0].code = SIGINT;
514 saved_handlers[1].code = SIGQUIT; 510 saved_handlers[1].code = SIGQUIT;
515 saved_handlers[2].code = SIGTERM; 511 saved_handlers[2].code = SIGTERM;
516#ifdef SIGIO 512#ifdef USABLE_SIGIO
517 saved_handlers[3].code = SIGIO; 513 saved_handlers[3].code = SIGIO;
518 saved_handlers[4].code = 0; 514 saved_handlers[4].code = 0;
519#else 515#else
@@ -642,121 +638,75 @@ restore_signal_handlers (struct save_signal *saved_handlers)
642 } 638 }
643} 639}
644 640
645#ifndef SIGIO 641#ifdef USABLE_SIGIO
646/* If SIGIO is broken, don't do anything. */
647void
648init_sigio (int fd)
649{
650}
651
652static void
653reset_sigio (int fd)
654{
655}
656
657void
658request_sigio (void)
659{
660}
661
662void
663unrequest_sigio (void)
664{
665}
666
667#else
668#ifdef F_SETFL
669
670static int old_fcntl_flags[MAXDESC]; 642static int old_fcntl_flags[MAXDESC];
643#endif
671 644
672void 645void
673init_sigio (int fd) 646init_sigio (int fd)
674{ 647{
675#ifdef FASYNC 648#ifdef USABLE_SIGIO
676 old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC; 649 old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC;
677 fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC); 650 fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC);
678#endif
679 interrupts_deferred = 0; 651 interrupts_deferred = 0;
652#endif
680} 653}
681 654
682static void 655static void
683reset_sigio (int fd) 656reset_sigio (int fd)
684{ 657{
685#ifdef FASYNC 658#ifdef USABLE_SIGIO
686 fcntl (fd, F_SETFL, old_fcntl_flags[fd]); 659 fcntl (fd, F_SETFL, old_fcntl_flags[fd]);
687#endif 660#endif
688} 661}
689 662
690#ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */
691/* XXX Uhm, FASYNC is not used anymore here. */
692/* XXX Yeah, but you need it for SIGIO, don't you? */
693
694void 663void
695request_sigio (void) 664request_sigio (void)
696{ 665{
666#ifdef USABLE_SIGIO
697 sigset_t unblocked; 667 sigset_t unblocked;
698 668
699 if (noninteractive) 669 if (noninteractive)
700 return; 670 return;
701 671
702 sigemptyset (&unblocked); 672 sigemptyset (&unblocked);
703#ifdef SIGWINCH 673# ifdef SIGWINCH
704 sigaddset (&unblocked, SIGWINCH); 674 sigaddset (&unblocked, SIGWINCH);
705#endif 675# endif
706 sigaddset (&unblocked, SIGIO); 676 sigaddset (&unblocked, SIGIO);
707 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0); 677 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
708 678
709 interrupts_deferred = 0; 679 interrupts_deferred = 0;
680#endif
710} 681}
711 682
712void 683void
713unrequest_sigio (void) 684unrequest_sigio (void)
714{ 685{
686#ifdef USABLE_SIGIO
715 sigset_t blocked; 687 sigset_t blocked;
716 688
717 if (noninteractive) 689 if (noninteractive)
718 return; 690 return;
719 691
720#if 0 /* XXX What's wrong with blocking SIGIO under X? */
721 if (x_display_list)
722 return;
723#endif
724
725 sigemptyset (&blocked); 692 sigemptyset (&blocked);
726#ifdef SIGWINCH 693# ifdef SIGWINCH
727 sigaddset (&blocked, SIGWINCH); 694 sigaddset (&blocked, SIGWINCH);
728#endif 695# endif
729 sigaddset (&blocked, SIGIO); 696 sigaddset (&blocked, SIGIO);
730 pthread_sigmask (SIG_BLOCK, &blocked, 0); 697 pthread_sigmask (SIG_BLOCK, &blocked, 0);
731 interrupts_deferred = 1; 698 interrupts_deferred = 1;
732} 699#endif
733
734#else /* no FASYNC */
735#ifndef MSDOS
736
737void
738request_sigio (void)
739{
740 if (noninteractive || read_socket_hook)
741 return;
742
743 croak ("request_sigio");
744} 700}
745 701
746void 702void
747unrequest_sigio (void) 703ignore_sigio (void)
748{ 704{
749 if (noninteractive || read_socket_hook) 705#ifdef USABLE_SIGIO
750 return; 706 signal (SIGIO, SIG_IGN);
751 707#endif
752 croak ("unrequest_sigio");
753} 708}
754 709
755#endif /* MSDOS */
756#endif /* FASYNC */
757#endif /* F_SETFL */
758#endif /* SIGIO */
759
760 710
761/* Getting and setting emacs_tty structures. */ 711/* Getting and setting emacs_tty structures. */
762 712
@@ -1497,27 +1447,21 @@ emacs_sigaction_init (struct sigaction *action, signal_handler_t handler)
1497 action->sa_handler = handler; 1447 action->sa_handler = handler;
1498 action->sa_flags = 0; 1448 action->sa_flags = 0;
1499#if defined (SA_RESTART) 1449#if defined (SA_RESTART)
1500 /* Emacs mostly works better with restartable system services. If this 1450 /* SA_RESTART causes interruptible functions with timeouts (e.g.,
1501 flag exists, we probably want to turn it on here. 1451 'select') to reset their timeout on some platforms (e.g.,
1502 However, on some systems (only hpux11 at present) this resets the 1452 HP-UX 11), which is not what we want. Also, when Emacs is
1503 timeout of `select' which means that `select' never finishes if 1453 interactive, we don't want SA_RESTART because we need to poll
1504 it keeps getting signals.
1505 We define BROKEN_SA_RESTART on those systems. */
1506 /* It's not clear why the comment above says "mostly works better". --Stef
1507 When SYNC_INPUT is set, we don't want SA_RESTART because we need to poll
1508 for pending input so we need long-running syscalls to be interrupted 1454 for pending input so we need long-running syscalls to be interrupted
1509 after a signal that sets the interrupt_input_pending flag. */ 1455 after a signal that sets the interrupt_input_pending flag. */
1510 /* Non-interactive keyboard input goes through stdio, where we always 1456 /* Non-interactive keyboard input goes through stdio, where we always
1511 want restartable system calls. */ 1457 want restartable system calls. */
1512# if defined (BROKEN_SA_RESTART) || defined (SYNC_INPUT)
1513 if (noninteractive) 1458 if (noninteractive)
1514# endif
1515 action->sa_flags = SA_RESTART; 1459 action->sa_flags = SA_RESTART;
1516#endif 1460#endif
1517} 1461}
1518 1462
1519#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD 1463#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
1520pthread_t main_thread; 1464static pthread_t main_thread;
1521#endif 1465#endif
1522 1466
1523/* If we are on the main thread, handle the signal SIG with HANDLER. 1467/* If we are on the main thread, handle the signal SIG with HANDLER.
@@ -1964,11 +1908,9 @@ emacs_write (int fildes, const char *buf, ptrdiff_t nbyte)
1964 { 1908 {
1965 if (errno == EINTR) 1909 if (errno == EINTR)
1966 { 1910 {
1967#ifdef SYNC_INPUT
1968 /* I originally used `QUIT' but that might causes files to 1911 /* I originally used `QUIT' but that might causes files to
1969 be truncated if you hit C-g in the middle of it. --Stef */ 1912 be truncated if you hit C-g in the middle of it. --Stef */
1970 process_pending_signals (); 1913 process_pending_signals ();
1971#endif
1972 continue; 1914 continue;
1973 } 1915 }
1974 else 1916 else
@@ -2051,19 +1993,6 @@ getwd (char *pathname)
2051} 1993}
2052 1994
2053#endif /* !defined (HAVE_GETWD) || defined (BROKEN_GETWD) */ 1995#endif /* !defined (HAVE_GETWD) || defined (BROKEN_GETWD) */
2054
2055/*
2056 * This function will go away as soon as all the stubs fixed. (fnf)
2057 */
2058
2059void
2060croak (char *badfunc)
2061{
2062 printf ("%s not yet implemented\r\n", badfunc);
2063 reset_all_sys_modes ();
2064 exit (1);
2065}
2066
2067#endif /* USG */ 1996#endif /* USG */
2068 1997
2069/* Directory routines for systems that don't have them. */ 1998/* Directory routines for systems that don't have them. */
diff --git a/src/syssignal.h b/src/syssignal.h
index c5529ae718a..e309e6725b7 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -34,27 +34,6 @@ typedef void (*signal_handler_t) (int);
34 34
35extern void emacs_sigaction_init (struct sigaction *, signal_handler_t); 35extern void emacs_sigaction_init (struct sigaction *, signal_handler_t);
36 36
37#if ! (defined TIOCNOTTY || defined USG5 || defined CYGWIN)
38_Noreturn void croak (char *);
39#endif
40
41/* Interrupt input is not used if there is no FIONREAD. */
42#include <sys/ioctl.h>
43#if defined BROKEN_SIGIO || ! defined FIONREAD || defined BROKEN_FIONREAD
44# undef SIGIO
45#endif
46
47/* These are only used by AIX */
48#if defined (SIGPOLL) && defined (BROKEN_SIGPOLL)
49#undef SIGPOLL
50#endif
51#if defined (SIGAIO) && defined (BROKEN_SIGAIO)
52#undef SIGAIO
53#endif
54#if defined (SIGPTY) && defined (BROKEN_SIGPTY)
55#undef SIGPTY
56#endif
57
58#if NSIG < NSIG_MINIMUM 37#if NSIG < NSIG_MINIMUM
59# undef NSIG 38# undef NSIG
60# define NSIG NSIG_MINIMUM 39# define NSIG NSIG_MINIMUM
@@ -85,8 +64,4 @@ _Noreturn void croak (char *);
85char *strsignal (int); 64char *strsignal (int);
86#endif 65#endif
87 66
88#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
89extern pthread_t main_thread;
90#endif
91
92void handle_on_main_thread (int, signal_handler_t); 67void handle_on_main_thread (int, signal_handler_t);
diff --git a/src/systty.h b/src/systty.h
index b660441a91e..b7f36c6c259 100644
--- a/src/systty.h
+++ b/src/systty.h
@@ -17,10 +17,8 @@ You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19/* Include the proper files. */ 19/* Include the proper files. */
20
20#ifndef DOS_NT 21#ifndef DOS_NT
21#ifndef NO_TERMIO
22#include <termio.h>
23#endif /* not NO_TERMIO */
24#include <termios.h> 22#include <termios.h>
25#include <fcntl.h> 23#include <fcntl.h>
26#endif /* not DOS_NT */ 24#endif /* not DOS_NT */
@@ -39,15 +37,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
39#include <unistd.h> 37#include <unistd.h>
40 38
41 39
42/* Special cases - inhibiting the use of certain features. */
43
44/* Allow configure to inhibit use of FIONREAD. */
45#ifdef BROKEN_FIONREAD
46#undef FIONREAD
47#undef ASYNC
48#endif
49
50
51/* Try to establish the correct character to disable terminal functions 40/* Try to establish the correct character to disable terminal functions
52 in a system-independent manner. Note that USG (at least) define 41 in a system-independent manner. Note that USG (at least) define
53 _POSIX_VDISABLE as 0! */ 42 _POSIX_VDISABLE as 0! */
diff --git a/src/term.c b/src/term.c
index 0eaf76a13df..f4117d67dec 100644
--- a/src/term.c
+++ b/src/term.c
@@ -25,7 +25,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25#include <sys/file.h> 25#include <sys/file.h>
26#include <sys/time.h> 26#include <sys/time.h>
27#include <unistd.h> 27#include <unistd.h>
28#include <setjmp.h>
29 28
30#include "lisp.h" 29#include "lisp.h"
31#include "termchar.h" 30#include "termchar.h"
@@ -2944,8 +2943,7 @@ dissociate_if_controlling_tty (int fd)
2944 emacs_close (fd); 2943 emacs_close (fd);
2945 pthread_sigmask (SIG_UNBLOCK, &blocked, 0); 2944 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
2946#else 2945#else
2947 /* Unknown system. */ 2946# error "Unknown system."
2948 croak ();
2949#endif /* ! TIOCNOTTY */ 2947#endif /* ! TIOCNOTTY */
2950#endif /* ! USG */ 2948#endif /* ! USG */
2951 } 2949 }
diff --git a/src/termcap.c b/src/termcap.c
index d1b05e8df94..e494cd113d9 100644
--- a/src/termcap.c
+++ b/src/termcap.c
@@ -19,7 +19,6 @@ Boston, MA 02110-1301, USA. */
19 19
20/* Emacs config.h may rename various library functions such as malloc. */ 20/* Emacs config.h may rename various library functions such as malloc. */
21#include <config.h> 21#include <config.h>
22#include <setjmp.h>
23#include <sys/file.h> 22#include <sys/file.h>
24#include <fcntl.h> 23#include <fcntl.h>
25#include <unistd.h> 24#include <unistd.h>
diff --git a/src/terminal.c b/src/terminal.c
index c51a18dfa61..719c2a36111 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#define TERMHOOKS_INLINE EXTERN_INLINE 21#define TERMHOOKS_INLINE EXTERN_INLINE
22 22
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25 24
26#include "lisp.h" 25#include "lisp.h"
27#include "frame.h" 26#include "frame.h"
diff --git a/src/terminfo.c b/src/terminfo.c
index ca2d89a000b..124c452a4a9 100644
--- a/src/terminfo.c
+++ b/src/terminfo.c
@@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19#include <config.h> 19#include <config.h>
20#include "tparam.h" 20#include "tparam.h"
21 21
22#include <setjmp.h>
23#include "lisp.h" 22#include "lisp.h"
24 23
25/* Define these variables that serve as global parameters to termcap, 24/* Define these variables that serve as global parameters to termcap,
diff --git a/src/textprop.c b/src/textprop.c
index 2a9efba1c45..872912ea706 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20#include <setjmp.h> 20
21#include "lisp.h" 21#include "lisp.h"
22#include "intervals.h" 22#include "intervals.h"
23#include "character.h" 23#include "character.h"
diff --git a/src/tparam.c b/src/tparam.c
index 58a825c90d7..164f61d471b 100644
--- a/src/tparam.c
+++ b/src/tparam.c
@@ -19,7 +19,7 @@ Boston, MA 02110-1301, USA. */
19 19
20/* Emacs config.h may rename various library functions such as malloc. */ 20/* Emacs config.h may rename various library functions such as malloc. */
21#include <config.h> 21#include <config.h>
22#include <setjmp.h> 22
23#include "lisp.h" /* for xmalloc */ 23#include "lisp.h" /* for xmalloc */
24#include "tparam.h" 24#include "tparam.h"
25 25
diff --git a/src/undo.c b/src/undo.c
index 9cd1d5f9f67..e878ef4dcf9 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -18,7 +18,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19 19
20#include <config.h> 20#include <config.h>
21#include <setjmp.h> 21
22#include "lisp.h" 22#include "lisp.h"
23#include "character.h" 23#include "character.h"
24#include "buffer.h" 24#include "buffer.h"
diff --git a/src/unexaix.c b/src/unexaix.c
index c09156296f7..c01a22a79f6 100644
--- a/src/unexaix.c
+++ b/src/unexaix.c
@@ -89,7 +89,6 @@ static int adjust_lnnoptrs (int, int, const char *);
89 89
90static int pagemask; 90static int pagemask;
91 91
92#include <setjmp.h>
93#include "lisp.h" 92#include "lisp.h"
94 93
95static void 94static void
diff --git a/src/unexcoff.c b/src/unexcoff.c
index e83042a379d..966dd58cb6e 100644
--- a/src/unexcoff.c
+++ b/src/unexcoff.c
@@ -120,7 +120,6 @@ static int pagemask;
120 120
121#define ADDR_CORRECT(x) ((char *)(x) - (char*)0) 121#define ADDR_CORRECT(x) ((char *)(x) - (char*)0)
122 122
123#include <setjmp.h>
124#include "lisp.h" 123#include "lisp.h"
125 124
126static void 125static void
diff --git a/src/unexcw.c b/src/unexcw.c
index eae534cf4dd..96c4b4a9aec 100644
--- a/src/unexcw.c
+++ b/src/unexcw.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#include <config.h> 21#include <config.h>
22#include "unexec.h" 22#include "unexec.h"
23 23
24#include <setjmp.h>
25#include <lisp.h> 24#include <lisp.h>
26#include <stdio.h> 25#include <stdio.h>
27#include <fcntl.h> 26#include <fcntl.h>
diff --git a/src/unexsol.c b/src/unexsol.c
index 336f3b4faea..470206d5838 100644
--- a/src/unexsol.c
+++ b/src/unexsol.c
@@ -4,7 +4,6 @@
4#include "unexec.h" 4#include "unexec.h"
5 5
6#include <dlfcn.h> 6#include <dlfcn.h>
7#include <setjmp.h>
8 7
9#include "lisp.h" 8#include "lisp.h"
10#include "character.h" 9#include "character.h"
diff --git a/src/vm-limit.c b/src/vm-limit.c
index cf697b56fdf..8de0acd1bb2 100644
--- a/src/vm-limit.c
+++ b/src/vm-limit.c
@@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20#include <setjmp.h>
21#include <unistd.h> /* for 'environ', on AIX */ 20#include <unistd.h> /* for 'environ', on AIX */
22#include "lisp.h" 21#include "lisp.h"
23#include "mem-limits.h" 22#include "mem-limits.h"
diff --git a/src/w16select.c b/src/w16select.c
index 2026de7421d..a3f6f1fb9ae 100644
--- a/src/w16select.c
+++ b/src/w16select.c
@@ -31,7 +31,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31#include <dpmi.h> 31#include <dpmi.h>
32#include <go32.h> 32#include <go32.h>
33#include <sys/farptr.h> 33#include <sys/farptr.h>
34#include <setjmp.h>
35#include "lisp.h" 34#include "lisp.h"
36#include "dispextern.h" /* frame.h seems to want this */ 35#include "dispextern.h" /* frame.h seems to want this */
37#include "frame.h" /* Need this to get the X window of selected_frame */ 36#include "frame.h" /* Need this to get the X window of selected_frame */
diff --git a/src/w32.c b/src/w32.c
index 04f7471577c..bcb0511e2fa 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -33,7 +33,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
33#include <sys/utime.h> 33#include <sys/utime.h>
34#include <mbstring.h> /* for _mbspbrk */ 34#include <mbstring.h> /* for _mbspbrk */
35#include <math.h> 35#include <math.h>
36#include <setjmp.h>
37#include <time.h> 36#include <time.h>
38 37
39/* must include CRT headers *before* config.h */ 38/* must include CRT headers *before* config.h */
diff --git a/src/w32console.c b/src/w32console.c
index 76585851e7f..b22b09af2f2 100644
--- a/src/w32console.c
+++ b/src/w32console.c
@@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26 26
27#include <stdio.h> 27#include <stdio.h>
28#include <windows.h> 28#include <windows.h>
29#include <setjmp.h>
30 29
31#include "lisp.h" 30#include "lisp.h"
32#include "character.h" 31#include "character.h"
diff --git a/src/w32fns.c b/src/w32fns.c
index ec1acbd89d9..be008bb18c8 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26#include <limits.h> 26#include <limits.h>
27#include <errno.h> 27#include <errno.h>
28#include <math.h> 28#include <math.h>
29#include <setjmp.h>
30 29
31#include "lisp.h" 30#include "lisp.h"
32#include "w32term.h" 31#include "w32term.h"
diff --git a/src/w32font.c b/src/w32font.c
index 8b3a0e4312e..833b7cdfb25 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#include <math.h> 21#include <math.h>
22#include <ctype.h> 22#include <ctype.h>
23#include <commdlg.h> 23#include <commdlg.h>
24#include <setjmp.h>
25 24
26#include "lisp.h" 25#include "lisp.h"
27#include "w32term.h" 26#include "w32term.h"
diff --git a/src/w32heap.c b/src/w32heap.c
index 26cc9aa0a0f..dc65198f90b 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22 22
23#include <config.h> 23#include <config.h>
24#include <stdio.h> 24#include <stdio.h>
25#include <setjmp.h>
26 25
27#include "w32heap.h" 26#include "w32heap.h"
28#include "lisp.h" /* for VALMASK */ 27#include "lisp.h" /* for VALMASK */
diff --git a/src/w32inevt.c b/src/w32inevt.c
index 731dd6715dc..ee07db5335b 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -25,7 +25,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25#include <config.h> 25#include <config.h>
26#include <stdio.h> 26#include <stdio.h>
27#include <windows.h> 27#include <windows.h>
28#include <setjmp.h>
29 28
30#ifndef MOUSE_MOVED 29#ifndef MOUSE_MOVED
31#define MOUSE_MOVED 1 30#define MOUSE_MOVED 1
diff --git a/src/w32menu.c b/src/w32menu.c
index d4de73a0de7..fa7db64f147 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22#include <signal.h> 22#include <signal.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <mbstring.h> 24#include <mbstring.h>
25#include <setjmp.h>
26 25
27#include "lisp.h" 26#include "lisp.h"
28#include "keyboard.h" 27#include "keyboard.h"
diff --git a/src/w32proc.c b/src/w32proc.c
index 74427e76a4f..26a0925ad87 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -28,7 +28,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
28#include <fcntl.h> 28#include <fcntl.h>
29#include <signal.h> 29#include <signal.h>
30#include <sys/file.h> 30#include <sys/file.h>
31#include <setjmp.h>
32 31
33/* must include CRT headers *before* config.h */ 32/* must include CRT headers *before* config.h */
34#include <config.h> 33#include <config.h>
diff --git a/src/w32reg.c b/src/w32reg.c
index 9c727ae5ab7..8a6a3c853b1 100644
--- a/src/w32reg.c
+++ b/src/w32reg.c
@@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19/* Written by Kevin Gallo */ 19/* Written by Kevin Gallo */
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h>
23#include "lisp.h" 22#include "lisp.h"
24#include "w32term.h" 23#include "w32term.h"
25#include "blockinput.h" 24#include "blockinput.h"
diff --git a/src/w32select.c b/src/w32select.c
index 3fb88d4f17f..11c68c9c617 100644
--- a/src/w32select.c
+++ b/src/w32select.c
@@ -73,7 +73,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
73 */ 73 */
74 74
75#include <config.h> 75#include <config.h>
76#include <setjmp.h>
77#include "lisp.h" 76#include "lisp.h"
78#include "w32term.h" /* for all of the w32 includes */ 77#include "w32term.h" /* for all of the w32 includes */
79#include "w32heap.h" /* os_subtype */ 78#include "w32heap.h" /* os_subtype */
diff --git a/src/w32term.c b/src/w32term.c
index 28c1c593cf6..6244728b264 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20#include <config.h> 20#include <config.h>
21#include <signal.h> 21#include <signal.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <setjmp.h>
24#include "lisp.h" 23#include "lisp.h"
25#include "blockinput.h" 24#include "blockinput.h"
26#include "w32term.h" 25#include "w32term.h"
@@ -4163,6 +4162,7 @@ w32_read_socket (struct terminal *terminal, int expected,
4163 if (interrupt_input_blocked) 4162 if (interrupt_input_blocked)
4164 { 4163 {
4165 interrupt_input_pending = 1; 4164 interrupt_input_pending = 1;
4165 pending_signals = 1;
4166 return -1; 4166 return -1;
4167 } 4167 }
4168 4168
diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c
index cf99d14dc77..5d160b9d42f 100644
--- a/src/w32uniscribe.c
+++ b/src/w32uniscribe.c
@@ -27,7 +27,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
27#define _WIN32_WINNT 0x500 27#define _WIN32_WINNT 0x500
28#include <windows.h> 28#include <windows.h>
29#include <usp10.h> 29#include <usp10.h>
30#include <setjmp.h>
31 30
32#include "lisp.h" 31#include "lisp.h"
33#include "w32term.h" 32#include "w32term.h"
diff --git a/src/w32xfns.c b/src/w32xfns.c
index 820dbcc76c6..33f40fc7c01 100644
--- a/src/w32xfns.c
+++ b/src/w32xfns.c
@@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19#include <config.h> 19#include <config.h>
20#include <signal.h> 20#include <signal.h>
21#include <stdio.h> 21#include <stdio.h>
22#include <setjmp.h>
23#include "lisp.h" 22#include "lisp.h"
24#include "keyboard.h" 23#include "keyboard.h"
25#include "frame.h" 24#include "frame.h"
diff --git a/src/widget.c b/src/widget.c
index 0100acc8143..fd5ad167125 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -30,7 +30,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
30 30
31#include <config.h> 31#include <config.h>
32#include <stdio.h> 32#include <stdio.h>
33#include <setjmp.h> 33
34#include "lisp.h" 34#include "lisp.h"
35#include "xterm.h" 35#include "xterm.h"
36 36
diff --git a/src/window.c b/src/window.c
index cf296a707e3..2589596ccfd 100644
--- a/src/window.c
+++ b/src/window.c
@@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23#define WINDOW_INLINE EXTERN_INLINE 23#define WINDOW_INLINE EXTERN_INLINE
24 24
25#include <stdio.h> 25#include <stdio.h>
26#include <setjmp.h>
27 26
28#include "lisp.h" 27#include "lisp.h"
29#include "character.h" 28#include "character.h"
@@ -1857,23 +1856,23 @@ return value is a list of elements of the form (PARAMETER . VALUE). */)
1857DEFUN ("window-parameter", Fwindow_parameter, Swindow_parameter, 1856DEFUN ("window-parameter", Fwindow_parameter, Swindow_parameter,
1858 2, 2, 0, 1857 2, 2, 0,
1859 doc: /* Return WINDOW's value for PARAMETER. 1858 doc: /* Return WINDOW's value for PARAMETER.
1860WINDOW must be a valid window and defaults to the selected one. */) 1859WINDOW can be any window and defaults to the selected one. */)
1861 (Lisp_Object window, Lisp_Object parameter) 1860 (Lisp_Object window, Lisp_Object parameter)
1862{ 1861{
1863 Lisp_Object result; 1862 Lisp_Object result;
1864 1863
1865 result = Fassq (parameter, decode_valid_window (window)->window_parameters); 1864 result = Fassq (parameter, decode_any_window (window)->window_parameters);
1866 return CDR_SAFE (result); 1865 return CDR_SAFE (result);
1867} 1866}
1868 1867
1869DEFUN ("set-window-parameter", Fset_window_parameter, 1868DEFUN ("set-window-parameter", Fset_window_parameter,
1870 Sset_window_parameter, 3, 3, 0, 1869 Sset_window_parameter, 3, 3, 0,
1871 doc: /* Set WINDOW's value of PARAMETER to VALUE. 1870 doc: /* Set WINDOW's value of PARAMETER to VALUE.
1872WINDOW must be a valid window and defaults to the selected one. 1871WINDOW can be any window and defaults to the selected one.
1873Return VALUE. */) 1872Return VALUE. */)
1874 (Lisp_Object window, Lisp_Object parameter, Lisp_Object value) 1873 (Lisp_Object window, Lisp_Object parameter, Lisp_Object value)
1875{ 1874{
1876 register struct window *w = decode_valid_window (window); 1875 register struct window *w = decode_any_window (window);
1877 Lisp_Object old_alist_elt; 1876 Lisp_Object old_alist_elt;
1878 1877
1879 old_alist_elt = Fassq (parameter, w->window_parameters); 1878 old_alist_elt = Fassq (parameter, w->window_parameters);
@@ -2659,7 +2658,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2659 /* Check for a window that has a killed buffer. */ 2658 /* Check for a window that has a killed buffer. */
2660 case CHECK_ALL_WINDOWS: 2659 case CHECK_ALL_WINDOWS:
2661 if (! NILP (w->buffer) 2660 if (! NILP (w->buffer)
2662 && NILP (BVAR (XBUFFER (w->buffer), name))) 2661 && !BUFFER_LIVE_P (XBUFFER (w->buffer)))
2663 emacs_abort (); 2662 emacs_abort ();
2664 break; 2663 break;
2665 2664
@@ -3264,7 +3263,7 @@ This function runs `window-scroll-functions' before running
3264 XSETWINDOW (window, w); 3263 XSETWINDOW (window, w);
3265 buffer = Fget_buffer (buffer_or_name); 3264 buffer = Fget_buffer (buffer_or_name);
3266 CHECK_BUFFER (buffer); 3265 CHECK_BUFFER (buffer);
3267 if (NILP (BVAR (XBUFFER (buffer), name))) 3266 if (!BUFFER_LIVE_P (XBUFFER (buffer)))
3268 error ("Attempt to display deleted buffer"); 3267 error ("Attempt to display deleted buffer");
3269 3268
3270 tem = w->buffer; 3269 tem = w->buffer;
@@ -3329,7 +3328,7 @@ displaying that buffer. */)
3329 3328
3330 if (STRINGP (object)) 3329 if (STRINGP (object))
3331 object = Fget_buffer (object); 3330 object = Fget_buffer (object);
3332 if (BUFFERP (object) && !NILP (BVAR (XBUFFER (object), name))) 3331 if (BUFFERP (object) && BUFFER_LIVE_P (XBUFFER (object)))
3333 { 3332 {
3334 /* Walk all windows looking for buffer, and force update 3333 /* Walk all windows looking for buffer, and force update
3335 of each of those windows. */ 3334 of each of those windows. */
@@ -5543,7 +5542,7 @@ the return value is nil. Otherwise the value is t. */)
5543 saved_windows = XVECTOR (data->saved_windows); 5542 saved_windows = XVECTOR (data->saved_windows);
5544 5543
5545 new_current_buffer = data->current_buffer; 5544 new_current_buffer = data->current_buffer;
5546 if (NILP (BVAR (XBUFFER (new_current_buffer), name))) 5545 if (!BUFFER_LIVE_P (XBUFFER (new_current_buffer)))
5547 new_current_buffer = Qnil; 5546 new_current_buffer = Qnil;
5548 else 5547 else
5549 { 5548 {
@@ -5618,7 +5617,7 @@ the return value is nil. Otherwise the value is t. */)
5618 w = XWINDOW (window); 5617 w = XWINDOW (window);
5619 if (!NILP (w->buffer) 5618 if (!NILP (w->buffer)
5620 && !EQ (w->buffer, p->buffer) 5619 && !EQ (w->buffer, p->buffer)
5621 && !NILP (BVAR (XBUFFER (p->buffer), name))) 5620 && BUFFER_LIVE_P (XBUFFER (p->buffer)))
5622 /* If a window we restore gets another buffer, record the 5621 /* If a window we restore gets another buffer, record the
5623 window's old buffer. */ 5622 window's old buffer. */
5624 call1 (Qrecord_window_buffer, window); 5623 call1 (Qrecord_window_buffer, window);
@@ -5768,7 +5767,7 @@ the return value is nil. Otherwise the value is t. */)
5768 if (NILP (p->buffer)) 5767 if (NILP (p->buffer))
5769 /* An internal window. */ 5768 /* An internal window. */
5770 wset_buffer (w, p->buffer); 5769 wset_buffer (w, p->buffer);
5771 else if (!NILP (BVAR (XBUFFER (p->buffer), name))) 5770 else if (BUFFER_LIVE_P (XBUFFER (p->buffer)))
5772 /* If saved buffer is alive, install it. */ 5771 /* If saved buffer is alive, install it. */
5773 { 5772 {
5774 wset_buffer (w, p->buffer); 5773 wset_buffer (w, p->buffer);
@@ -5787,7 +5786,7 @@ the return value is nil. Otherwise the value is t. */)
5787 Fgoto_char (w->pointm); 5786 Fgoto_char (w->pointm);
5788 } 5787 }
5789 else if (!NILP (w->buffer) 5788 else if (!NILP (w->buffer)
5790 && !NILP (BVAR (XBUFFER (w->buffer), name))) 5789 && BUFFER_LIVE_P (XBUFFER (w->buffer)))
5791 /* Keep window's old buffer; make sure the markers are 5790 /* Keep window's old buffer; make sure the markers are
5792 real. */ 5791 real. */
5793 { 5792 {
diff --git a/src/xdisp.c b/src/xdisp.c
index 3536e04fe8d..ef36cf5c867 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -273,7 +273,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
273#include <config.h> 273#include <config.h>
274#include <stdio.h> 274#include <stdio.h>
275#include <limits.h> 275#include <limits.h>
276#include <setjmp.h>
277 276
278#include "lisp.h" 277#include "lisp.h"
279#include "keyboard.h" 278#include "keyboard.h"
@@ -3671,7 +3670,7 @@ handle_fontified_prop (struct it *it)
3671 } 3670 }
3672 /* There isn't much we can reasonably do to protect against 3671 /* There isn't much we can reasonably do to protect against
3673 misbehaving fontification, but here's a fig leaf. */ 3672 misbehaving fontification, but here's a fig leaf. */
3674 else if (!NILP (BVAR (obuf, name))) 3673 else if (BUFFER_LIVE_P (obuf))
3675 set_buffer_internal_1 (obuf); 3674 set_buffer_internal_1 (obuf);
3676 3675
3677 /* The fontification code may have added/removed text. 3676 /* The fontification code may have added/removed text.
@@ -9345,12 +9344,6 @@ add_to_log (const char *format, Lisp_Object arg1, Lisp_Object arg2)
9345 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 9344 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
9346 USE_SAFE_ALLOCA; 9345 USE_SAFE_ALLOCA;
9347 9346
9348 /* Do nothing if called asynchronously. Inserting text into
9349 a buffer may call after-change-functions and alike and
9350 that would means running Lisp asynchronously. */
9351 if (handling_signal)
9352 return;
9353
9354 fmt = msg = Qnil; 9347 fmt = msg = Qnil;
9355 GCPRO4 (fmt, msg, arg1, arg2); 9348 GCPRO4 (fmt, msg, arg1, arg2);
9356 9349
@@ -9963,7 +9956,7 @@ ensure_echo_area_buffers (void)
9963 9956
9964 for (i = 0; i < 2; ++i) 9957 for (i = 0; i < 2; ++i)
9965 if (!BUFFERP (echo_buffer[i]) 9958 if (!BUFFERP (echo_buffer[i])
9966 || NILP (BVAR (XBUFFER (echo_buffer[i]), name))) 9959 || !BUFFER_LIVE_P (XBUFFER (echo_buffer[i])))
9967 { 9960 {
9968 char name[30]; 9961 char name[30];
9969 Lisp_Object old_buffer; 9962 Lisp_Object old_buffer;
@@ -21144,8 +21137,7 @@ are the selected window and the WINDOW's buffer). */)
21144 : EQ (face, Qtool_bar) ? TOOL_BAR_FACE_ID 21137 : EQ (face, Qtool_bar) ? TOOL_BAR_FACE_ID
21145 : DEFAULT_FACE_ID; 21138 : DEFAULT_FACE_ID;
21146 21139
21147 if (XBUFFER (buffer) != current_buffer) 21140 old_buffer = current_buffer;
21148 old_buffer = current_buffer;
21149 21141
21150 /* Save things including mode_line_proptrans_alist, 21142 /* Save things including mode_line_proptrans_alist,
21151 and set that to nil so that we don't alter the outer value. */ 21143 and set that to nil so that we don't alter the outer value. */
@@ -21156,8 +21148,7 @@ are the selected window and the WINDOW's buffer). */)
21156 mode_line_proptrans_alist = Qnil; 21148 mode_line_proptrans_alist = Qnil;
21157 21149
21158 Fselect_window (window, Qt); 21150 Fselect_window (window, Qt);
21159 if (old_buffer) 21151 set_buffer_internal_1 (XBUFFER (buffer));
21160 set_buffer_internal_1 (XBUFFER (buffer));
21161 21152
21162 init_iterator (&it, w, -1, -1, NULL, face_id); 21153 init_iterator (&it, w, -1, -1, NULL, face_id);
21163 21154
@@ -23167,7 +23158,8 @@ right_overwritten (struct glyph_string *s)
23167 { 23158 {
23168 int x = 0, i; 23159 int x = 0, i;
23169 struct glyph *glyphs = s->row->glyphs[s->area]; 23160 struct glyph *glyphs = s->row->glyphs[s->area];
23170 int first = (s->first_glyph - glyphs) + (s->cmp ? 1 : s->nchars); 23161 int first = (s->first_glyph - glyphs
23162 + (s->first_glyph->type == COMPOSITE_GLYPH ? 1 : s->nchars));
23171 int end = s->row->used[s->area]; 23163 int end = s->row->used[s->area];
23172 23164
23173 for (i = first; i < end && s->right_overhang > x; ++i) 23165 for (i = first; i < end && s->right_overhang > x; ++i)
@@ -23190,7 +23182,8 @@ right_overwriting (struct glyph_string *s)
23190 int i, k, x; 23182 int i, k, x;
23191 int end = s->row->used[s->area]; 23183 int end = s->row->used[s->area];
23192 struct glyph *glyphs = s->row->glyphs[s->area]; 23184 struct glyph *glyphs = s->row->glyphs[s->area];
23193 int first = (s->first_glyph - glyphs) + (s->cmp ? 1 : s->nchars); 23185 int first = (s->first_glyph - glyphs
23186 + (s->first_glyph->type == COMPOSITE_GLYPH ? 1 : s->nchars));
23194 23187
23195 k = -1; 23188 k = -1;
23196 x = 0; 23189 x = 0;
diff --git a/src/xfaces.c b/src/xfaces.c
index c113c1a37b7..c240a05c6c0 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -204,7 +204,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
204#include <sys/types.h> 204#include <sys/types.h>
205#include <sys/stat.h> 205#include <sys/stat.h>
206#include <stdio.h> /* This needs to be before termchar.h */ 206#include <stdio.h> /* This needs to be before termchar.h */
207#include <setjmp.h>
208 207
209#include "lisp.h" 208#include "lisp.h"
210#include "character.h" 209#include "character.h"
diff --git a/src/xfns.c b/src/xfns.c
index 90b54d12345..8304a3df04f 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20#include <config.h> 20#include <config.h>
21#include <stdio.h> 21#include <stdio.h>
22#include <math.h> 22#include <math.h>
23#include <setjmp.h>
24#include <unistd.h> 23#include <unistd.h>
25 24
26/* This makes the fields of a Display accessible, in Xlib header files. */ 25/* This makes the fields of a Display accessible, in Xlib header files. */
diff --git a/src/xfont.c b/src/xfont.c
index 7755b780815..1f2fd13f1b7 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25#include <X11/Xlib.h> 24#include <X11/Xlib.h>
26 25
27#include "lisp.h" 26#include "lisp.h"
diff --git a/src/xftfont.c b/src/xftfont.c
index 404b9124099..9f52eb8b233 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h>
25#include <X11/Xlib.h> 24#include <X11/Xlib.h>
26#include <X11/Xft/Xft.h> 25#include <X11/Xft/Xft.h>
27 26
diff --git a/src/xgselect.c b/src/xgselect.c
index 5f4c7edfb79..c161564a322 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -19,14 +19,12 @@ along with GNU Emacs. If not, see <http§://www.gnu.org/licenses/>. */
19 19
20#include <config.h> 20#include <config.h>
21 21
22#include <setjmp.h>
23#include "xgselect.h" 22#include "xgselect.h"
24 23
25#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) 24#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
26 25
27#include <glib.h> 26#include <glib.h>
28#include <errno.h> 27#include <errno.h>
29#include <setjmp.h>
30#include "xterm.h" 28#include "xterm.h"
31 29
32int 30int
diff --git a/src/xmenu.c b/src/xmenu.c
index 605db13e149..d03a4bc974b 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -33,7 +33,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
33#include <config.h> 33#include <config.h>
34 34
35#include <stdio.h> 35#include <stdio.h>
36#include <setjmp.h>
37 36
38#include "lisp.h" 37#include "lisp.h"
39#include "keyboard.h" 38#include "keyboard.h"
diff --git a/src/xml.c b/src/xml.c
index 7bc6130b8b1..b668525cf26 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#ifdef HAVE_LIBXML2 21#ifdef HAVE_LIBXML2
22 22
23#include <setjmp.h>
24#include <libxml/tree.h> 23#include <libxml/tree.h>
25#include <libxml/parser.h> 24#include <libxml/parser.h>
26#include <libxml/HTMLparser.h> 25#include <libxml/HTMLparser.h>
diff --git a/src/xrdb.c b/src/xrdb.c
index 624bafa5e92..73672c9617c 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26#include <epaths.h> 26#include <epaths.h>
27 27
28#include <stdio.h> 28#include <stdio.h>
29#include <setjmp.h>
30 29
31#include "lisp.h" 30#include "lisp.h"
32 31
diff --git a/src/xselect.c b/src/xselect.c
index 5a3b7452c6d..ab199e0b9b9 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22#include <config.h> 22#include <config.h>
23#include <limits.h> 23#include <limits.h>
24#include <stdio.h> /* termhooks.h needs this */ 24#include <stdio.h> /* termhooks.h needs this */
25#include <setjmp.h>
26 25
27#ifdef HAVE_SYS_TYPES_H 26#ifdef HAVE_SYS_TYPES_H
28#include <sys/types.h> 27#include <sys/types.h>
diff --git a/src/xsettings.c b/src/xsettings.c
index a28d75d9422..58c84495489 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#include <float.h> 22#include <float.h>
23#include <limits.h> 23#include <limits.h>
24#include <setjmp.h>
25#include <fcntl.h> 24#include <fcntl.h>
26#include "lisp.h" 25#include "lisp.h"
27#include "xterm.h" 26#include "xterm.h"
@@ -711,12 +710,12 @@ apply_xft_settings (struct x_display_info *dpyinfo,
711 if (send_event_p) 710 if (send_event_p)
712 store_config_changed_event (Qfont_render, 711 store_config_changed_event (Qfont_render,
713 XCAR (dpyinfo->name_list_element)); 712 XCAR (dpyinfo->name_list_element));
714 Vxft_settings 713 Vxft_settings
715 = make_formatted_string (buf, format, 714 = make_formatted_string (buf, format,
716 oldsettings.aa, oldsettings.hinting, 715 oldsettings.aa, oldsettings.hinting,
717 oldsettings.rgba, oldsettings.lcdfilter, 716 oldsettings.rgba, oldsettings.lcdfilter,
718 oldsettings.hintstyle, oldsettings.dpi); 717 oldsettings.hintstyle, oldsettings.dpi);
719 718
720 } 719 }
721 else 720 else
722 FcPatternDestroy (pat); 721 FcPatternDestroy (pat);
diff --git a/src/xsmfns.c b/src/xsmfns.c
index cddbb2aae86..8067899f931 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -29,7 +29,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29#include <unistd.h> 29#include <unistd.h>
30#include <sys/param.h> 30#include <sys/param.h>
31#include <stdio.h> 31#include <stdio.h>
32#include <setjmp.h>
33 32
34#include "lisp.h" 33#include "lisp.h"
35#include "systime.h" 34#include "systime.h"
diff --git a/src/xterm.c b/src/xterm.c
index 8a702800c38..5bc87d0ec64 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22 22
23#include <config.h> 23#include <config.h>
24#include <stdio.h> 24#include <stdio.h>
25#include <setjmp.h>
26 25
27#ifdef HAVE_X_WINDOWS 26#ifdef HAVE_X_WINDOWS
28 27
@@ -47,7 +46,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
47 46
48#include <fcntl.h> 47#include <fcntl.h>
49#include <errno.h> 48#include <errno.h>
50#include <setjmp.h>
51#include <sys/stat.h> 49#include <sys/stat.h>
52/* Caused redefinition of DBL_DIG on Netbsd; seems not to be needed. */ 50/* Caused redefinition of DBL_DIG on Netbsd; seems not to be needed. */
53/* #include <sys/param.h> */ 51/* #include <sys/param.h> */
@@ -7140,25 +7138,17 @@ XTread_socket (struct terminal *terminal, int expected, struct input_event *hold
7140 if (interrupt_input_blocked) 7138 if (interrupt_input_blocked)
7141 { 7139 {
7142 interrupt_input_pending = 1; 7140 interrupt_input_pending = 1;
7143#ifdef SYNC_INPUT
7144 pending_signals = 1; 7141 pending_signals = 1;
7145#endif
7146 return -1; 7142 return -1;
7147 } 7143 }
7148 7144
7149 interrupt_input_pending = 0; 7145 interrupt_input_pending = 0;
7150#ifdef SYNC_INPUT
7151 pending_signals = pending_atimers; 7146 pending_signals = pending_atimers;
7152#endif
7153 BLOCK_INPUT; 7147 BLOCK_INPUT;
7154 7148
7155 /* So people can tell when we have read the available input. */ 7149 /* So people can tell when we have read the available input. */
7156 input_signal_count++; 7150 input_signal_count++;
7157 7151
7158#ifndef SYNC_INPUT
7159 ++handling_signal;
7160#endif
7161
7162 /* For debugging, this gives a way to fake an I/O error. */ 7152 /* For debugging, this gives a way to fake an I/O error. */
7163 if (terminal->display_info.x == XTread_socket_fake_io_error) 7153 if (terminal->display_info.x == XTread_socket_fake_io_error)
7164 { 7154 {
@@ -7247,9 +7237,6 @@ XTread_socket (struct terminal *terminal, int expected, struct input_event *hold
7247 pending_autoraise_frame = 0; 7237 pending_autoraise_frame = 0;
7248 } 7238 }
7249 7239
7250#ifndef SYNC_INPUT
7251 --handling_signal;
7252#endif
7253 UNBLOCK_INPUT; 7240 UNBLOCK_INPUT;
7254 7241
7255 return count; 7242 return count;
@@ -7804,7 +7791,6 @@ x_connection_closed (Display *dpy, const char *error_message)
7804 7791
7805 error_msg = alloca (strlen (error_message) + 1); 7792 error_msg = alloca (strlen (error_message) + 1);
7806 strcpy (error_msg, error_message); 7793 strcpy (error_msg, error_message);
7807 handling_signal = 0;
7808 7794
7809 /* Inhibit redisplay while frames are being deleted. */ 7795 /* Inhibit redisplay while frames are being deleted. */
7810 specbind (Qinhibit_redisplay, Qt); 7796 specbind (Qinhibit_redisplay, Qt);
@@ -7892,7 +7878,7 @@ For details, see etc/PROBLEMS.\n",
7892 { 7878 {
7893 sigset_t unblocked; 7879 sigset_t unblocked;
7894 sigemptyset (&unblocked); 7880 sigemptyset (&unblocked);
7895#ifdef SIGIO 7881#ifdef USABLE_SIGIO
7896 sigaddset (&unblocked, SIGIO); 7882 sigaddset (&unblocked, SIGIO);
7897#endif 7883#endif
7898 sigaddset (&unblocked, SIGALRM); 7884 sigaddset (&unblocked, SIGALRM);
@@ -10439,10 +10425,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10439 fcntl (connection, F_SETOWN, getpid ()); 10425 fcntl (connection, F_SETOWN, getpid ());
10440#endif /* ! defined (F_SETOWN) */ 10426#endif /* ! defined (F_SETOWN) */
10441 10427
10442#ifdef SIGIO
10443 if (interrupt_input) 10428 if (interrupt_input)
10444 init_sigio (connection); 10429 init_sigio (connection);
10445#endif /* ! defined (SIGIO) */
10446 10430
10447#ifdef USE_LUCID 10431#ifdef USE_LUCID
10448 { 10432 {