/* -*-C-*-
-$Id: ntio.c,v 1.7 1993/08/21 03:34:00 gjr Exp $
+$Id: ntio.c,v 1.8 1993/09/01 18:42:20 gjr Exp $
Copyright (c) 1992-1993 Massachusetts Institute of Technology
return;
}
+#ifndef GUI
static BOOL _stdcall
-NT_ctrl_handler(DWORD dwCtrlType)
+NT_ctrl_handler (DWORD dwCtrlType)
{
switch (dwCtrlType) {
case CTRL_C_EVENT:
return FALSE;
}
}
-
-
-extern HANDLE master_tty_window;
-
-
-void
-DEFUN_VOID (NT_initialize_channels)
-{
-#ifndef GUI
- STDIN_HANDLE = (GetStdHandle (STD_INPUT_HANDLE));
- STDOUT_HANDLE = (GetStdHandle (STD_OUTPUT_HANDLE));
- STDERR_HANDLE = (GetStdHandle (STD_ERROR_HANDLE));
-
- if (STDIN_HANDLE == INVALID_HANDLE_VALUE ||
- STDOUT_HANDLE == INVALID_HANDLE_VALUE ||
- STDERR_HANDLE == INVALID_HANDLE_VALUE)
- {
- outf_fatal ("\nUnable to get standard handles %s(%d).\n",
- __FILE__, __LINE__);
- termination_init_error ();
- }
-
- SetConsoleMode (STDIN_HANDLE,
- ( ENABLE_LINE_INPUT
- | ENABLE_ECHO_INPUT
- | ENABLE_PROCESSED_INPUT));
- SetConsoleCtrlHandler (NT_ctrl_handler, TRUE);
#endif /* GUI */
- master_tty_window = Screen_Create (NULL, "MIT Scheme", SW_SHOWNORMAL);
-
- OS_channel_table_size = (NT_SC_OPEN_MAX ());
- channel_table =
- (NT_malloc (OS_channel_table_size * (sizeof (struct channel))));
- if (channel_table == 0)
- {
- outf_fatal ("\nUnable to allocate channel table.\n");
- termination_init_error ();
- }
- {
- Tchannel channel;
- for (channel = 0; (channel < OS_channel_table_size); channel += 1)
- MARK_CHANNEL_CLOSED (channel);
- }
- add_reload_cleanup (NT_channel_close_all);
- OS_channels_registered = 0;
- return;
-}
-
-void
-DEFUN_VOID (NT_reset_channels)
-{
- NT_free (channel_table);
- channel_table = 0;
- OS_channel_table_size = 0;
- return;
-}
-
Tchannel
DEFUN_VOID (channel_allocate)
{
return;
}
-/* Hold-over from DOS.
- This needs to be updated to use the NT equivalent.
- */
+/* Initialization/Termination code. */
-CONST int OS_have_select_p = 0;
+int OS_have_select_p = 0;
-long
-DEFUN (OS_channel_select_then_read, (channel, buffer, nbytes),
- Tchannel channel AND
- PTR buffer AND
- size_t nbytes)
-{ /* We can't really select amongst channels in DOS, but still need
- to keep track of whether the read was interrupted.
- */
- while (1)
+extern HANDLE master_tty_window;
+extern BOOL win32_under_win32s_p (void);
+extern void EXFUN (NT_initialize_channels, (void));
+extern void EXFUN (NT_reset_channels, (void));
+extern void EXFUN (NT_restore_channels, (void));
+
+void
+DEFUN_VOID (NT_reset_channels)
+{
+ NT_free (channel_table);
+ channel_table = 0;
+ OS_channel_table_size = 0;
+ return;
+}
+
+void
+DEFUN_VOID (NT_restore_channels)
+{
+ if (master_tty_window != ((HANDLE) NULL))
+ Screen_Destroy (TRUE, master_tty_window);
+ master_tty_window = ((HANDLE) NULL);
+ return;
+}
+\f
+void
+DEFUN_VOID (NT_initialize_channels)
+{
+#ifndef GUI
+ STDIN_HANDLE = (GetStdHandle (STD_INPUT_HANDLE));
+ STDOUT_HANDLE = (GetStdHandle (STD_OUTPUT_HANDLE));
+ STDERR_HANDLE = (GetStdHandle (STD_ERROR_HANDLE));
+
+ if (STDIN_HANDLE == INVALID_HANDLE_VALUE ||
+ STDOUT_HANDLE == INVALID_HANDLE_VALUE ||
+ STDERR_HANDLE == INVALID_HANDLE_VALUE)
{
- long scr = (nt_channel_read (channel, buffer, nbytes));
+ outf_fatal ("\nUnable to get standard handles %s(%d).\n",
+ __FILE__, __LINE__);
+ termination_init_error ();
+ }
- if (scr < 0)
- {
- if (errno == ERRNO_NONBLOCK)
- return -1;
- else if (errno == EINTR)
- return -4;
- else
- {
- NT_prim_check_errno (syscall_read);
- continue;
- }
- }
- else if (((size_t) scr) > nbytes)
- error_external_return ();
- else
- return (scr);
+ SetConsoleMode (STDIN_HANDLE,
+ ( ENABLE_LINE_INPUT
+ | ENABLE_ECHO_INPUT
+ | ENABLE_PROCESSED_INPUT));
+ SetConsoleCtrlHandler (NT_ctrl_handler, TRUE);
+#endif /* GUI */
+
+ master_tty_window = Screen_Create (NULL, "MIT Scheme", SW_SHOWNORMAL);
+
+ if (win32s_under_win32s_p ())
+ OS_have_select = 0;
+ else
+ OS_have_select = 1;
+ OS_channel_table_size = (NT_SC_OPEN_MAX ());
+ channel_table =
+ (NT_malloc (OS_channel_table_size * (sizeof (struct channel))));
+ if (channel_table == 0)
+ {
+ outf_fatal ("\nUnable to allocate channel table.\n");
+ termination_init_error ();
}
+ {
+ Tchannel channel;
+ for (channel = 0; (channel < OS_channel_table_size); channel += 1)
+ MARK_CHANNEL_CLOSED (channel);
+ }
+ add_reload_cleanup (NT_channel_close_all);
+ OS_channels_registered = 0;
+ return;
}
/* -*-C-*-
-$Id: ntsig.c,v 1.7 1993/08/21 03:45:54 gjr Exp $
+$Id: ntsig.c,v 1.8 1993/09/01 18:44:09 gjr Exp $
Copyright (c) 1992-1993 Massachusetts Institute of Technology
int_handlers[4] = ((unsigned char) interrupt_handler_interactive);
int_chars[5] = CONTROL_BREAK;
int_handlers[5] = ((unsigned char) interrupt_handler_terminate);
- update_interrupt_characters ();
keyboard_interrupt_enables =
(CONTROL_B_ENABLE | CONTROL_G_ENABLE
| CONTROL_U_ENABLE | CONTROL_X_ENABLE
| INTERACTIVE_INTERRUPT_ENABLE
| TERMINATE_INTERRUPT_ENABLE);
+ update_interrupt_characters ();
return;
}
console_write_string ("\nTerminating scheme!");
termination_normal (0);
}
- goto interactive_interrupt;
+ tty_set_next_interrupt_char (CONTROL_G_INTERRUPT_CHAR);
}
return (0);
}
}
interactive_interrupt:
print_interrupt_help ();
- interrupt_p = 0;
+ interrupt_p = 1;
break;
default:
/* Why does this raise INT_Timer as well?
We could request an synchronous Windows timer that would trigger
- the timer interrupt bit.
+ the timer interrupt bit. -- This does not seem to work!
- INT_Global_1: Windows polling interrupt
- INT_Timer: Scheme timer interrupt
+ INT_Global_GC: High-priority Windows polling interrupt.
+ INT_Global_1: Windows polling interrupt.
+ INT_Timer: Thread-switch timer interrupt.
*/
static void * timer_state = ((void *) NULL);
REGBLOCK_MEMTOP,
REGBLOCK_INT_CODE,
REGBLOCK_INT_MASK,
- (INT_Global_1 | INT_Timer),
+ (INT_Global_GC
+ | INT_Global_1
+ | INT_Timer),
&timer_state))
{
case WIN32_ASYNC_TIMER_OK:
/* -*-C-*-
-$Id: nttop.c,v 1.7 1993/08/21 03:48:26 gjr Exp $
+$Id: nttop.c,v 1.8 1993/09/01 18:45:02 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
extern void EXFUN (NT_reset_channels, (void));
+extern void EXFUN (NT_restore_channels, (void));
extern void EXFUN (NT_restore_signals, (void));
extern void EXFUN (NT_restore_traps, (void));
version_t version_number;
nt_get_version (&version_number);
- outf_console ("MIT Scheme running under %s %d.%d 386/486\r\n",
+ outf_console ("MIT Scheme running under %s %d.%d 386/486\n",
OS_Variant,
((int) version_number.major),
((int) version_number.minor));
/* To make our compiler vendors happy. */
outf_console
- ("Copyright (c) 1993 Massachusetts Institute of Technology\r\n");
+ ("Copyright (c) 1993 Massachusetts Institute of Technology\n");
}
- outf_console ("\r\n");
+ outf_console ("\n");
outf_flush_console ();
return;
}
{
NT_restore_traps ();
NT_restore_signals ();
+ NT_restore_channels ();
return;
}