aboutsummaryrefslogtreecommitdiffstats
path: root/src/keyboard.c
diff options
context:
space:
mode:
authorDaniel Colascione2012-09-17 04:07:36 -0800
committerDaniel Colascione2012-09-17 04:07:36 -0800
commit2ab329f3b5d52a39f0a45c3d9c129f1c19560142 (patch)
tree6dd6784d63e54cb18071df8e28fbdbc27d418728 /src/keyboard.c
parentf701ab72dd55460d23c8b029550aa4d7ecef3cfa (diff)
parentbb7dce392f6d9d5fc4b9d7de09ff920a52f07669 (diff)
downloademacs-2ab329f3b5d52a39f0a45c3d9c129f1c19560142.tar.gz
emacs-2ab329f3b5d52a39f0a45c3d9c129f1c19560142.zip
Merge from trunk
Diffstat (limited to 'src/keyboard.c')
-rw-r--r--src/keyboard.c321
1 files changed, 137 insertions, 184 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 992d1a97b3c..451ffd9d600 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -21,9 +21,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#define KEYBOARD_INLINE EXTERN_INLINE 22#define KEYBOARD_INLINE EXTERN_INLINE
23 23
24#include <signal.h>
25#include <stdio.h> 24#include <stdio.h>
26#include <setjmp.h> 25
27#include "lisp.h" 26#include "lisp.h"
28#include "termchar.h" 27#include "termchar.h"
29#include "termopts.h" 28#include "termopts.h"
@@ -57,6 +56,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
57#include <sys/ioctl.h> 56#include <sys/ioctl.h>
58#endif /* not MSDOS */ 57#endif /* not MSDOS */
59 58
59#if defined USABLE_FIONREAD && defined USG5_4
60# include <sys/filio.h>
61#endif
62
60#include "syssignal.h" 63#include "syssignal.h"
61 64
62#include <sys/types.h> 65#include <sys/types.h>
@@ -81,9 +84,7 @@ int interrupt_input_pending;
81 pending_atimers separately, to reduce code size. So, any code that 84 pending_atimers separately, to reduce code size. So, any code that
82 changes interrupt_input_pending or pending_atimers should update 85 changes interrupt_input_pending or pending_atimers should update
83 this too. */ 86 this too. */
84#ifdef SYNC_INPUT
85int pending_signals; 87int pending_signals;
86#endif
87 88
88#define KBD_BUFFER_SIZE 4096 89#define KBD_BUFFER_SIZE 4096
89 90
@@ -142,7 +143,7 @@ static ptrdiff_t before_command_echo_length;
142 143
143/* For longjmp to where kbd input is being done. */ 144/* For longjmp to where kbd input is being done. */
144 145
145static jmp_buf getcjmp; 146static sys_jmp_buf getcjmp;
146 147
147/* True while doing kbd input. */ 148/* True while doing kbd input. */
148int waiting_for_input; 149int waiting_for_input;
@@ -386,19 +387,6 @@ int interrupt_input;
386/* Nonzero while interrupts are temporarily deferred during redisplay. */ 387/* Nonzero while interrupts are temporarily deferred during redisplay. */
387int interrupts_deferred; 388int interrupts_deferred;
388 389
389/* Allow configure to inhibit use of FIONREAD. */
390#ifdef BROKEN_FIONREAD
391#undef FIONREAD
392#endif
393
394/* We are unable to use interrupts if FIONREAD is not available,
395 so flush SIGIO so we won't try. */
396#if !defined (FIONREAD)
397#ifdef SIGIO
398#undef SIGIO
399#endif
400#endif
401
402/* If we support a window system, turn on the code to poll periodically 390/* If we support a window system, turn on the code to poll periodically
403 to detect C-g. It isn't actually used when doing interrupt input. */ 391 to detect C-g. It isn't actually used when doing interrupt input. */
404#if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS) 392#if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS)
@@ -444,14 +432,13 @@ static Lisp_Object modify_event_symbol (ptrdiff_t, int, Lisp_Object,
444 Lisp_Object *, ptrdiff_t); 432 Lisp_Object *, ptrdiff_t);
445static Lisp_Object make_lispy_switch_frame (Lisp_Object); 433static Lisp_Object make_lispy_switch_frame (Lisp_Object);
446static int help_char_p (Lisp_Object); 434static int help_char_p (Lisp_Object);
447static void save_getcjmp (jmp_buf); 435static void save_getcjmp (sys_jmp_buf);
448static void restore_getcjmp (jmp_buf); 436static void restore_getcjmp (sys_jmp_buf);
449static Lisp_Object apply_modifiers (int, Lisp_Object); 437static Lisp_Object apply_modifiers (int, Lisp_Object);
450static void clear_event (struct input_event *); 438static void clear_event (struct input_event *);
451static Lisp_Object restore_kboard_configuration (Lisp_Object); 439static Lisp_Object restore_kboard_configuration (Lisp_Object);
452static void interrupt_signal (int signalnum); 440#ifdef USABLE_SIGIO
453#ifdef SIGIO 441static void deliver_input_available_signal (int signo);
454static void input_available_signal (int signo);
455#endif 442#endif
456static void handle_interrupt (void); 443static void handle_interrupt (void);
457static _Noreturn void quit_throw_to_read_char (int); 444static _Noreturn void quit_throw_to_read_char (int);
@@ -459,7 +446,7 @@ static void process_special_events (void);
459static void timer_start_idle (void); 446static void timer_start_idle (void);
460static void timer_stop_idle (void); 447static void timer_stop_idle (void);
461static void timer_resume_idle (void); 448static void timer_resume_idle (void);
462static void handle_user_signal (int); 449static void deliver_user_signal (int);
463static char *find_user_signal_name (int); 450static char *find_user_signal_name (int);
464static int store_user_signal_events (void); 451static int store_user_signal_events (void);
465 452
@@ -1023,7 +1010,7 @@ restore_kboard_configuration (Lisp_Object was_locked)
1023 pop_kboard (); 1010 pop_kboard ();
1024 /* The pop should not change the kboard. */ 1011 /* The pop should not change the kboard. */
1025 if (single_kboard && current_kboard != prev) 1012 if (single_kboard && current_kboard != prev)
1026 abort (); 1013 emacs_abort ();
1027 } 1014 }
1028 return Qnil; 1015 return Qnil;
1029} 1016}
@@ -1315,7 +1302,7 @@ usage: (track-mouse BODY...) */)
1315 If ignore_mouse_drag_p is non-zero, ignore (implicit) mouse movement 1302 If ignore_mouse_drag_p is non-zero, ignore (implicit) mouse movement
1316 after resizing the tool-bar window. */ 1303 after resizing the tool-bar window. */
1317 1304
1318#if !defined HAVE_WINDOW_SYSTEM 1305#if !defined HAVE_WINDOW_SYSTEM || defined USE_GTK || defined HAVE_NS
1319static 1306static
1320#endif 1307#endif
1321int ignore_mouse_drag_p; 1308int ignore_mouse_drag_p;
@@ -2021,17 +2008,9 @@ static struct atimer *poll_timer;
2021void 2008void
2022poll_for_input_1 (void) 2009poll_for_input_1 (void)
2023{ 2010{
2024/* Tell ns_read_socket() it is being called asynchronously so it can avoid
2025 doing anything dangerous. */
2026#ifdef HAVE_NS
2027 ++handling_signal;
2028#endif
2029 if (interrupt_input_blocked == 0 2011 if (interrupt_input_blocked == 0
2030 && !waiting_for_input) 2012 && !waiting_for_input)
2031 read_avail_input (0); 2013 read_avail_input (0);
2032#ifdef HAVE_NS
2033 --handling_signal;
2034#endif
2035} 2014}
2036 2015
2037/* Timer callback function for poll_timer. TIMER is equal to 2016/* Timer callback function for poll_timer. TIMER is equal to
@@ -2042,12 +2021,8 @@ poll_for_input (struct atimer *timer)
2042{ 2021{
2043 if (poll_suppress_count == 0) 2022 if (poll_suppress_count == 0)
2044 { 2023 {
2045#ifdef SYNC_INPUT
2046 interrupt_input_pending = 1; 2024 interrupt_input_pending = 1;
2047 pending_signals = 1; 2025 pending_signals = 1;
2048#else
2049 poll_for_input_1 ();
2050#endif
2051 } 2026 }
2052} 2027}
2053 2028
@@ -2326,8 +2301,8 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2326{ 2301{
2327 volatile Lisp_Object c; 2302 volatile Lisp_Object c;
2328 ptrdiff_t jmpcount; 2303 ptrdiff_t jmpcount;
2329 jmp_buf local_getcjmp; 2304 sys_jmp_buf local_getcjmp;
2330 jmp_buf save_jump; 2305 sys_jmp_buf save_jump;
2331 volatile int key_already_recorded = 0; 2306 volatile int key_already_recorded = 0;
2332 Lisp_Object tem, save; 2307 Lisp_Object tem, save;
2333 volatile Lisp_Object previous_echo_area_message; 2308 volatile Lisp_Object previous_echo_area_message;
@@ -2368,15 +2343,6 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2368 goto reread_first; 2343 goto reread_first;
2369 } 2344 }
2370 2345
2371 if (unread_command_char != -1)
2372 {
2373 XSETINT (c, unread_command_char);
2374 unread_command_char = -1;
2375
2376 reread = 1;
2377 goto reread_first;
2378 }
2379
2380 if (CONSP (Vunread_command_events)) 2346 if (CONSP (Vunread_command_events))
2381 { 2347 {
2382 int was_disabled = 0; 2348 int was_disabled = 0;
@@ -2561,7 +2527,6 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2561 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event) 2527 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event)
2562 /* Don't bring up a menu if we already have another event. */ 2528 /* Don't bring up a menu if we already have another event. */
2563 && NILP (Vunread_command_events) 2529 && NILP (Vunread_command_events)
2564 && unread_command_char < 0
2565 && !detect_input_pending_run_timers (0)) 2530 && !detect_input_pending_run_timers (0))
2566 { 2531 {
2567 c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps); 2532 c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps);
@@ -2583,7 +2548,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2583 it *must not* be in effect when we call redisplay. */ 2548 it *must not* be in effect when we call redisplay. */
2584 2549
2585 jmpcount = SPECPDL_INDEX (); 2550 jmpcount = SPECPDL_INDEX ();
2586 if (_setjmp (local_getcjmp)) 2551 if (sys_setjmp (local_getcjmp))
2587 { 2552 {
2588 /* Handle quits while reading the keyboard. */ 2553 /* Handle quits while reading the keyboard. */
2589 /* We must have saved the outer value of getcjmp here, 2554 /* We must have saved the outer value of getcjmp here,
@@ -2605,13 +2570,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2605 Lisp_Object last = KVAR (kb, kbd_queue); 2570 Lisp_Object last = KVAR (kb, kbd_queue);
2606 /* We shouldn't get here if we were in single-kboard mode! */ 2571 /* We shouldn't get here if we were in single-kboard mode! */
2607 if (single_kboard) 2572 if (single_kboard)
2608 abort (); 2573 emacs_abort ();
2609 if (CONSP (last)) 2574 if (CONSP (last))
2610 { 2575 {
2611 while (CONSP (XCDR (last))) 2576 while (CONSP (XCDR (last)))
2612 last = XCDR (last); 2577 last = XCDR (last);
2613 if (!NILP (XCDR (last))) 2578 if (!NILP (XCDR (last)))
2614 abort (); 2579 emacs_abort ();
2615 } 2580 }
2616 if (!CONSP (last)) 2581 if (!CONSP (last))
2617 kset_kbd_queue (kb, Fcons (c, Qnil)); 2582 kset_kbd_queue (kb, Fcons (c, Qnil));
@@ -2697,8 +2662,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2697 && !EQ (XCAR (prev_event), Qmenu_bar) 2662 && !EQ (XCAR (prev_event), Qmenu_bar)
2698 && !EQ (XCAR (prev_event), Qtool_bar) 2663 && !EQ (XCAR (prev_event), Qtool_bar)
2699 /* Don't bring up a menu if we already have another event. */ 2664 /* Don't bring up a menu if we already have another event. */
2700 && NILP (Vunread_command_events) 2665 && NILP (Vunread_command_events))
2701 && unread_command_char < 0)
2702 { 2666 {
2703 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); 2667 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu);
2704 2668
@@ -2784,7 +2748,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2784 if (current_kboard->kbd_queue_has_data) 2748 if (current_kboard->kbd_queue_has_data)
2785 { 2749 {
2786 if (!CONSP (KVAR (current_kboard, kbd_queue))) 2750 if (!CONSP (KVAR (current_kboard, kbd_queue)))
2787 abort (); 2751 emacs_abort ();
2788 c = XCAR (KVAR (current_kboard, kbd_queue)); 2752 c = XCAR (KVAR (current_kboard, kbd_queue));
2789 kset_kbd_queue (current_kboard, 2753 kset_kbd_queue (current_kboard,
2790 XCDR (KVAR (current_kboard, kbd_queue))); 2754 XCDR (KVAR (current_kboard, kbd_queue)));
@@ -2851,7 +2815,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2851 while (CONSP (XCDR (last))) 2815 while (CONSP (XCDR (last)))
2852 last = XCDR (last); 2816 last = XCDR (last);
2853 if (!NILP (XCDR (last))) 2817 if (!NILP (XCDR (last)))
2854 abort (); 2818 emacs_abort ();
2855 } 2819 }
2856 if (!CONSP (last)) 2820 if (!CONSP (last))
2857 kset_kbd_queue (kb, Fcons (c, Qnil)); 2821 kset_kbd_queue (kb, Fcons (c, Qnil));
@@ -3416,13 +3380,13 @@ record_char (Lisp_Object c)
3416 See read_process_output. */ 3380 See read_process_output. */
3417 3381
3418static void 3382static void
3419save_getcjmp (jmp_buf temp) 3383save_getcjmp (sys_jmp_buf temp)
3420{ 3384{
3421 memcpy (temp, getcjmp, sizeof getcjmp); 3385 memcpy (temp, getcjmp, sizeof getcjmp);
3422} 3386}
3423 3387
3424static void 3388static void
3425restore_getcjmp (jmp_buf temp) 3389restore_getcjmp (sys_jmp_buf temp)
3426{ 3390{
3427 memcpy (getcjmp, temp, sizeof getcjmp); 3391 memcpy (getcjmp, temp, sizeof getcjmp);
3428} 3392}
@@ -3560,7 +3524,7 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3560 struct input_event *hold_quit) 3524 struct input_event *hold_quit)
3561{ 3525{
3562 if (event->kind == NO_EVENT) 3526 if (event->kind == NO_EVENT)
3563 abort (); 3527 emacs_abort ();
3564 3528
3565 if (hold_quit && hold_quit->kind != NO_EVENT) 3529 if (hold_quit && hold_quit->kind != NO_EVENT)
3566 return; 3530 return;
@@ -3604,7 +3568,7 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3604 3568
3605 if (hold_quit) 3569 if (hold_quit)
3606 { 3570 {
3607 memcpy (hold_quit, event, sizeof (*event)); 3571 *hold_quit = *event;
3608 return; 3572 return;
3609 } 3573 }
3610 3574
@@ -3659,10 +3623,8 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3659 /* Don't read keyboard input until we have processed kbd_buffer. 3623 /* Don't read keyboard input until we have processed kbd_buffer.
3660 This happens when pasting text longer than KBD_BUFFER_SIZE/2. */ 3624 This happens when pasting text longer than KBD_BUFFER_SIZE/2. */
3661 hold_keyboard_input (); 3625 hold_keyboard_input ();
3662#ifdef SIGIO
3663 if (!noninteractive) 3626 if (!noninteractive)
3664 signal (SIGIO, SIG_IGN); 3627 ignore_sigio ();
3665#endif
3666 stop_polling (); 3628 stop_polling ();
3667 } 3629 }
3668#endif /* subprocesses */ 3630#endif /* subprocesses */
@@ -3681,7 +3643,7 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3681 if (immediate_quit && NILP (Vinhibit_quit)) 3643 if (immediate_quit && NILP (Vinhibit_quit))
3682 { 3644 {
3683 immediate_quit = 0; 3645 immediate_quit = 0;
3684 sigfree (); 3646 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
3685 QUIT; 3647 QUIT;
3686 } 3648 }
3687 } 3649 }
@@ -3831,10 +3793,14 @@ kbd_buffer_get_event (KBOARD **kbp,
3831 /* Start reading input again because we have processed enough to 3793 /* Start reading input again because we have processed enough to
3832 be able to accept new events again. */ 3794 be able to accept new events again. */
3833 unhold_keyboard_input (); 3795 unhold_keyboard_input ();
3834#ifdef SIGIO 3796#ifdef USABLE_SIGIO
3835 if (!noninteractive) 3797 if (!noninteractive)
3836 signal (SIGIO, input_available_signal); 3798 {
3837#endif /* SIGIO */ 3799 struct sigaction action;
3800 emacs_sigaction_init (&action, deliver_input_available_signal);
3801 sigaction (SIGIO, &action, 0);
3802 }
3803#endif
3838 start_polling (); 3804 start_polling ();
3839 } 3805 }
3840#endif /* subprocesses */ 3806#endif /* subprocesses */
@@ -3876,10 +3842,9 @@ kbd_buffer_get_event (KBOARD **kbp,
3876 /* One way or another, wait until input is available; then, if 3842 /* One way or another, wait until input is available; then, if
3877 interrupt handlers have not read it, read it now. */ 3843 interrupt handlers have not read it, read it now. */
3878 3844
3879/* Note SIGIO has been undef'd if FIONREAD is missing. */ 3845#ifdef USABLE_SIGIO
3880#ifdef SIGIO
3881 gobble_input (0); 3846 gobble_input (0);
3882#endif /* SIGIO */ 3847#endif
3883 if (kbd_fetch_ptr != kbd_store_ptr) 3848 if (kbd_fetch_ptr != kbd_store_ptr)
3884 break; 3849 break;
3885#if defined (HAVE_MOUSE) || defined (HAVE_GPM) 3850#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
@@ -3955,7 +3920,7 @@ kbd_buffer_get_event (KBOARD **kbp,
3955#else 3920#else
3956 /* We're getting selection request events, but we don't have 3921 /* We're getting selection request events, but we don't have
3957 a window system. */ 3922 a window system. */
3958 abort (); 3923 emacs_abort ();
3959#endif 3924#endif
3960 } 3925 }
3961 3926
@@ -4131,7 +4096,7 @@ kbd_buffer_get_event (KBOARD **kbp,
4131 *used_mouse_menu = 1; 4096 *used_mouse_menu = 1;
4132#endif 4097#endif
4133#ifdef HAVE_NS 4098#ifdef HAVE_NS
4134 /* certain system events are non-key events */ 4099 /* Certain system events are non-key events. */
4135 if (used_mouse_menu 4100 if (used_mouse_menu
4136 && event->kind == NS_NONKEY_EVENT) 4101 && event->kind == NS_NONKEY_EVENT)
4137 *used_mouse_menu = 1; 4102 *used_mouse_menu = 1;
@@ -4159,7 +4124,7 @@ kbd_buffer_get_event (KBOARD **kbp,
4159 so x remains nil. */ 4124 so x remains nil. */
4160 x = Qnil; 4125 x = Qnil;
4161 4126
4162 /* XXX Can f or mouse_position_hook be NULL here? */ 4127 /* XXX Can f or mouse_position_hook be NULL here? */
4163 if (f && FRAME_TERMINAL (f)->mouse_position_hook) 4128 if (f && FRAME_TERMINAL (f)->mouse_position_hook)
4164 (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, 0, &bar_window, 4129 (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, 0, &bar_window,
4165 &part, &x, &y, &t); 4130 &part, &x, &y, &t);
@@ -4192,7 +4157,7 @@ kbd_buffer_get_event (KBOARD **kbp,
4192 else 4157 else
4193 /* We were promised by the above while loop that there was 4158 /* We were promised by the above while loop that there was
4194 something for us to read! */ 4159 something for us to read! */
4195 abort (); 4160 emacs_abort ();
4196 4161
4197 input_pending = readable_events (0); 4162 input_pending = readable_events (0);
4198 4163
@@ -4261,7 +4226,7 @@ process_special_events (void)
4261#else 4226#else
4262 /* We're getting selection request events, but we don't have 4227 /* We're getting selection request events, but we don't have
4263 a window system. */ 4228 a window system. */
4264 abort (); 4229 emacs_abort ();
4265#endif 4230#endif
4266 } 4231 }
4267 } 4232 }
@@ -4351,7 +4316,7 @@ decode_timer (Lisp_Object timer, EMACS_TIME *result)
4351 if (! NILP (vector[0])) 4316 if (! NILP (vector[0]))
4352 return 0; 4317 return 0;
4353 4318
4354 return decode_time_components (vector[1], vector[2], vector[3], vector[4], 4319 return decode_time_components (vector[1], vector[2], vector[3], vector[8],
4355 result, 0); 4320 result, 0);
4356} 4321}
4357 4322
@@ -4553,7 +4518,7 @@ in the same style as (current-time).
4553 4518
4554The value when Emacs is not idle is nil. 4519The value when Emacs is not idle is nil.
4555 4520
4556NSEC is a multiple of the system clock resolution. */) 4521PSEC is a multiple of the system clock resolution. */)
4557 (void) 4522 (void)
4558{ 4523{
4559 if (EMACS_TIME_VALID_P (timer_idleness_start_time)) 4524 if (EMACS_TIME_VALID_P (timer_idleness_start_time))
@@ -5614,7 +5579,7 @@ make_lispy_event (struct input_event *event)
5614 else if (FRAMEP (event->frame_or_window)) 5579 else if (FRAMEP (event->frame_or_window))
5615 f = XFRAME (event->frame_or_window); 5580 f = XFRAME (event->frame_or_window);
5616 else 5581 else
5617 abort (); 5582 emacs_abort ();
5618 5583
5619 if (FRAME_WINDOW_P (f)) 5584 if (FRAME_WINDOW_P (f))
5620 fuzz = double_click_fuzz; 5585 fuzz = double_click_fuzz;
@@ -5721,7 +5686,7 @@ make_lispy_event (struct input_event *event)
5721 else 5686 else
5722 /* Every mouse event should either have the down_modifier or 5687 /* Every mouse event should either have the down_modifier or
5723 the up_modifier set. */ 5688 the up_modifier set. */
5724 abort (); 5689 emacs_abort ();
5725 5690
5726 { 5691 {
5727 /* Get the symbol we should use for the mouse click. */ 5692 /* Get the symbol we should use for the mouse click. */
@@ -5782,7 +5747,7 @@ make_lispy_event (struct input_event *event)
5782 else if (FRAMEP (event->frame_or_window)) 5747 else if (FRAMEP (event->frame_or_window))
5783 fr = XFRAME (event->frame_or_window); 5748 fr = XFRAME (event->frame_or_window);
5784 else 5749 else
5785 abort (); 5750 emacs_abort ();
5786 5751
5787 fuzz = FRAME_WINDOW_P (fr) 5752 fuzz = FRAME_WINDOW_P (fr)
5788 ? double_click_fuzz : double_click_fuzz / 8; 5753 ? double_click_fuzz : double_click_fuzz / 8;
@@ -5802,7 +5767,7 @@ make_lispy_event (struct input_event *event)
5802 else 5767 else
5803 /* Every wheel event should either have the down_modifier or 5768 /* Every wheel event should either have the down_modifier or
5804 the up_modifier set. */ 5769 the up_modifier set. */
5805 abort (); 5770 emacs_abort ();
5806 5771
5807 if (event->kind == HORIZ_WHEEL_EVENT) 5772 if (event->kind == HORIZ_WHEEL_EVENT)
5808 symbol_num += 2; 5773 symbol_num += 2;
@@ -5971,7 +5936,7 @@ make_lispy_event (struct input_event *event)
5971 { 5936 {
5972 char *name = find_user_signal_name (event->code); 5937 char *name = find_user_signal_name (event->code);
5973 if (!name) 5938 if (!name)
5974 abort (); 5939 emacs_abort ();
5975 return intern (name); 5940 return intern (name);
5976 } 5941 }
5977 5942
@@ -6052,7 +6017,7 @@ make_lispy_event (struct input_event *event)
6052 6017
6053 /* The 'kind' field of the event is something we don't recognize. */ 6018 /* The 'kind' field of the event is something we don't recognize. */
6054 default: 6019 default:
6055 abort (); 6020 emacs_abort ();
6056 } 6021 }
6057} 6022}
6058 6023
@@ -6229,7 +6194,7 @@ apply_modifiers_uncached (int modifiers, char *base, int base_len, int base_len_
6229 /* Only the event queue may use the `up' modifier; it should always 6194 /* Only the event queue may use the `up' modifier; it should always
6230 be turned into a click or drag event before presented to lisp code. */ 6195 be turned into a click or drag event before presented to lisp code. */
6231 if (modifiers & up_modifier) 6196 if (modifiers & up_modifier)
6232 abort (); 6197 emacs_abort ();
6233 6198
6234 if (modifiers & alt_modifier) { *p++ = 'A'; *p++ = '-'; } 6199 if (modifiers & alt_modifier) { *p++ = 'A'; *p++ = '-'; }
6235 if (modifiers & ctrl_modifier) { *p++ = 'C'; *p++ = '-'; } 6200 if (modifiers & ctrl_modifier) { *p++ = 'C'; *p++ = '-'; }
@@ -6324,7 +6289,7 @@ parse_modifiers (Lisp_Object symbol)
6324 Qnil); 6289 Qnil);
6325 6290
6326 if (modifiers & ~INTMASK) 6291 if (modifiers & ~INTMASK)
6327 abort (); 6292 emacs_abort ();
6328 XSETFASTINT (mask, modifiers); 6293 XSETFASTINT (mask, modifiers);
6329 elements = Fcons (unmodified, Fcons (mask, Qnil)); 6294 elements = Fcons (unmodified, Fcons (mask, Qnil));
6330 6295
@@ -6778,13 +6743,15 @@ get_input_pending (int *addr, int flags)
6778void 6743void
6779gobble_input (int expected) 6744gobble_input (int expected)
6780{ 6745{
6781#ifdef SIGIO 6746#ifdef USABLE_SIGIO
6782 if (interrupt_input) 6747 if (interrupt_input)
6783 { 6748 {
6784 SIGMASKTYPE mask; 6749 sigset_t blocked, procmask;
6785 mask = sigblock (sigmask (SIGIO)); 6750 sigemptyset (&blocked);
6751 sigaddset (&blocked, SIGIO);
6752 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
6786 read_avail_input (expected); 6753 read_avail_input (expected);
6787 sigsetmask (mask); 6754 pthread_sigmask (SIG_SETMASK, &procmask, 0);
6788 } 6755 }
6789 else 6756 else
6790#ifdef POLL_FOR_INPUT 6757#ifdef POLL_FOR_INPUT
@@ -6793,10 +6760,12 @@ gobble_input (int expected)
6793 it's always set. */ 6760 it's always set. */
6794 if (!interrupt_input && poll_suppress_count == 0) 6761 if (!interrupt_input && poll_suppress_count == 0)
6795 { 6762 {
6796 SIGMASKTYPE mask; 6763 sigset_t blocked, procmask;
6797 mask = sigblock (sigmask (SIGALRM)); 6764 sigemptyset (&blocked);
6765 sigaddset (&blocked, SIGALRM);
6766 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
6798 read_avail_input (expected); 6767 read_avail_input (expected);
6799 sigsetmask (mask); 6768 pthread_sigmask (SIG_SETMASK, &procmask, 0);
6800 } 6769 }
6801 else 6770 else
6802#endif 6771#endif
@@ -6829,13 +6798,15 @@ record_asynch_buffer_change (void)
6829 return; 6798 return;
6830 6799
6831 /* Make sure no interrupt happens while storing the event. */ 6800 /* Make sure no interrupt happens while storing the event. */
6832#ifdef SIGIO 6801#ifdef USABLE_SIGIO
6833 if (interrupt_input) 6802 if (interrupt_input)
6834 { 6803 {
6835 SIGMASKTYPE mask; 6804 sigset_t blocked, procmask;
6836 mask = sigblock (sigmask (SIGIO)); 6805 sigemptyset (&blocked);
6806 sigaddset (&blocked, SIGIO);
6807 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
6837 kbd_buffer_store_event (&event); 6808 kbd_buffer_store_event (&event);
6838 sigsetmask (mask); 6809 pthread_sigmask (SIG_SETMASK, &procmask, 0);
6839 } 6810 }
6840 else 6811 else
6841#endif 6812#endif
@@ -7001,7 +6972,7 @@ tty_read_avail_input (struct terminal *terminal,
7001 6972
7002 if (terminal->type != output_termcap 6973 if (terminal->type != output_termcap
7003 && terminal->type != output_msdos_raw) 6974 && terminal->type != output_msdos_raw)
7004 abort (); 6975 emacs_abort ();
7005 6976
7006 /* XXX I think the following code should be moved to separate hook 6977 /* XXX I think the following code should be moved to separate hook
7007 functions in system-dependent files. */ 6978 functions in system-dependent files. */
@@ -7053,7 +7024,7 @@ tty_read_avail_input (struct terminal *terminal,
7053#endif /* HAVE_GPM */ 7024#endif /* HAVE_GPM */
7054 7025
7055/* Determine how many characters we should *try* to read. */ 7026/* Determine how many characters we should *try* to read. */
7056#ifdef FIONREAD 7027#ifdef USABLE_FIONREAD
7057 /* Find out how much input is available. */ 7028 /* Find out how much input is available. */
7058 if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0) 7029 if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0)
7059 { 7030 {
@@ -7066,14 +7037,12 @@ tty_read_avail_input (struct terminal *terminal,
7066 return 0; 7037 return 0;
7067 if (n_to_read > sizeof cbuf) 7038 if (n_to_read > sizeof cbuf)
7068 n_to_read = sizeof cbuf; 7039 n_to_read = sizeof cbuf;
7069#else /* no FIONREAD */ 7040#elif defined USG || defined CYGWIN
7070#if defined (USG) || defined (CYGWIN)
7071 /* Read some input if available, but don't wait. */ 7041 /* Read some input if available, but don't wait. */
7072 n_to_read = sizeof cbuf; 7042 n_to_read = sizeof cbuf;
7073 fcntl (fileno (tty->input), F_SETFL, O_NDELAY); 7043 fcntl (fileno (tty->input), F_SETFL, O_NDELAY);
7074#else 7044#else
7075 you lose; 7045# error "Cannot read without possibly delaying"
7076#endif
7077#endif 7046#endif
7078 7047
7079#ifdef subprocesses 7048#ifdef subprocesses
@@ -7122,7 +7091,7 @@ tty_read_avail_input (struct terminal *terminal,
7122#endif 7091#endif
7123 ); 7092 );
7124 7093
7125#ifndef FIONREAD 7094#ifndef USABLE_FIONREAD
7126#if defined (USG) || defined (CYGWIN) 7095#if defined (USG) || defined (CYGWIN)
7127 fcntl (fileno (tty->input), F_SETFL, 0); 7096 fcntl (fileno (tty->input), F_SETFL, 0);
7128#endif /* USG or CYGWIN */ 7097#endif /* USG or CYGWIN */
@@ -7193,19 +7162,12 @@ tty_read_avail_input (struct terminal *terminal,
7193 return nread; 7162 return nread;
7194} 7163}
7195 7164
7196#if defined SYNC_INPUT || defined SIGIO
7197static void 7165static void
7198handle_async_input (void) 7166handle_async_input (void)
7199{ 7167{
7200 interrupt_input_pending = 0; 7168 interrupt_input_pending = 0;
7201#ifdef SYNC_INPUT
7202 pending_signals = pending_atimers; 7169 pending_signals = pending_atimers;
7203#endif 7170
7204/* Tell ns_read_socket() it is being called asynchronously so it can avoid
7205 doing anything dangerous. */
7206#ifdef HAVE_NS
7207 ++handling_signal;
7208#endif
7209 while (1) 7171 while (1)
7210 { 7172 {
7211 int nread; 7173 int nread;
@@ -7216,13 +7178,8 @@ handle_async_input (void)
7216 if (nread <= 0) 7178 if (nread <= 0)
7217 break; 7179 break;
7218 } 7180 }
7219#ifdef HAVE_NS
7220 --handling_signal;
7221#endif
7222} 7181}
7223#endif /* SYNC_INPUT || SIGIO */
7224 7182
7225#ifdef SYNC_INPUT
7226void 7183void
7227process_pending_signals (void) 7184process_pending_signals (void)
7228{ 7185{
@@ -7230,33 +7187,25 @@ process_pending_signals (void)
7230 handle_async_input (); 7187 handle_async_input ();
7231 do_pending_atimers (); 7188 do_pending_atimers ();
7232} 7189}
7233#endif
7234 7190
7235#ifdef SIGIO /* for entire page */ 7191#ifdef USABLE_SIGIO
7236/* Note SIGIO has been undef'd if FIONREAD is missing. */
7237 7192
7238static void 7193static void
7239input_available_signal (int signo) 7194handle_input_available_signal (int sig)
7240{ 7195{
7241 /* Must preserve main program's value of errno. */
7242 int old_errno = errno;
7243 SIGNAL_THREAD_CHECK (signo);
7244
7245#ifdef SYNC_INPUT
7246 interrupt_input_pending = 1; 7196 interrupt_input_pending = 1;
7247 pending_signals = 1; 7197 pending_signals = 1;
7248#endif
7249 7198
7250 if (input_available_clear_time) 7199 if (input_available_clear_time)
7251 *input_available_clear_time = make_emacs_time (0, 0); 7200 *input_available_clear_time = make_emacs_time (0, 0);
7201}
7252 7202
7253#ifndef SYNC_INPUT 7203static void
7254 handle_async_input (); 7204deliver_input_available_signal (int sig)
7255#endif 7205{
7256 7206 handle_on_main_thread (sig, handle_input_available_signal);
7257 errno = old_errno;
7258} 7207}
7259#endif /* SIGIO */ 7208#endif /* USABLE_SIGIO */
7260 7209
7261/* Send ourselves a SIGIO. 7210/* Send ourselves a SIGIO.
7262 7211
@@ -7267,7 +7216,7 @@ input_available_signal (int signo)
7267void 7216void
7268reinvoke_input_signal (void) 7217reinvoke_input_signal (void)
7269{ 7218{
7270#ifdef SIGIO 7219#ifdef USABLE_SIGIO
7271 handle_async_input (); 7220 handle_async_input ();
7272#endif 7221#endif
7273} 7222}
@@ -7296,6 +7245,7 @@ static struct user_signal_info *user_signals = NULL;
7296void 7245void
7297add_user_signal (int sig, const char *name) 7246add_user_signal (int sig, const char *name)
7298{ 7247{
7248 struct sigaction action;
7299 struct user_signal_info *p; 7249 struct user_signal_info *p;
7300 7250
7301 for (p = user_signals; p; p = p->next) 7251 for (p = user_signals; p; p = p->next)
@@ -7310,18 +7260,16 @@ add_user_signal (int sig, const char *name)
7310 p->next = user_signals; 7260 p->next = user_signals;
7311 user_signals = p; 7261 user_signals = p;
7312 7262
7313 signal (sig, handle_user_signal); 7263 emacs_sigaction_init (&action, deliver_user_signal);
7264 sigaction (sig, &action, 0);
7314} 7265}
7315 7266
7316static void 7267static void
7317handle_user_signal (int sig) 7268handle_user_signal (int sig)
7318{ 7269{
7319 int old_errno = errno;
7320 struct user_signal_info *p; 7270 struct user_signal_info *p;
7321 const char *special_event_name = NULL; 7271 const char *special_event_name = NULL;
7322 7272
7323 SIGNAL_THREAD_CHECK (sig);
7324
7325 if (SYMBOLP (Vdebug_on_event)) 7273 if (SYMBOLP (Vdebug_on_event))
7326 special_event_name = SSDATA (SYMBOL_NAME (Vdebug_on_event)); 7274 special_event_name = SSDATA (SYMBOL_NAME (Vdebug_on_event));
7327 7275
@@ -7342,7 +7290,7 @@ handle_user_signal (int sig)
7342 } 7290 }
7343 7291
7344 p->npending++; 7292 p->npending++;
7345#ifdef SIGIO 7293#ifdef USABLE_SIGIO
7346 if (interrupt_input) 7294 if (interrupt_input)
7347 kill (getpid (), SIGIO); 7295 kill (getpid (), SIGIO);
7348 else 7296 else
@@ -7355,8 +7303,12 @@ handle_user_signal (int sig)
7355 } 7303 }
7356 break; 7304 break;
7357 } 7305 }
7306}
7358 7307
7359 errno = old_errno; 7308static void
7309deliver_user_signal (int sig)
7310{
7311 handle_on_main_thread (sig, handle_user_signal);
7360} 7312}
7361 7313
7362static char * 7314static char *
@@ -7381,7 +7333,7 @@ store_user_signal_events (void)
7381 for (p = user_signals; p; p = p->next) 7333 for (p = user_signals; p; p = p->next)
7382 if (p->npending > 0) 7334 if (p->npending > 0)
7383 { 7335 {
7384 SIGMASKTYPE mask; 7336 sigset_t blocked, procmask;
7385 7337
7386 if (nstored == 0) 7338 if (nstored == 0)
7387 { 7339 {
@@ -7391,7 +7343,10 @@ store_user_signal_events (void)
7391 } 7343 }
7392 nstored += p->npending; 7344 nstored += p->npending;
7393 7345
7394 mask = sigblock (sigmask (p->sig)); 7346 sigemptyset (&blocked);
7347 sigaddset (&blocked, p->sig);
7348 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
7349
7395 do 7350 do
7396 { 7351 {
7397 buf.code = p->sig; 7352 buf.code = p->sig;
@@ -7399,7 +7354,8 @@ store_user_signal_events (void)
7399 p->npending--; 7354 p->npending--;
7400 } 7355 }
7401 while (p->npending > 0); 7356 while (p->npending > 0);
7402 sigsetmask (mask); 7357
7358 pthread_sigmask (SIG_SETMASK, &procmask, 0);
7403 } 7359 }
7404 7360
7405 return nstored; 7361 return nstored;
@@ -10438,7 +10394,7 @@ clear_input_pending (void)
10438int 10394int
10439requeued_events_pending_p (void) 10395requeued_events_pending_p (void)
10440{ 10396{
10441 return (!NILP (Vunread_command_events) || unread_command_char != -1); 10397 return (!NILP (Vunread_command_events));
10442} 10398}
10443 10399
10444 10400
@@ -10448,7 +10404,7 @@ Actually, the value is nil only if we can be sure that no input is available;
10448if there is a doubt, the value is t. */) 10404if there is a doubt, the value is t. */)
10449 (void) 10405 (void)
10450{ 10406{
10451 if (!NILP (Vunread_command_events) || unread_command_char != -1 10407 if (!NILP (Vunread_command_events)
10452 || !NILP (Vunread_post_input_method_events) 10408 || !NILP (Vunread_post_input_method_events)
10453 || !NILP (Vunread_input_method_events)) 10409 || !NILP (Vunread_input_method_events))
10454 return (Qt); 10410 return (Qt);
@@ -10636,7 +10592,6 @@ Also end any kbd macro being defined. */)
10636 update_mode_lines++; 10592 update_mode_lines++;
10637 10593
10638 Vunread_command_events = Qnil; 10594 Vunread_command_events = Qnil;
10639 unread_command_char = -1;
10640 10595
10641 discard_tty_input (); 10596 discard_tty_input ();
10642 10597
@@ -10776,17 +10731,10 @@ clear_waiting_for_input (void)
10776 Otherwise, tell QUIT to kill Emacs. */ 10731 Otherwise, tell QUIT to kill Emacs. */
10777 10732
10778static void 10733static void
10779interrupt_signal (int signalnum) /* If we don't have an argument, some */ 10734handle_interrupt_signal (int sig)
10780 /* compilers complain in signal calls. */
10781{ 10735{
10782 /* Must preserve main program's value of errno. */
10783 int old_errno = errno;
10784 struct terminal *terminal;
10785
10786 SIGNAL_THREAD_CHECK (signalnum);
10787
10788 /* See if we have an active terminal on our controlling tty. */ 10736 /* See if we have an active terminal on our controlling tty. */
10789 terminal = get_named_tty ("/dev/tty"); 10737 struct terminal *terminal = get_named_tty ("/dev/tty");
10790 if (!terminal) 10738 if (!terminal)
10791 { 10739 {
10792 /* If there are no frames there, let's pretend that we are a 10740 /* If there are no frames there, let's pretend that we are a
@@ -10807,10 +10755,15 @@ interrupt_signal (int signalnum) /* If we don't have an argument, some */
10807 10755
10808 handle_interrupt (); 10756 handle_interrupt ();
10809 } 10757 }
10758}
10810 10759
10811 errno = old_errno; 10760static void
10761deliver_interrupt_signal (int sig)
10762{
10763 handle_on_main_thread (sig, handle_interrupt_signal);
10812} 10764}
10813 10765
10766
10814/* If Emacs is stuck because `inhibit-quit' is true, then keep track 10767/* If Emacs is stuck because `inhibit-quit' is true, then keep track
10815 of the number of times C-g has been requested. If C-g is pressed 10768 of the number of times C-g has been requested. If C-g is pressed
10816 enough times, then quit anyway. See bug#6585. */ 10769 enough times, then quit anyway. See bug#6585. */
@@ -10840,7 +10793,10 @@ handle_interrupt (void)
10840 /* If SIGINT isn't blocked, don't let us be interrupted by 10793 /* If SIGINT isn't blocked, don't let us be interrupted by
10841 another SIGINT, it might be harmful due to non-reentrancy 10794 another SIGINT, it might be harmful due to non-reentrancy
10842 in I/O functions. */ 10795 in I/O functions. */
10843 sigblock (sigmask (SIGINT)); 10796 sigset_t blocked;
10797 sigemptyset (&blocked);
10798 sigaddset (&blocked, SIGINT);
10799 pthread_sigmask (SIG_BLOCK, &blocked, 0);
10844 10800
10845 fflush (stdout); 10801 fflush (stdout);
10846 reset_all_sys_modes (); 10802 reset_all_sys_modes ();
@@ -10902,7 +10858,7 @@ handle_interrupt (void)
10902#endif /* not MSDOS */ 10858#endif /* not MSDOS */
10903 fflush (stdout); 10859 fflush (stdout);
10904 if (((c = getchar ()) & ~040) == 'Y') 10860 if (((c = getchar ()) & ~040) == 'Y')
10905 abort (); 10861 emacs_abort ();
10906 while (c != '\n') c = getchar (); 10862 while (c != '\n') c = getchar ();
10907#ifdef MSDOS 10863#ifdef MSDOS
10908 printf ("\r\nContinuing...\r\n"); 10864 printf ("\r\nContinuing...\r\n");
@@ -10911,7 +10867,7 @@ handle_interrupt (void)
10911#endif /* not MSDOS */ 10867#endif /* not MSDOS */
10912 fflush (stdout); 10868 fflush (stdout);
10913 init_all_sys_modes (); 10869 init_all_sys_modes ();
10914 sigfree (); 10870 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
10915 } 10871 }
10916 else 10872 else
10917 { 10873 {
@@ -10924,7 +10880,7 @@ handle_interrupt (void)
10924 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 10880 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
10925 10881
10926 immediate_quit = 0; 10882 immediate_quit = 0;
10927 sigfree (); 10883 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
10928 saved = gl_state; 10884 saved = gl_state;
10929 GCPRO4 (saved.object, saved.global_code, 10885 GCPRO4 (saved.object, saved.global_code,
10930 saved.current_syntax_table, saved.old_prop); 10886 saved.current_syntax_table, saved.old_prop);
@@ -10969,13 +10925,12 @@ quit_throw_to_read_char (int from_signal)
10969 if (!from_signal && EQ (Vquit_flag, Qkill_emacs)) 10925 if (!from_signal && EQ (Vquit_flag, Qkill_emacs))
10970 Fkill_emacs (Qnil); 10926 Fkill_emacs (Qnil);
10971 10927
10972 sigfree (); 10928 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
10973 /* Prevent another signal from doing this before we finish. */ 10929 /* Prevent another signal from doing this before we finish. */
10974 clear_waiting_for_input (); 10930 clear_waiting_for_input ();
10975 input_pending = 0; 10931 input_pending = 0;
10976 10932
10977 Vunread_command_events = Qnil; 10933 Vunread_command_events = Qnil;
10978 unread_command_char = -1;
10979 10934
10980#if 0 /* Currently, sit_for is called from read_char without turning 10935#if 0 /* Currently, sit_for is called from read_char without turning
10981 off polling. And that can call set_waiting_for_input. 10936 off polling. And that can call set_waiting_for_input.
@@ -10983,7 +10938,7 @@ quit_throw_to_read_char (int from_signal)
10983#ifdef POLL_FOR_INPUT 10938#ifdef POLL_FOR_INPUT
10984 /* May be > 1 if in recursive minibuffer. */ 10939 /* May be > 1 if in recursive minibuffer. */
10985 if (poll_suppress_count == 0) 10940 if (poll_suppress_count == 0)
10986 abort (); 10941 emacs_abort ();
10987#endif 10942#endif
10988#endif 10943#endif
10989 if (FRAMEP (internal_last_event_frame) 10944 if (FRAMEP (internal_last_event_frame)
@@ -10991,7 +10946,7 @@ quit_throw_to_read_char (int from_signal)
10991 do_switch_frame (make_lispy_switch_frame (internal_last_event_frame), 10946 do_switch_frame (make_lispy_switch_frame (internal_last_event_frame),
10992 0, 0, Qnil); 10947 0, 0, Qnil);
10993 10948
10994 _longjmp (getcjmp, 1); 10949 sys_longjmp (getcjmp, 1);
10995} 10950}
10996 10951
10997DEFUN ("set-input-interrupt-mode", Fset_input_interrupt_mode, 10952DEFUN ("set-input-interrupt-mode", Fset_input_interrupt_mode,
@@ -11004,8 +10959,7 @@ See also `current-input-mode'. */)
11004 (Lisp_Object interrupt) 10959 (Lisp_Object interrupt)
11005{ 10960{
11006 int new_interrupt_input; 10961 int new_interrupt_input;
11007#ifdef SIGIO 10962#ifdef USABLE_SIGIO
11008/* Note SIGIO has been undef'd if FIONREAD is missing. */
11009#ifdef HAVE_X_WINDOWS 10963#ifdef HAVE_X_WINDOWS
11010 if (x_display_list != NULL) 10964 if (x_display_list != NULL)
11011 { 10965 {
@@ -11016,9 +10970,9 @@ See also `current-input-mode'. */)
11016 else 10970 else
11017#endif /* HAVE_X_WINDOWS */ 10971#endif /* HAVE_X_WINDOWS */
11018 new_interrupt_input = !NILP (interrupt); 10972 new_interrupt_input = !NILP (interrupt);
11019#else /* not SIGIO */ 10973#else /* not USABLE_SIGIO */
11020 new_interrupt_input = 0; 10974 new_interrupt_input = 0;
11021#endif /* not SIGIO */ 10975#endif /* not USABLE_SIGIO */
11022 10976
11023 if (new_interrupt_input != interrupt_input) 10977 if (new_interrupt_input != interrupt_input)
11024 { 10978 {
@@ -11341,7 +11295,7 @@ delete_kboard (KBOARD *kb)
11341 11295
11342 for (kbp = &all_kboards; *kbp != kb; kbp = &(*kbp)->next_kboard) 11296 for (kbp = &all_kboards; *kbp != kb; kbp = &(*kbp)->next_kboard)
11343 if (*kbp == NULL) 11297 if (*kbp == NULL)
11344 abort (); 11298 emacs_abort ();
11345 *kbp = kb->next_kboard; 11299 *kbp = kb->next_kboard;
11346 11300
11347 /* Prevent a dangling reference to KB. */ 11301 /* Prevent a dangling reference to KB. */
@@ -11352,7 +11306,7 @@ delete_kboard (KBOARD *kb)
11352 current_kboard = FRAME_KBOARD (XFRAME (selected_frame)); 11306 current_kboard = FRAME_KBOARD (XFRAME (selected_frame));
11353 single_kboard = 0; 11307 single_kboard = 0;
11354 if (current_kboard == kb) 11308 if (current_kboard == kb)
11355 abort (); 11309 emacs_abort ();
11356 } 11310 }
11357 11311
11358 wipe_kboard (kb); 11312 wipe_kboard (kb);
@@ -11362,12 +11316,11 @@ delete_kboard (KBOARD *kb)
11362void 11316void
11363init_keyboard (void) 11317init_keyboard (void)
11364{ 11318{
11365 /* This is correct before outermost invocation of the editor loop */ 11319 /* This is correct before outermost invocation of the editor loop. */
11366 command_loop_level = -1; 11320 command_loop_level = -1;
11367 immediate_quit = 0; 11321 immediate_quit = 0;
11368 quit_char = Ctl ('g'); 11322 quit_char = Ctl ('g');
11369 Vunread_command_events = Qnil; 11323 Vunread_command_events = Qnil;
11370 unread_command_char = -1;
11371 timer_idleness_start_time = invalid_emacs_time (); 11324 timer_idleness_start_time = invalid_emacs_time ();
11372 total_keys = 0; 11325 total_keys = 0;
11373 recent_keys_index = 0; 11326 recent_keys_index = 0;
@@ -11379,9 +11332,7 @@ init_keyboard (void)
11379 input_pending = 0; 11332 input_pending = 0;
11380 interrupt_input_blocked = 0; 11333 interrupt_input_blocked = 0;
11381 interrupt_input_pending = 0; 11334 interrupt_input_pending = 0;
11382#ifdef SYNC_INPUT
11383 pending_signals = 0; 11335 pending_signals = 0;
11384#endif
11385 11336
11386 /* This means that command_loop_1 won't try to select anything the first 11337 /* This means that command_loop_1 won't try to select anything the first
11387 time through. */ 11338 time through. */
@@ -11404,18 +11355,23 @@ init_keyboard (void)
11404 SIGINT. There is special code in interrupt_signal to exit 11355 SIGINT. There is special code in interrupt_signal to exit
11405 Emacs on SIGINT when there are no termcap frames on the 11356 Emacs on SIGINT when there are no termcap frames on the
11406 controlling terminal. */ 11357 controlling terminal. */
11407 signal (SIGINT, interrupt_signal); 11358 struct sigaction action;
11359 emacs_sigaction_init (&action, deliver_interrupt_signal);
11360 sigaction (SIGINT, &action, 0);
11408#ifndef DOS_NT 11361#ifndef DOS_NT
11409 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and 11362 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and
11410 SIGQUIT and we can't tell which one it will give us. */ 11363 SIGQUIT and we can't tell which one it will give us. */
11411 signal (SIGQUIT, interrupt_signal); 11364 sigaction (SIGQUIT, &action, 0);
11412#endif /* not DOS_NT */ 11365#endif /* not DOS_NT */
11413 } 11366 }
11414/* Note SIGIO has been undef'd if FIONREAD is missing. */ 11367#ifdef USABLE_SIGIO
11415#ifdef SIGIO
11416 if (!noninteractive) 11368 if (!noninteractive)
11417 signal (SIGIO, input_available_signal); 11369 {
11418#endif /* SIGIO */ 11370 struct sigaction action;
11371 emacs_sigaction_init (&action, deliver_input_available_signal);
11372 sigaction (SIGIO, &action, 0);
11373 }
11374#endif
11419 11375
11420/* Use interrupt input by default, if it works and noninterrupt input 11376/* Use interrupt input by default, if it works and noninterrupt input
11421 has deficiencies. */ 11377 has deficiencies. */
@@ -11426,7 +11382,7 @@ init_keyboard (void)
11426 interrupt_input = 0; 11382 interrupt_input = 0;
11427#endif 11383#endif
11428 11384
11429 sigfree (); 11385 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
11430 dribble = 0; 11386 dribble = 0;
11431 11387
11432 if (keyboard_init_hook) 11388 if (keyboard_init_hook)
@@ -11694,9 +11650,6 @@ as they will already have been added once as they were read for the first time.
11694An element of the form (t . EVENT) forces EVENT to be added to that list. */); 11650An element of the form (t . EVENT) forces EVENT to be added to that list. */);
11695 Vunread_command_events = Qnil; 11651 Vunread_command_events = Qnil;
11696 11652
11697 DEFVAR_INT ("unread-command-char", unread_command_char,
11698 doc: /* If not -1, an object to be read as next command input event. */);
11699
11700 DEFVAR_LISP ("unread-post-input-method-events", Vunread_post_input_method_events, 11653 DEFVAR_LISP ("unread-post-input-method-events", Vunread_post_input_method_events,
11701 doc: /* List of events to be processed as input by input methods. 11654 doc: /* List of events to be processed as input by input methods.
11702These events are processed before `unread-command-events' 11655These events are processed before `unread-command-events'