/* Interfaces to system-dependent kernel and library entries.
Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1999, 2000, 2001,
- 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ Free Software Foundation, Inc.
This file is part of GNU Emacs.
/* Including stdlib.h isn't necessarily enough to get srandom
declared, e.g. without __USE_XOPEN_EXTENDED with glibc 2. */
#ifdef HAVE_RANDOM
-#if 0 /* It turns out that defining _OSF_SOURCE in osf5-0.h gets
- random prototyped as returning `int'. It looks to me as
- though the best way to DTRT is to prefer the rand48 functions
- (per libc.info). -- fx */
-extern long int random P_ ((void));
-#endif
#if 0 /* Don't prototype srandom; it takes an unsigned argument on
some systems, and an unsigned long on others, like FreeBSD
4.1. */
#endif
#endif
+/* The w32 build defines select stuff in w32.h, which is included by
+ sys/select.h (included below). */
+#ifndef WINDOWSNT
#include "sysselect.h"
+#endif
#include "blockinput.h"
-#ifdef MAC_OS8
-#include <sys/param.h>
-
-#ifndef subprocesses
-/* Nonzero means delete a process right away if it exits (process.c). */
-static int delete_exited_processes;
-#endif
-#endif /* MAC_OS8 */
-
#ifdef WINDOWSNT
#define read sys_read
#define write sys_write
#undef TIOCSWINSZ
#endif
-#if defined (USG) || defined (DGUX)
+#if defined (USG)
#include <sys/utsname.h>
-#ifndef MEMORY_IN_STRING_H
#include <memory.h>
-#endif
-#if defined (TIOCGWINSZ) || defined (ISC4_0)
+#if defined (TIOCGWINSZ)
#ifdef NEED_SIOCTL
#include <sys/sioctl.h>
#endif
#include <sys/stream.h>
#include <sys/ptem.h>
#endif
-#endif /* TIOCGWINSZ or ISC4_0 */
-#endif /* USG or DGUX */
+#endif /* TIOCGWINSZ */
+#endif /* USG */
extern int quit_char;
&buf.main, 0, 0, terminator_mask, 0, 0);
queue_kbd_input ();
#else /* not VMS */
-#ifdef APOLLO
- {
- struct tty_display_info *tty;
- for (tty = tty_list; tty; tty = tty->next)
- {
- int zero = 0;
- if (tty->input)
- ioctl (fileno (tty->input), TIOCFLUSH, &zero);
- }
- }
-#else /* not Apollo */
#ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */
while (dos_keyread () != -1)
;
}
}
#endif /* not MSDOS */
-#endif /* not Apollo */
#endif /* not VMS */
#endif /* not WINDOWSNT */
}
emacs_ospeed = 0;
else
{
-#ifdef INIT_BAUD_RATE
- INIT_BAUD_RATE ();
-#else
#ifdef DOS_NT
emacs_ospeed = 15;
#else /* not DOS_NT */
sg.c_cflag = B9600;
tcgetattr (fd, &sg);
emacs_ospeed = cfgetospeed (&sg);
-#if defined (USE_GETOBAUD) && defined (getobaud)
- /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */
- if (emacs_ospeed == 0)
- emacs_ospeed = getobaud (sg.c_cflag);
-#endif
#else /* neither VMS nor TERMIOS */
#ifdef HAVE_TERMIO
struct termio sg;
#endif /* not HAVE_TERMIOS */
#endif /* not VMS */
#endif /* not DOS_NT */
-#endif /* not INIT_BAUD_RATE */
}
baud_rate = (emacs_ospeed < sizeof baud_convert / sizeof baud_convert[0]
else
sigpause (SIGEMPTYMASK);
#else /* not BSD_SYSTEM, and not HPUX version >= 6 */
-#if defined (UNIPLUS)
- if (0 > kill (pid, 0))
- break;
- wait (0);
-#else /* neither BSD_SYSTEM nor UNIPLUS: random sysV */
#ifdef POSIX_SIGNALS /* would this work for GNU/Linux as well? */
sigblock (sigmask (SIGCHLD));
errno = 0;
#endif /* not WINDOWSNT */
#endif /* not HAVE_SYSV_SIGPAUSE */
#endif /* not POSIX_SIGNALS */
-#endif /* not UNIPLUS */
#endif /* not BSD_SYSTEM, and not HPUX version >= 6 */
#endif /* not VMS */
#else /* not subprocesses */
if (interrupt_input)
reset_sigio (0);
#endif /* BSD4_1 */
-#ifdef RTU
- {
- int zero = 0;
- ioctl (out, FIOASYNC, &zero);
- }
-#endif /* RTU */
#endif /* not DOS_NT */
}
#endif /* not VMS */
/* Fork a subshell. */
-#ifndef MAC_OS8
void
sys_subshell ()
{
synch_process_alive = 0;
#endif /* !VMS */
}
-#endif /* !MAC_OS8 */
static void
save_signal_handlers (saved_handlers)
}
#else /* no FASYNC */
-#ifdef STRIDE /* Stride doesn't have FASYNC - use FIOASYNC */
-
-void
-request_sigio ()
-{
- int on = 1;
-
- if (noninteractive || read_socket_hook)
- return;
-
- /* XXX CURTTY() is bogus here. */
- ioctl (fileno (CURTTY ()->input), FIOASYNC, &on);
- interrupts_deferred = 0;
-}
-
-void
-unrequest_sigio ()
-{
- int off = 0;
-
- if (noninteractive || read_socket_hook)
- return;
-
- /* XXX CURTTY() is bogus here. */
- ioctl (fileno (CURTTY ()->input), FIOASYNC, &off);
- interrupts_deferred = 1;
-}
-
-#else /* not FASYNC, not STRIDE */
-
-#ifdef _CX_UX
-
-#include <termios.h>
-
-void
-request_sigio ()
-{
- int on = 1;
- sigset_t st;
-
- if (noninteractive || read_socket_hook)
- return;
-
- sigemptyset (&st);
- sigaddset (&st, SIGIO);
- ioctl (0, FIOASYNC, &on); /* XXX This fails for multiple ttys. */
- interrupts_deferred = 0;
- sigprocmask (SIG_UNBLOCK, &st, (sigset_t *)0);
-}
-
-void
-unrequest_sigio ()
-{
- int off = 0;
-
- if (noninteractive || read_socket_hook)
- return;
-
- ioctl (0, FIOASYNC, &off); /* XXX This fails for multiple ttys. */
- interrupts_deferred = 1;
-}
-
-#else /* ! _CX_UX */
#ifndef MSDOS
void
}
#endif /* MSDOS */
-#endif /* _CX_UX */
-#endif /* STRIDE */
#endif /* FASYNC */
#endif /* F_SETFL */
#endif /* SIGIO */
redirect the tty device handle FD to point to our own process
group. We need to be in our own process group to receive SIGIO
properly. */
-void
+static void
narrow_foreground_group (int fd)
{
int me = getpid ();
}
/* Set the tty to our original foreground group. */
-void
+static void
widen_foreground_group (int fd)
{
if (inherited_pgroup != getpid ())
int lmode;
#endif
-#ifndef F_SETOWN_BUG
#ifdef F_SETOWN
int old_fcntl_owner[MAXDESC];
#endif /* F_SETOWN */
-#endif /* F_SETOWN_BUG */
/* This may also be defined in stdio,
but if so, this does no harm,
#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
XSETINT (Vtty_erase_char, tty.main.c_cc[VERASE]);
-#ifdef DGUX
- /* This allows meta to be sent on 8th bit. */
- tty.main.c_iflag &= ~INPCK; /* don't check input for parity */
-#endif
tty.main.c_iflag |= (IGNBRK); /* Ignore break condition */
tty.main.c_iflag &= ~ICRNL; /* Disable map of CR to NL on input */
#ifdef INLCR /* I'm just being cautious,
#ifdef TCXONC
if (!tty_out->flow_control) ioctl (fileno (tty_out->input), TCXONC, 1);
#endif
-#ifndef APOLLO
#ifdef TIOCSTART
if (!tty_out->flow_control) ioctl (fileno (tty_out->input), TIOCSTART, 0);
#endif
-#endif
#if defined (HAVE_TERMIOS) || defined (HPUX9)
#ifdef TCOON
#endif /* VMS */
#ifdef F_SETFL
-#ifndef F_SETOWN_BUG
#ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */
if (interrupt_input)
{
fcntl (fileno (tty_out->input), F_SETOWN, getpid ());
init_sigio (fileno (tty_out->input));
#ifdef HAVE_GPM
- if (term_gpm)
+ if (gpm_tty == tty_out)
{
+ /* Arrange for mouse events to give us SIGIO signals. */
fcntl (gpm_fd, F_SETOWN, getpid ());
fcntl (gpm_fd, F_SETFL, fcntl (gpm_fd, F_GETFL, 0) | O_NONBLOCK);
init_sigio (gpm_fd);
#endif /* HAVE_GPM */
}
#endif /* F_GETOWN */
-#endif /* F_SETOWN_BUG */
#endif /* F_SETFL */
#ifdef BSD4_1
setbuf (tty_out->output, (char *) _sobuf);
#endif
- tty_set_terminal_modes (tty_out->terminal);
+ if (tty_out->terminal->set_terminal_modes_hook)
+ tty_out->terminal->set_terminal_modes_hook (tty_out->terminal);
if (!tty_out->term_initted)
{
}
#endif
- tty_reset_terminal_modes (tty_out->terminal);
+ if (tty_out->terminal->reset_terminal_modes_hook)
+ tty_out->terminal->reset_terminal_modes_hook (tty_out->terminal);
#ifdef BSD_SYSTEM
#ifndef BSD4_1
#endif
#ifdef F_SETFL
-#ifndef F_SETOWN_BUG
#ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */
if (interrupt_input)
{
old_fcntl_owner[fileno (tty_out->input)]);
}
#endif /* F_SETOWN */
-#endif /* F_SETOWN_BUG */
#ifdef O_NDELAY
fcntl (fileno (tty_out->input), F_SETFL,
fcntl (fileno (tty_out->input), F_GETFL, 0) & ~O_NDELAY);
}
#endif
#endif
-#ifdef IBMRTAIX
- /* On AIX, the parent gets SIGHUP when a pty attached child dies. So, we */
- /* ignore SIGHUP once we've started a child on a pty. Note that this may */
- /* cause EMACS not to die when it should, i.e., when its own controlling */
- /* tty goes away. I've complained to the AIX developers, and they may */
- /* change this behavior, but I'm not going to hold my breath. */
- signal (SIGHUP, SIG_IGN);
-#endif
}
#endif /* HAVE_PTYS */
\f
#ifdef TEXT_START
return ((char *) TEXT_START);
#else
-#ifdef GOULD
- extern csrt ();
- return ((char *) csrt);
-#else /* not GOULD */
extern int _start ();
return ((char *) _start);
-#endif /* GOULD */
#endif /* TEXT_START */
}
#endif /* not HAVE_TEXT_START */
#endif /* not CANNOT_DUMP */
if (! index (hostname, '.'))
{
- struct hostent *hp;
int count;
+#ifdef HAVE_GETADDRINFO
+ struct addrinfo *res;
+ struct addrinfo hints;
+ int ret;
+
+ memset (&hints, 0, sizeof(hints));
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_CANONNAME;
+
for (count = 0;; count++)
{
+ if ((ret = getaddrinfo (hostname, NULL, &hints, &res)) == 0
+ || ret != EAI_AGAIN)
+ break;
+
+ if (count >= 5)
+ break;
+ Fsleep_for (make_number (1), Qnil);
+ }
+
+ if (ret == 0)
+ {
+ struct addrinfo *it = res;
+ while (it)
+ {
+ char *fqdn = it->ai_canonname;
+ if (fqdn && index (fqdn, '.')
+ && strcmp (fqdn, "localhost.localdomain") != 0)
+ break;
+ it = it->ai_next;
+ }
+ if (it)
+ {
+ hostname = alloca (strlen (it->ai_canonname) + 1);
+ strcpy (hostname, it->ai_canonname);
+ }
+ freeaddrinfo (res);
+ }
+#else /* !HAVE_GETADDRINFO */
+ struct hostent *hp;
+ for (count = 0;; count++)
+ {
+
#ifdef TRY_AGAIN
h_errno = 0;
#endif
#ifdef TRY_AGAIN
if (! (hp == 0 && h_errno == TRY_AGAIN))
#endif
+
break;
+
if (count >= 5)
break;
Fsleep_for (make_number (1), Qnil);
}
+
if (hp)
{
char *fqdn = (char *) hp->h_name;
}
#endif
}
+#endif /* !HAVE_GETADDRINFO */
}
#endif /* HAVE_SOCKETS */
/* We used to try using getdomainname here,
\f
#ifndef MSDOS
#ifndef VMS
-#if !defined (HAVE_SELECT) || defined (BROKEN_SELECT_NON_X)
+#if !defined (HAVE_SELECT)
#include "sysselect.h"
#undef select
}
}
-#if !defined (HAVE_SELECT) || defined (BROKEN_SELECT_NON_X)
+#if !defined (HAVE_SELECT)
#define select sys_select
#endif
return val & ((1L << VALBITS) - 1);
}
\f
-#ifdef WRONG_NAME_INSQUE
-
-insque (q,p)
- caddr_t q,p;
-{
- _insque (q,p);
-}
-
-#endif
-\f
#ifdef VMS
#ifdef getenv
int did_retry = 0;
register int rtnval;
+#if defined (MAC_OSX) && defined (HAVE_CARBON)
+ {
+ extern int mac_try_close_socket P_ ((int));
+
+ if (mac_try_close_socket (fd))
+ return 0;
+ }
+#endif
+
while ((rtnval = close (fd)) == -1
&& (errno == EINTR))
did_retry = 1;
#endif /* AIXHFT */
-#ifdef USE_DL_STUBS
-
-/* These are included on Sunos 4.1 when we do not use shared libraries.
- X11 libraries may refer to these functions but (we hope) do not
- actually call them. */
-
-void *
-dlopen ()
-{
- return 0;
-}
-
-void *
-dlsym ()
-{
- return 0;
-}
-
-int
-dlclose ()
-{
- return -1;
-}
-
-#endif /* USE_DL_STUBS */
\f
#ifndef BSTRING