-#ifdef VMS
-
-/* Assigning an input channel is done at the start of Emacs execution.
- This is called each time Emacs is resumed, also, but does nothing
- because input_chain is no longer zero. */
-
-void
-init_vms_input ()
-{
- int status;
-
- if (fileno (CURTTY ()->input)) == 0)
- {
- status = SYS$ASSIGN (&input_dsc, &fileno (CURTTY ()->input)), 0, 0);
- if (! (status & 1))
- LIB$STOP (status);
- }
-}
-
-/* Deassigning the input channel is done before exiting. */
-
-void
-stop_vms_input ()
-{
- return SYS$DASSGN (fileno (CURTTY ()->input)));
-}
-
-short input_buffer;
-
-/* Request reading one character into the keyboard buffer.
- This is done as soon as the buffer becomes empty. */
-
-void
-queue_kbd_input ()
-{
- int status;
- extern kbd_input_ast ();
-
- waiting_for_ast = 0;
- stop_input = 0;
- status = SYS$QIO (0, fileno (CURTTY()->input), IO$_READVBLK,
- &input_iosb, kbd_input_ast, 1,
- &input_buffer, 1, 0, terminator_mask, 0, 0);
-}
-
-int input_count;
-
-/* Ast routine that is called when keyboard input comes in
- in accord with the SYS$QIO above. */
-
-void
-kbd_input_ast ()
-{
- register int c = -1;
- int old_errno = errno;
- extern EMACS_TIME *input_available_clear_time;
-
- if (waiting_for_ast)
- SYS$SETEF (input_ef);
- waiting_for_ast = 0;
- input_count++;
-#ifdef ASTDEBUG
- if (input_count == 25)
- exit (1);
- printf ("Ast # %d,", input_count);
- printf (" iosb = %x, %x, %x, %x",
- input_iosb.offset, input_iosb.status, input_iosb.termlen,
- input_iosb.term);
-#endif
- if (input_iosb.offset)
- {
- c = input_buffer;
-#ifdef ASTDEBUG
- printf (", char = 0%o", c);
-#endif
- }
-#ifdef ASTDEBUG
- printf ("\n");
- fflush (stdout);
- sleep (1);
-#endif
- if (! stop_input)
- queue_kbd_input ();
- if (c >= 0)
- {
- struct input_event e;
- EVENT_INIT (e);
-
- e.kind = ASCII_KEYSTROKE_EVENT;
- XSETINT (e.code, c);
- e.frame_or_window = selected_frame;
- kbd_buffer_store_event (&e);
- }
- if (input_available_clear_time)
- EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
- errno = old_errno;
-}
-
-/* Wait until there is something in kbd_buffer. */
-
-void
-wait_for_kbd_input ()
-{
- extern int have_process_input, process_exited;
-
- /* If already something, avoid doing system calls. */
- if (detect_input_pending ())
- {
- return;
- }
- /* Clear a flag, and tell ast routine above to set it. */
- SYS$CLREF (input_ef);
- waiting_for_ast = 1;
- /* Check for timing error: ast happened while we were doing that. */
- if (!detect_input_pending ())
- {
- /* No timing error: wait for flag to be set. */
- set_waiting_for_input (0);
- SYS$WFLOR (input_ef, input_eflist);
- clear_waiting_for_input ();
- if (!detect_input_pending ())
- /* Check for subprocess input availability */
- {
- int dsp = have_process_input || process_exited;
-
- SYS$CLREF (process_ef);
- if (have_process_input)
- process_command_input ();
- if (process_exited)
- process_exit ();
- if (dsp)
- {
- update_mode_lines++;
- prepare_menu_bars ();
- redisplay_preserve_echo_area (18);
- }
- }
- }
- waiting_for_ast = 0;
-}
-
-/* Get rid of any pending QIO, when we are about to suspend
- or when we want to throw away pending input.
- We wait for a positive sign that the AST routine has run
- and therefore there is no I/O request queued when we return.
- SYS$SETAST is used to avoid a timing error. */
-
-void
-end_kbd_input ()
-{
-#ifdef ASTDEBUG
- printf ("At end_kbd_input.\n");
- fflush (stdout);
- sleep (1);
-#endif
- if (LIB$AST_IN_PROG ()) /* Don't wait if suspending from kbd_buffer_store_event! */
- {
- SYS$CANCEL (fileno (CURTTY()->input));
- return;
- }
-
- SYS$SETAST (0);
- /* Clear a flag, and tell ast routine above to set it. */
- SYS$CLREF (input_ef);
- waiting_for_ast = 1;
- stop_input = 1;
- SYS$CANCEL (fileno (CURTTY()->input));
- SYS$SETAST (1);
- SYS$WAITFR (input_ef);
- waiting_for_ast = 0;
-}
-
-/* Wait for either input available or time interval expiry. */
-
-void
-input_wait_timeout (timeval)
- int timeval; /* Time to wait, in seconds */
-{
- int time [2];
- static int zero = 0;
- static int large = -10000000;
-
- LIB$EMUL (&timeval, &large, &zero, time); /* Convert to VMS format */
-
- /* If already something, avoid doing system calls. */
- if (detect_input_pending ())
- {
- return;
- }
- /* Clear a flag, and tell ast routine above to set it. */
- SYS$CLREF (input_ef);
- waiting_for_ast = 1;
- /* Check for timing error: ast happened while we were doing that. */
- if (!detect_input_pending ())
- {
- /* No timing error: wait for flag to be set. */
- SYS$CANTIM (1, 0);
- if (SYS$SETIMR (timer_ef, time, 0, 1) & 1) /* Set timer */
- SYS$WFLOR (timer_ef, timer_eflist); /* Wait for timer expiry or input */
- }
- waiting_for_ast = 0;
-}
-
-/* The standard `sleep' routine works some other way
- and it stops working if you have ever quit out of it.
- This one continues to work. */
-
-sys_sleep (timeval)
- int timeval;
-{
- int time [2];
- static int zero = 0;
- static int large = -10000000;
-
- LIB$EMUL (&timeval, &large, &zero, time); /* Convert to VMS format */
-
- SYS$CANTIM (1, 0);
- if (SYS$SETIMR (timer_ef, time, 0, 1) & 1) /* Set timer */
- SYS$WAITFR (timer_ef); /* Wait for timer expiry only */
-}
-
-void
-init_sigio (fd)
- int fd;
-{
- request_sigio ();
-}
-
-reset_sigio (fd)
- int fd;
-{
- unrequest_sigio ();
-}
-
-void
-request_sigio ()
-{
- if (noninteractive)
- return;
- croak ("request sigio");
-}
-
-void
-unrequest_sigio ()
-{
- if (noninteractive)
- return;
- croak ("unrequest sigio");
-}
-
-#endif /* VMS */
-\f
-/* Note that VMS compiler won't accept defined (CANNOT_DUMP). */
-#ifndef CANNOT_DUMP
-#define NEED_STARTS
-#endif
-
-#ifndef SYSTEM_MALLOC
-#ifndef NEED_STARTS
-#define NEED_STARTS
-#endif
-#endif
-
-#ifdef NEED_STARTS