From: Guillermo J. Rozas Date: Tue, 5 May 1992 06:37:58 +0000 (+0000) Subject: Add new interrupt character procedures. X-Git-Tag: 20090517-FFI~9435 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=237c32b239f890d6db7f0b89240e263aa6b544e8;p=mit-scheme.git Add new interrupt character procedures. --- diff --git a/v7/src/microcode/osctty.h b/v7/src/microcode/osctty.h index 3bacb318a..b80d2eef8 100644 --- a/v7/src/microcode/osctty.h +++ b/v7/src/microcode/osctty.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osctty.h,v 1.1 1990/06/20 19:36:13 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osctty.h,v 1.2 1992/05/05 06:37:17 jinx Exp $ -Copyright (c) 1990 Massachusetts Institute of Technology +Copyright (c) 1990-1992 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -37,13 +37,6 @@ MIT in each case. */ #include "os.h" -extern cc_t EXFUN (OS_ctty_quit_char, (void)); -extern cc_t EXFUN (OS_ctty_int_char, (void)); -extern cc_t EXFUN (OS_ctty_tstp_char, (void)); -extern void EXFUN - (OS_ctty_set_interrupt_chars, - (cc_t quit_char, cc_t int_char, cc_t tstp_char)); - /* If this procedure returns 0, the interrupt control procedures will not work correctly. */ extern int EXFUN (OS_ctty_interrupt_control, (void)); @@ -52,4 +45,10 @@ typedef unsigned int Tinterrupt_enables; extern void EXFUN (OS_ctty_get_interrupt_enables, (Tinterrupt_enables * mask)); extern void EXFUN (OS_ctty_set_interrupt_enables, (Tinterrupt_enables * mask)); +extern unsigned int EXFUN (OS_ctty_num_int_chars, (void)); +extern cc_t * EXFUN (OS_ctty_get_int_chars, (void)); +extern cc_t * EXFUN (OS_ctty_get_int_char_handlers, (void)); +extern void EXFUN (OS_ctty_set_int_chars, (cc_t *)); +extern void EXFUN (OS_ctty_set_int_char_handlers, (cc_t *)); + #endif /* SCM_OSCTTY_H */ diff --git a/v7/src/microcode/prostty.c b/v7/src/microcode/prostty.c index f85454ef5..b6e467e8f 100644 --- a/v7/src/microcode/prostty.c +++ b/v7/src/microcode/prostty.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prostty.c,v 1.3 1991/10/29 22:55:11 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prostty.c,v 1.4 1992/05/05 06:37:58 jinx Exp $ -Copyright (c) 1987-1991 Massachusetts Institute of Technology +Copyright (c) 1987-1992 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -38,7 +38,6 @@ MIT in each case. */ #include "prims.h" #include "ostty.h" #include "osctty.h" -#include "ossig.h" #include "osfile.h" #include "osio.h" @@ -121,35 +120,46 @@ DEFINE_PRIMITIVE ("TTY-GET-INTERRUPT-CHARS", Prim_tty_get_interrupt_chars, 0, 0, { PRIMITIVE_HEADER (0); { - SCHEME_OBJECT result = (allocate_string (6)); + 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 ()); unsigned char * scan = (STRING_LOC (result, 0)); - (*scan++) = ((unsigned char) (OS_ctty_quit_char ())); - (*scan++) = ((unsigned char) (OS_signal_quit_handler ())); - (*scan++) = ((unsigned char) (OS_ctty_int_char ())); - (*scan++) = ((unsigned char) (OS_signal_int_handler ())); - (*scan++) = ((unsigned char) (OS_ctty_tstp_char ())); - (*scan) = ((unsigned char) (OS_signal_tstp_handler ())); + + for (i = 0; i < num_chars; i++) + { + (*scan++) = ((unsigned char) int_chars[i]); + (*scan++) = ((unsigned char) int_handlers[i]); + } PRIMITIVE_RETURN (result); } } -DEFINE_PRIMITIVE ("TTY-SET-INTERRUPT-CHARS", Prim_tty_set_interrupt_chars, 1, 1, +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)); - if (! ((STRING_P (argument)) && ((STRING_LENGTH (argument)) == 6))) + unsigned char * scan; + + if (! ((STRING_P (argument)) + && ((STRING_LENGTH (argument)) == (num_chars * 2)))) error_wrong_type_arg (1); - OS_signal_set_interrupt_handlers - (((enum interrupt_handler) (STRING_REF (argument, 1))), - ((enum interrupt_handler) (STRING_REF (argument, 3))), - ((enum interrupt_handler) (STRING_REF (argument, 5)))); - OS_ctty_set_interrupt_chars - ((STRING_REF (argument, 0)), - (STRING_REF (argument, 2)), - (STRING_REF (argument, 4))); + + for (i = 0, scan = (STRING_LOC (argument, 0)); 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/v7/src/microcode/uxctty.c b/v7/src/microcode/uxctty.c index e1fc94b8c..b5d3fd259 100644 --- a/v7/src/microcode/uxctty.c +++ b/v7/src/microcode/uxctty.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxctty.c,v 1.10 1992/02/12 12:18:30 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxctty.c,v 1.11 1992/05/05 06:37:40 jinx Exp $ -Copyright (c) 1990-92 Massachusetts Institute of Technology +Copyright (c) 1990-1992 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -34,6 +34,7 @@ MIT in each case. */ #include "ux.h" #include "osctty.h" +#include "ossig.h" /* If `ctty_fildes' is nonnegative, it is an open file descriptor for the controlling terminal of the process. @@ -316,6 +317,7 @@ DEFUN_VOID (OS_ctty_fd) } #if 0 + /* not currently used */ static void DEFUN (ctty_get_interrupt_chars, (ic), Tinterrupt_chars * ic) @@ -428,7 +430,7 @@ DEFUN (ctty_set_interrupt_chars, (ic), Tinterrupt_chars * ic) set_terminal_state (ctty_fildes, (&s)); } } - + static void DEFUN_VOID (ctty_update_interrupt_chars) { @@ -463,6 +465,8 @@ DEFUN (OS_ctty_set_interrupt_enables, (mask), Tinterrupt_enables * mask) ctty_update_interrupt_chars (); } +#if 0 + void DEFUN (OS_ctty_set_interrupt_chars, (quit_char, int_char, tstp_char), cc_t quit_char AND @@ -474,6 +478,64 @@ DEFUN (OS_ctty_set_interrupt_chars, (quit_char, int_char, tstp_char), (current_interrupt_chars . tstp) = tstp_char; ctty_update_interrupt_chars (); } +#endif + +unsigned int +DEFUN_VOID (OS_ctty_num_int_chars) +{ + return (3); +} + +cc_t * +DEFUN_VOID (OS_ctty_get_int_chars) +{ + 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 +DEFUN (OS_ctty_set_int_chars, (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 EXFUN (OS_signal_quit_handler, (void)); +extern enum interrupt_handler EXFUN (OS_signal_int_handler, (void)); +extern enum interrupt_handler EXFUN (OS_signal_tstp_handler, (void)); +extern void EXFUN + (OS_signal_set_interrupt_handlers, + (enum interrupt_handler quit_handler, + enum interrupt_handler int_handler, + enum interrupt_handler tstp_handler)); + +cc_t * +DEFUN_VOID (OS_ctty_get_int_char_handlers) +{ + 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 +DEFUN (OS_ctty_set_int_char_handlers, (int_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 DEFUN (UX_initialize_ctty, (interactive), int interactive)