X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/75a8734b11821d807cf64b42c66f8fe141ad4e5e..ce9033f853940155138f64e282809ec975fc8c91:/src/sysdep.c diff --git a/src/sysdep.c b/src/sysdep.c index 35a107f34c..02e1832e63 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -1,6 +1,7 @@ /* 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. @@ -33,12 +34,6 @@ Boston, MA 02110-1301, USA. */ /* 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. */ @@ -54,15 +49,6 @@ extern void srandom P_ ((unsigned int)); #include "blockinput.h" -#ifdef MAC_OS8 -#include - -#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 @@ -156,12 +142,10 @@ extern int errno; #undef TIOCSWINSZ #endif -#if defined (USG) || defined (DGUX) +#if defined (USG) #include -#ifndef MEMORY_IN_STRING_H #include -#endif -#if defined (TIOCGWINSZ) || defined (ISC4_0) +#if defined (TIOCGWINSZ) #ifdef NEED_SIOCTL #include #endif @@ -169,8 +153,8 @@ extern int errno; #include #include #endif -#endif /* TIOCGWINSZ or ISC4_0 */ -#endif /* USG or DGUX */ +#endif /* TIOCGWINSZ */ +#endif /* USG */ extern int quit_char; @@ -350,17 +334,6 @@ discard_tty_input () &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) ; @@ -377,7 +350,6 @@ discard_tty_input () } } #endif /* not MSDOS */ -#endif /* not Apollo */ #endif /* not VMS */ #endif /* not WINDOWSNT */ } @@ -413,9 +385,6 @@ init_baud_rate (int fd) emacs_ospeed = 0; else { -#ifdef INIT_BAUD_RATE - INIT_BAUD_RATE (); -#else #ifdef DOS_NT emacs_ospeed = 15; #else /* not DOS_NT */ @@ -432,11 +401,6 @@ init_baud_rate (int fd) 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; @@ -459,7 +423,6 @@ init_baud_rate (int fd) #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] @@ -537,11 +500,6 @@ wait_for_termination (pid) 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; @@ -575,7 +533,6 @@ wait_for_termination (pid) #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 */ @@ -732,12 +689,6 @@ child_setup_tty (out) 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 */ @@ -826,7 +777,6 @@ sys_suspend () /* Fork a subshell. */ -#ifndef MAC_OS8 void sys_subshell () { @@ -962,7 +912,6 @@ sys_subshell () synch_process_alive = 0; #endif /* !VMS */ } -#endif /* !MAC_OS8 */ static void save_signal_handlers (saved_handlers) @@ -1071,69 +1020,6 @@ unrequest_sigio (void) } #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 - -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 @@ -1155,8 +1041,6 @@ unrequest_sigio () } #endif /* MSDOS */ -#endif /* _CX_UX */ -#endif /* STRIDE */ #endif /* FASYNC */ #endif /* F_SETFL */ #endif /* SIGIO */ @@ -1379,11 +1263,9 @@ emacs_set_tty (fd, settings, flushp) 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, @@ -1491,10 +1373,6 @@ init_sys_modes (tty_out) #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, @@ -1708,11 +1586,9 @@ init_sys_modes (tty_out) #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 @@ -1743,7 +1619,6 @@ init_sys_modes (tty_out) #endif /* VMS */ #ifdef F_SETFL -#ifndef F_SETOWN_BUG #ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */ if (interrupt_input) { @@ -1762,7 +1637,6 @@ init_sys_modes (tty_out) #endif /* HAVE_GPM */ } #endif /* F_GETOWN */ -#endif /* F_SETOWN_BUG */ #endif /* F_SETFL */ #ifdef BSD4_1 @@ -2006,7 +1880,6 @@ reset_sys_modes (tty_out) #endif #ifdef F_SETFL -#ifndef F_SETOWN_BUG #ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ if (interrupt_input) { @@ -2015,7 +1888,6 @@ reset_sys_modes (tty_out) 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); @@ -2090,14 +1962,6 @@ setup_pty (fd) } #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 */ @@ -2382,13 +2246,8 @@ start_of_text () #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 */ @@ -2518,10 +2377,50 @@ init_system_name () #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 @@ -2529,11 +2428,14 @@ init_system_name () #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; @@ -2567,6 +2469,7 @@ init_system_name () } #endif } +#endif /* !HAVE_GETADDRINFO */ } #endif /* HAVE_SOCKETS */ /* We used to try using getdomainname here, @@ -2623,7 +2526,7 @@ init_system_name () #ifndef MSDOS #ifndef VMS -#if !defined (HAVE_SELECT) || defined (BROKEN_SELECT_NON_X) +#if !defined (HAVE_SELECT) #include "sysselect.h" #undef select @@ -2861,7 +2764,7 @@ read_input_waiting () } } -#if !defined (HAVE_SELECT) || defined (BROKEN_SELECT_NON_X) +#if !defined (HAVE_SELECT) #define select sys_select #endif @@ -3285,16 +3188,6 @@ get_random () return val & ((1L << VALBITS) - 1); } -#ifdef WRONG_NAME_INSQUE - -insque (q,p) - caddr_t q,p; -{ - _insque (q,p); -} - -#endif - #ifdef VMS #ifdef getenv @@ -3442,6 +3335,15 @@ emacs_close (fd) 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; @@ -5368,31 +5270,6 @@ hft_reset (struct tty_display_info *tty_out) #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 */ #ifndef BSTRING