From 7e6f94959d7180c2c774e027a7f855363d1c408b Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Tue, 2 Aug 2011 12:51:33 -0700 Subject: [PATCH] Punt the tty-get/set-interrupt-chars primitives. Gtkio's signal forwarder breaks the assumptions in en/decode_interrupt _handler. Rather than fix them, I punt the TTY-GET-INTERRUPT-CHARS and TTY-SET-INTERRUPTS-CHARS! primitives. They were not used in The Tree, not even by Edwin. --- src/microcode/ntsig.c | 40 ------------ src/microcode/os2ctty.c | 48 -------------- src/microcode/osctty.h | 6 -- src/microcode/prostty.c | 50 -------------- src/microcode/uxctty.c | 140 ---------------------------------------- src/microcode/uxsig.c | 139 ++------------------------------------- 6 files changed, 7 insertions(+), 416 deletions(-) diff --git a/src/microcode/ntsig.c b/src/microcode/ntsig.c index 464ecf6c5..e36eec1c8 100644 --- a/src/microcode/ntsig.c +++ b/src/microcode/ntsig.c @@ -190,46 +190,6 @@ update_interrupt_characters (void) } return; } - -unsigned int -OS_ctty_num_int_chars (void) -{ - return (NUM_INT_CHANNELS); -} - -cc_t * -OS_ctty_get_int_chars (void) -{ - return (&int_chars[0]); -} - -void -OS_ctty_set_int_chars (cc_t * new_int_chars) -{ - int i; - - for (i = 0; i < NUM_INT_CHANNELS; i++) - int_chars[i] = new_int_chars[i]; - update_interrupt_characters (); - return; -} - -cc_t * -OS_ctty_get_int_char_handlers (void) -{ - return (&int_handlers[0]); -} - -void -OS_ctty_set_int_char_handlers (cc_t * new_int_handlers) -{ - int i; - - for (i = 0; i < NUM_INT_CHANNELS; i++) - int_handlers[i] = new_int_handlers[i]; - update_interrupt_characters (); - return; -} static void console_write_string (unsigned char * string) diff --git a/src/microcode/os2ctty.c b/src/microcode/os2ctty.c index aad5a191e..3f508e12d 100644 --- a/src/microcode/os2ctty.c +++ b/src/microcode/os2ctty.c @@ -94,59 +94,11 @@ OS_ctty_set_interrupt_enables (Tinterrupt_enables * mask) keyboard_interrupt_enables = ((*mask) & ALL_ENABLES); } -unsigned int -OS_ctty_num_int_chars (void) -{ - return (KB_INT_CHARS_SIZE + 1); -} - cc_t OS_tty_map_interrupt_char (cc_t int_char) { return (int_char); } - -cc_t * -OS_ctty_get_int_chars (void) -{ - static cc_t characters [KB_INT_CHARS_SIZE + 1]; - unsigned int i; - for (i = 0; (i < KB_INT_CHARS_SIZE); i += 1) - (characters[i]) = (keyboard_interrupt_characters[i]); - (characters[i]) = '\0'; /* dummy for control-break */ - return (characters); -} - -void -OS_ctty_set_int_chars (cc_t * characters) -{ - unsigned int i; - for (i = 0; (i < KB_INT_CHARS_SIZE); i += 1) - (keyboard_interrupt_characters[i]) = (characters[i]); - update_keyboard_interrupt_characters (); -} - -cc_t * -OS_ctty_get_int_char_handlers (void) -{ - static cc_t handlers [KB_INT_CHARS_SIZE + 1]; - unsigned int i; - for (i = 0; (i < KB_INT_CHARS_SIZE); i += 1) - (handlers[i]) = ((cc_t) (keyboard_interrupt_handlers[i])); - (handlers[i]) = ((cc_t) keyboard_break_interrupt); - return (handlers); -} - -void -OS_ctty_set_int_char_handlers (cc_t * handlers) -{ - unsigned int i; - for (i = 0; (i < KB_INT_CHARS_SIZE); i += 1) - (keyboard_interrupt_handlers[i]) = - ((enum interrupt_handler) (handlers[i])); - keyboard_break_interrupt = ((enum interrupt_handler) (handlers[i])); - update_keyboard_interrupt_characters (); -} static char check_if_enabled (enum interrupt_handler handler) diff --git a/src/microcode/osctty.h b/src/microcode/osctty.h index 4cc92a65d..f312134a8 100644 --- a/src/microcode/osctty.h +++ b/src/microcode/osctty.h @@ -37,10 +37,4 @@ typedef unsigned int Tinterrupt_enables; extern void OS_ctty_get_interrupt_enables (Tinterrupt_enables * mask); extern void OS_ctty_set_interrupt_enables (Tinterrupt_enables * mask); -extern unsigned int OS_ctty_num_int_chars (void); -extern cc_t * OS_ctty_get_int_chars (void); -extern cc_t * OS_ctty_get_int_char_handlers (void); -extern void OS_ctty_set_int_chars (cc_t *); -extern void OS_ctty_set_int_char_handlers (cc_t *); - #endif /* SCM_OSCTTY_H */ diff --git a/src/microcode/prostty.c b/src/microcode/prostty.c index e0948a682..331c4143e 100644 --- a/src/microcode/prostty.c +++ b/src/microcode/prostty.c @@ -104,53 +104,3 @@ DEFINE_PRIMITIVE ("TTY-SET-INTERRUPT-ENABLES", Prim_tty_set_interrupt_enables, 1 } PRIMITIVE_RETURN (UNSPECIFIC); } - -DEFINE_PRIMITIVE ("TTY-GET-INTERRUPT-CHARS", Prim_tty_get_interrupt_chars, 0, 0, - "Return the current interrupt characters as a string.") -{ - PRIMITIVE_HEADER (0); - { - unsigned int i; - unsigned int num_chars = (OS_ctty_num_int_chars ()); - SCHEME_OBJECT result = (allocate_string (num_chars * 2)); - cc_t * int_chars = (OS_ctty_get_int_chars ()); - cc_t * int_handlers = (OS_ctty_get_int_char_handlers ()); - char * scan = (STRING_POINTER (result)); - - for (i = 0; i < num_chars; i++) - { - (*scan++) = (int_chars[i]); - (*scan++) = (int_handlers[i]); - } - PRIMITIVE_RETURN (result); - } -} - -DEFINE_PRIMITIVE ("TTY-SET-INTERRUPT-CHARS!", Prim_tty_set_interrupt_chars, 1, 1, - "Change the current interrupt characters to STRING.\n\ -STRING must be in the correct form for this operating system.") -{ - PRIMITIVE_HEADER (1); - { - unsigned int i; - unsigned int num_chars = (OS_ctty_num_int_chars ()); - cc_t * int_chars = (OS_ctty_get_int_chars ()); - cc_t * int_handlers = (OS_ctty_get_int_char_handlers ()); - SCHEME_OBJECT argument = (ARG_REF (1)); - char * scan; - - if (! ((STRING_P (argument)) - && (((unsigned int) (STRING_LENGTH (argument))) - == (num_chars * 2)))) - error_wrong_type_arg (1); - - for (i = 0, scan = (STRING_POINTER (argument)); i < num_chars; i++) - { - (int_chars[i]) = (*scan++); - (int_handlers[i]) = (*scan++); - } - OS_ctty_set_int_chars (int_chars); - OS_ctty_set_int_char_handlers (int_handlers); - } - PRIMITIVE_RETURN (UNSPECIFIC); -} diff --git a/src/microcode/uxctty.c b/src/microcode/uxctty.c index 90a075e0f..563cdd4bf 100644 --- a/src/microcode/uxctty.c +++ b/src/microcode/uxctty.c @@ -242,7 +242,6 @@ OS_ctty_interrupt_control (void) { return (outside_ctty_state . recorded_p); } - int UX_terminal_control_ok (int fd) { @@ -306,75 +305,6 @@ OS_ctty_fd (void) return (ctty_fildes); } -#if 0 - -/* not currently used */ -static void -ctty_get_interrupt_chars (Tinterrupt_chars * ic) -{ - Ttty_state s; - if ((get_terminal_state (ctty_fildes, (&s))) == 0) - { -#ifdef HAVE_TERMIOS_H - (ic -> quit) = ((s . tio . c_cc) [VQUIT]); - (ic -> intrpt) = ((s . tio . c_cc) [VINTR]); - (ic -> tstp) = ((s . tio . c_cc) [VSUSP]); - -#ifdef VDSUSP - (ic -> dtstp) = ((s . tio . c_cc) [VDSUSP]); -#else /* not VDSUSP */ -#ifdef __HPUX__ - (ic -> dtstp) = (s . ltc . t_dsuspc); -#endif /* __HPUX__ */ -#endif /* not VDSUSP */ - -#else /* not HAVE_TERMIOS_H */ -#ifdef HAVE_TERMIO_H - - (ic -> quit) = ((s . tio . c_cc) [VQUIT]); - (ic -> intrpt) = ((s . tio . c_cc) [VINTR]); -#ifdef HAVE_STRUCT_LTCHARS - (ic -> tstp) = (s . ltc . t_suspc); - (ic -> dtstp) = (s . ltc . t_dsuspc); -#else /* not HAVE_STRUCT_LTCHARS */ - { - cc_t disabled_char = (UX_PC_VDISABLE (ctty_fildes)); - (ic -> tstp) = disabled_char; - (ic -> dtstp) = disabled_char; - } -#endif /* not HAVE_STRUCT_LTCHARS */ - -#else /* not HAVE_TERMIO_H */ -#ifdef HAVE_SGTTY_H - - (ic -> quit) = (s . tc . t_quitc); - (ic -> intrpt) = (s . tc . t_intrc); -#ifdef HAVE_STRUCT_LTCHARS - (ic -> tstp) = (s . ltc . t_suspc); - (ic -> dtstp) = (s . ltc . t_dsuspc); -#else /* not HAVE_STRUCT_LTCHARS */ - { - cc_t disabled_char = (UX_PC_VDISABLE (ctty_fildes)); - (ic -> tstp) = disabled_char; - (ic -> dtstp) = disabled_char; - } -#endif /* not HAVE_STRUCT_LTCHARS */ - -#endif /* HAVE_SGTTY_H */ -#endif /* HAVE_TERMIO_H */ -#endif /* HAVE_TERMIOS_H */ - } - else - { - cc_t disabled_char = (UX_PC_VDISABLE (ctty_fildes)); - (ic -> quit) = disabled_char; - (ic -> intrpt) = disabled_char; - (ic -> tstp) = disabled_char; - (ic -> dtstp) = disabled_char; - } -} -#endif /* 0 */ - static void ctty_set_interrupt_chars (Tinterrupt_chars * ic) { @@ -454,77 +384,7 @@ OS_ctty_set_interrupt_enables (Tinterrupt_enables * mask) current_interrupt_enables = (*mask); ctty_update_interrupt_chars (); } - -#if 0 - -void -OS_ctty_set_interrupt_chars (cc_t quit_char, - cc_t int_char, - cc_t tstp_char) -{ - (current_interrupt_chars . quit) = quit_char; - (current_interrupt_chars . intrpt) = int_char; - (current_interrupt_chars . tstp) = tstp_char; - ctty_update_interrupt_chars (); -} -#endif - -unsigned int -OS_ctty_num_int_chars (void) -{ - return (3); -} - -cc_t * -OS_ctty_get_int_chars (void) -{ - static cc_t int_chars [3]; - - int_chars[0] = current_interrupt_chars.quit; - int_chars[1] = current_interrupt_chars.intrpt; - int_chars[2] = current_interrupt_chars.tstp; - return (& int_chars [0]); -} - -void -OS_ctty_set_int_chars (cc_t * int_chars) -{ - current_interrupt_chars.quit = int_chars[0]; - current_interrupt_chars.intrpt = int_chars[1]; - current_interrupt_chars.tstp = int_chars[2]; - ctty_update_interrupt_chars (); - return; -} -extern enum interrupt_handler OS_signal_quit_handler (void); -extern enum interrupt_handler OS_signal_int_handler (void); -extern enum interrupt_handler OS_signal_tstp_handler (void); -extern void OS_signal_set_interrupt_handlers - (enum interrupt_handler quit_handler, - enum interrupt_handler int_handler, - enum interrupt_handler tstp_handler); - -cc_t * -OS_ctty_get_int_char_handlers (void) -{ - static cc_t int_handlers [3]; - - int_handlers[0] = ((cc_t) (OS_signal_quit_handler ())); - int_handlers[1] = ((cc_t) (OS_signal_int_handler ())); - int_handlers[2] = ((cc_t) (OS_signal_tstp_handler ())); - return (& int_handlers [0]); -} - -void -OS_ctty_set_int_char_handlers (cc_t * int_handlers) -{ - OS_signal_set_interrupt_handlers - (((enum interrupt_handler) (int_handlers [0])), - ((enum interrupt_handler) (int_handlers [1])), - ((enum interrupt_handler) (int_handlers [2]))); - return; -} - void UX_initialize_ctty (int interactive) { diff --git a/src/microcode/uxsig.c b/src/microcode/uxsig.c index 959f7458c..3a31f8762 100644 --- a/src/microcode/uxsig.c +++ b/src/microcode/uxsig.c @@ -879,135 +879,6 @@ interactive_interrupt_handler (SIGCONTEXT_T * scp) } } -static enum interrupt_handler -encode_interrupt_handler (Tsignal_handler handler) -{ - return - ((handler == ((Tsignal_handler) sighnd_control_g)) - ? interrupt_handler_control_g - : (handler == ((Tsignal_handler) sighnd_interactive)) - ? interrupt_handler_interactive - : (handler == ((Tsignal_handler) sighnd_stop)) - ? interrupt_handler_stop - : (handler == ((Tsignal_handler) sighnd_terminate)) - ? interrupt_handler_terminate - : (handler == ((Tsignal_handler) SIG_IGN)) - ? interrupt_handler_ignore - : (handler == ((Tsignal_handler) SIG_DFL)) - ? interrupt_handler_default - : interrupt_handler_unknown); -} - -static Tsignal_handler -decode_interrupt_handler (enum interrupt_handler encoding) -{ - return - ((encoding == interrupt_handler_control_g) - ? ((Tsignal_handler) sighnd_control_g) - : (encoding == interrupt_handler_interactive) - ? ((Tsignal_handler) sighnd_interactive) - : (encoding == interrupt_handler_stop) - ? ((Tsignal_handler) sighnd_stop) - : (encoding == interrupt_handler_terminate) - ? ((Tsignal_handler) sighnd_terminate) - : (encoding == interrupt_handler_ignore) - ? ((Tsignal_handler) SIG_IGN) - : (encoding == interrupt_handler_default) - ? ((Tsignal_handler) SIG_DFL) - : ((Tsignal_handler) 0)); -} - -enum interrupt_handler -OS_signal_quit_handler (void) -{ - return (encode_interrupt_handler (current_handler (SIGQUIT))); -} - -enum interrupt_handler -OS_signal_int_handler (void) -{ - return (encode_interrupt_handler (current_handler (SIGINT))); -} - -enum interrupt_handler -OS_signal_tstp_handler (void) -{ - return - ((UX_SC_JOB_CONTROL ()) - ? (encode_interrupt_handler (current_handler (SIGTSTP))) - : interrupt_handler_ignore); -} - -void -OS_signal_set_interrupt_handlers (enum interrupt_handler quit_handler, - enum interrupt_handler int_handler, - enum interrupt_handler tstp_handler) -{ - { - Tsignal_handler handler = (decode_interrupt_handler (quit_handler)); - if (handler != 0) - INSTALL_HANDLER (SIGQUIT, handler); - } - { - Tsignal_handler handler = (decode_interrupt_handler (int_handler)); - if (handler != 0) - INSTALL_HANDLER (SIGINT, handler); - } - if (UX_SC_JOB_CONTROL ()) - { - Tsignal_handler handler = (decode_interrupt_handler (tstp_handler)); - if (handler != 0) - INSTALL_HANDLER (SIGTSTP, handler); - } -} - -static void -describe_sighnd (int signo, unsigned char c) -{ - switch (encode_interrupt_handler (current_handler (signo))) - { - case interrupt_handler_control_g: - fputs ("When typed, scheme will get the ^G character interrupt.\n", - stdout); - fputs ("The default action is to abort the running program,\n", stdout); - fputs ("and to resume the top level read-eval-print loop.\n", stdout); - break; - case interrupt_handler_interactive: - fputs ("When typed, various interrupt options are offered.\n", stdout); - fprintf (stdout, "Type %s followed by `?' for a list of options.\n", - (char_description (c, 0))); - break; - case interrupt_handler_terminate: - describe_terminate: - fputs ("When typed, scheme will terminate.\n", stdout); - break; - case interrupt_handler_stop: - describe_stop: - fputs ("When typed, scheme will suspend execution.\n", stdout); - break; - case interrupt_handler_ignore: - describe_ignore: - fputs ("When typed, this character will be ignored.\n", stdout); - break; - case interrupt_handler_default: - { - struct signal_descriptor * descriptor = - (find_signal_descriptor (signo)); - if (descriptor != 0) - switch (descriptor -> action) - { - case dfl_ignore: goto describe_ignore; - case dfl_stop: goto describe_stop; - case dfl_terminate: goto describe_terminate; - } - } - default: - fputs ("When typed, this character will have an unknown effect.\n", - stdout); - break; - } -} - static void print_interrupt_chars (void) { @@ -1015,20 +886,24 @@ print_interrupt_chars (void) unsigned char quit_char = (OS_ctty_quit_char ()); fprintf (stdout, "\n\nThe quit character is %s.\n", (char_description (quit_char, 1))); - describe_sighnd (SIGQUIT, quit_char); + fputs ("When typed, various interrupt options are offered.\n", stdout); + fprintf (stdout, "Type %s followed by `?' for a list of options.\n", + (char_description (quit_char, 0))); } { unsigned char int_char = (OS_ctty_int_char ()); fprintf (stdout, "\nThe interrupt character is %s.\n", (char_description (int_char, 1))); - describe_sighnd (SIGINT, int_char); + fputs ("When typed, scheme will get the ^G character interrupt.\n", stdout); + fputs ("The default action is to abort the running program,\n", stdout); + fputs ("and to resume the top level read-eval-print loop.\n", stdout); } if (UX_SC_JOB_CONTROL ()) { unsigned char tstp_char = (OS_ctty_tstp_char ()); fprintf (stdout, "\nThe terminal stop character is %s.\n", (char_description (tstp_char, 1))); - describe_sighnd (SIGTSTP, tstp_char); + fputs ("When typed, scheme will suspend execution.\n", stdout); } putc ('\n', stdout); fflush (stdout); -- 2.25.1