/* 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.
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA. */
+along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#include "lisp.h"
/* 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. */
-extern void srandom P_ ((unsigned int));
-#endif
-#endif
/* The w32 build defines select stuff in w32.h, which is included by
sys/select.h (included below). */
#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
#include "systty.h"
#include "syswait.h"
-#ifdef BROKEN_TIOCGWINSZ
-#undef TIOCGWINSZ
-#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)
-#ifdef NEED_SIOCTL
-#include <sys/sioctl.h>
-#endif
-#ifdef NEED_PTEM_H
-#include <sys/stream.h>
-#include <sys/ptem.h>
-#endif
-#endif /* TIOCGWINSZ or ISC4_0 */
-#endif /* USG or DGUX */
+#endif /* USG */
extern int quit_char;
#include "process.h"
#include "cm.h" /* for reset_sys_modes */
+/* For serial_configure and serial_open. */
+extern Lisp_Object QCport, QCspeed, QCprocess;
+extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven;
+extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary;
+
#ifdef WINDOWSNT
#include <direct.h>
/* In process.h which conflicts with the local copy. */
#define _P_WAIT 0
-int _CRTAPI1 _spawnlp (int, const char *, const char *, ...);
-int _CRTAPI1 _getpid (void);
+int _cdecl _spawnlp (int, const char *, const char *, ...);
+int _cdecl _getpid (void);
extern char *getwd (char *);
#endif
#define LPASS8 0
#endif
-#ifdef BSD4_1
-#define LNOFLSH 0100000
-#endif
-
static int baud_convert[] =
-#ifdef BAUD_CONVERT
- BAUD_CONVERT;
-#else
{
0, 50, 75, 110, 135, 150, 200, 300, 600, 1200,
1800, 2400, 4800, 9600, 19200, 38400
};
-#endif
#ifdef HAVE_SPEED_T
#include <termios.h>
void croak P_ ((char *)) NO_RETURN;
-#ifdef AIXHFT
-void hft_init P_ ((struct tty_display_info *));
-void hft_reset P_ ((struct tty_display_info *));
-#endif
-
/* Temporary used by `sigblock' when defined in terms of signprocmask. */
SIGMASKTYPE sigprocmask_set;
&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]
status = SYS$FORCEX (&pid, 0, 0);
break;
#else /* not VMS */
-#if defined (BSD_SYSTEM) || (defined (HPUX) && !defined (HPUX_5))
+#if defined (BSD_SYSTEM) || defined (HPUX)
/* Note that kill returns -1 even if the process is just a zombie now.
But inevitably a SIGCHLD interrupt should be generated
and child_sig will do wait3 and make the process go away. */
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 __DJGPP__ > 1
break;
#else /* not __DJGPP__ > 1 */
-#ifndef BSD4_1
if (kill (pid, 0) < 0)
break;
wait (0);
-#else /* BSD4_1 */
- int status;
- status = wait (0);
- if (status == pid || status == -1)
- break;
-#endif /* BSD4_1 */
#endif /* not __DJGPP__ > 1*/
#endif /* not subprocesses */
}
s.main.c_oflag |= OPOST; /* Enable output postprocessing */
s.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL on output */
#ifdef NLDLY
+ /* http://lists.gnu.org/archive/html/emacs-devel/2008-05/msg00406.html
+ Some versions of GNU Hurd do not have FFDLY? */
+#ifdef FFDLY
s.main.c_oflag &= ~(NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);
/* No output delays */
+#else
+ s.main.c_oflag &= ~(NLDLY|CRDLY|TABDLY|BSDLY|VTDLY);
+ /* No output delays */
+#endif
#endif
s.main.c_lflag &= ~ECHO; /* Disable echo */
s.main.c_lflag |= ISIG; /* Enable signals */
-#if 0 /* This causes bugs in (for instance) telnet to certain sites. */
- s.main.c_iflag &= ~ICRNL; /* Disable map of CR to NL on input */
-#ifdef INLCR /* Just being cautious, since I can't check how
- widespread INLCR is--rms. */
- s.main.c_iflag &= ~INLCR; /* Disable map of NL to CR on input */
-#endif
-#endif
#ifdef IUCLC
s.main.c_iflag &= ~IUCLC; /* Disable downcasing on input. */
#endif
#endif
s.main.c_oflag &= ~TAB3; /* Disable tab expansion */
s.main.c_cflag = (s.main.c_cflag & ~CSIZE) | CS8; /* Don't strip 8th bit */
-#if 0
- /* Said to be unnecessary: */
- s.main.c_cc[VMIN] = 1; /* minimum number of characters to accept */
- s.main.c_cc[VTIME] = 0; /* wait forever for at least 1 character */
-#endif
-
s.main.c_lflag |= ICANON; /* Enable erase/kill and eof processing */
s.main.c_cc[VEOF] = 04; /* insure that EOF is Control-D */
s.main.c_cc[VERASE] = CDISABLE; /* disable erase processing */
EMACS_SET_TTY (out, &s, 0);
-#ifdef BSD4_1
- 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 ()
{
if (epwd)
putenv (old_pwd); /* restore previous value */
}
-#if 0 /* This is also reported if last command executed in subshell failed, KFS */
- if (st)
- report_file_error ("Can't execute subshell", Fcons (build_string (sh), Qnil));
-#endif
#else /* not MSDOS */
#ifdef WINDOWSNT
/* Waits for process completion */
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 */
\f
-#ifdef BSD4_1
-/* BSD 4.1 needs to keep track of the lmode bits in order to start
- sigio. */
-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,
and using the same name avoids wasting the other one's space. */
-#ifdef nec_ews_svr4
-extern char *_sobuf ;
-#else
#if defined (USG) || defined (DGUX)
unsigned char _sobuf[BUFSIZ+8];
#else
char _sobuf[BUFSIZ];
#endif
-#endif
#ifdef HAVE_LTCHARS
static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1};
{
struct emacs_tty tty;
-#ifdef VMS
-#if 0
- static int oob_chars[2] = {0, 1 << 7}; /* catch C-g's */
- extern int (*interrupt_signal) ();
-#endif
-#endif
-
Vtty_erase_char = Qnil;
if (noninteractive)
timer_ef = get_timer_event_flag ();
/* LIB$GET_EF (&timer_ef); */
SYS$CLREF (timer_ef);
-#if 0
- if (!process_ef)
- {
- LIB$GET_EF (&process_ef);
- SYS$CLREF (process_ef);
- }
- if (input_ef / 32 != process_ef / 32)
- croak ("Input and process event flags in different clusters.");
-#endif
if (input_ef / 32 != timer_ef / 32)
croak ("Input and timer event flags in different clusters.");
-#if 0
- input_eflist = ((unsigned) 1 << (input_ef % 32)) |
- ((unsigned) 1 << (process_ef % 32));
-#endif
timer_eflist = ((unsigned) 1 << (input_ef % 32)) |
((unsigned) 1 << (timer_ef % 32));
#ifndef VMS4_4
#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,
}
#endif /* mips or HAVE_TCATTR */
-#ifdef SET_LINE_DISCIPLINE
- /* Need to explicitly request TERMIODISC line discipline or
- Ultrix's termios does not work correctly. */
- tty.main.c_line = SET_LINE_DISCIPLINE;
-#endif
#ifdef AIX
#ifndef IBMR2AIX
/* AIX enhanced edit loses NULs, so disable it. */
}
tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | tty_out->old_tty.lmode;
-#ifdef ultrix
- /* Under Ultrix 4.2a, leaving this out doesn't seem to hurt
- anything, and leaving it in breaks the meta key. Go figure. */
- tty.lmode &= ~LLITOUT;
-#endif
-#ifdef BSD4_1
- lmode = tty.lmode;
-#endif
-
#endif /* HAVE_TCHARS */
#endif /* not HAVE_TERMIO */
#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)
+#if defined (HAVE_TERMIOS) || defined (HPUX)
#ifdef TCOON
if (!tty_out->flow_control) tcflow (fileno (tty_out->input), TCOON);
#endif
#endif
-#ifdef AIXHFT
- hft_init (tty_out);
-#ifdef IBMR2AIX
- {
- /* IBM's HFT device usually thinks a ^J should be LF/CR. We need it
- to be only LF. This is the way that is done. */
- struct termio tty;
-
- if (ioctl (1, HFTGETID, &tty) != -1)
- write (1, "\033[20l", 5);
- }
-#endif
-#endif /* AIXHFT */
-
#ifdef VMS
/* Appears to do nothing when in PASTHRU mode.
SYS$QIOW (0, fileno (tty_out->input), IO$_SETMODE|IO$M_OUTBAND, 0, 0, 0,
#endif /* VMS */
#ifdef F_SETFL
-#ifndef F_SETOWN_BUG
#ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */
if (interrupt_input)
{
#endif /* HAVE_GPM */
}
#endif /* F_GETOWN */
-#endif /* F_SETOWN_BUG */
#endif /* F_SETFL */
-#ifdef BSD4_1
- if (interrupt_input)
- init_sigio (fileno (tty_out->input));
-#endif
-
#ifdef VMS /* VMS sometimes has this symbol but lacks setvbuf. */
#undef _IOFBF
#endif
cmgoto (tty_out, FrameRows (tty_out) - 1, 0);
fflush (tty_out->output);
-#if defined (IBMR2AIX) && defined (AIXHFT)
- {
- /* HFT devices normally use ^J as a LF/CR. We forced it to
- do the LF only. Now, we need to reset it. */
- struct termio tty;
-
- if (ioctl (1, HFTGETID, &tty) != -1)
- write (1, "\033[20h", 5);
- }
-#endif
-
if (tty_out->terminal->reset_terminal_modes_hook)
tty_out->terminal->reset_terminal_modes_hook (tty_out->terminal);
#ifdef BSD_SYSTEM
-#ifndef BSD4_1
/* Avoid possible loss of output when changing terminal modes. */
fsync (fileno (tty_out->output));
#endif
-#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 /* F_SETFL */
-#ifdef BSD4_1
- if (interrupt_input)
- reset_sigio (fileno (tty_out->input));
-#endif /* BSD4_1 */
if (tty_out->old_tty)
while (EMACS_SET_TTY (fileno (tty_out->input),
dos_ttcooked ();
#endif
-#ifdef SET_LINE_DISCIPLINE
- /* Ultrix's termios *ignores* any line discipline except TERMIODISC.
- A different old line discipline is therefore not restored, yet.
- Restore the old line discipline by hand. */
- ioctl (0, TIOCSETD, &tty_out->old_tty.main.c_line);
-#endif
-
-#ifdef AIXHFT
- hft_reset ();
-#endif
-
#ifdef BSD_PGRPS
widen_foreground_group (fileno (tty_out->input));
#endif
Since the latter lossage is more benign, we may as well
lose that way. -- cph */
#ifdef FIONBIO
-#if defined(SYSV_PTYS) || defined(UNIX98_PTYS)
+#if defined(UNIX98_PTYS)
{
int on = 1;
ioctl (fd, FIONBIO, &on);
}
#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 */
/* init_system_name sets up the string for the Lisp function
system-name to return. */
-#ifdef BSD4_1
-#include <whoami.h>
-#endif
-
extern Lisp_Object Vsystem_name;
-#ifndef BSD4_1
#ifndef VMS
#ifdef HAVE_SOCKETS
#include <sys/socket.h>
#include <netdb.h>
#endif /* HAVE_SOCKETS */
#endif /* not VMS */
-#endif /* not BSD4_1 */
#ifdef TRY_AGAIN
#ifndef HAVE_H_ERRNO
void
init_system_name ()
{
-#ifdef BSD4_1
- Vsystem_name = build_string (sysname);
-#else
#ifdef VMS
char *sp, *end;
if ((sp = egetenv ("SYS$NODE")) == 0)
#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;
-#if 0
- char *p;
-#endif
if (!index (fqdn, '.'))
{
fqdn = *alias;
}
hostname = fqdn;
-#if 0
- /* Convert the host name to lower case. */
- /* Using ctype.h here would introduce a possible locale
- dependence that is probably wrong for hostnames. */
- p = hostname;
- while (*p)
- {
- if (*p >= 'A' && *p <= 'Z')
- *p += 'a' - 'A';
- p++;
- }
-#endif
}
+#endif /* !HAVE_GETADDRINFO */
}
#endif /* HAVE_SOCKETS */
- /* We used to try using getdomainname here,
- but NIIBE Yutaka <gniibe@etl.go.jp> says that
- getdomainname gets the NIS/YP domain which often is not the same
- as in Internet domain name. */
-#if 0 /* Turned off because sysinfo is not really likely to return the
- correct Internet domain. */
-#if (HAVE_SYSINFO && defined (SI_SRPC_DOMAIN))
- if (! index (hostname, '.'))
- {
- /* The hostname is not fully qualified. Append the domain name. */
-
- int hostlen = strlen (hostname);
- int domain_size = 256;
-
- for (;;)
- {
- char *domain = (char *) alloca (domain_size + 1);
- char *fqdn = (char *) alloca (hostlen + 1 + domain_size + 1);
- int sys_domain_size = sysinfo (SI_SRPC_DOMAIN, domain, domain_size);
- if (sys_domain_size <= 0)
- break;
- if (domain_size < sys_domain_size)
- {
- domain_size = sys_domain_size;
- continue;
- }
- strcpy (fqdn, hostname);
- if (domain[0] == '.')
- strcpy (fqdn + hostlen, domain);
- else if (domain[0] != 0)
- {
- fqdn[hostlen] = '.';
- strcpy (fqdn + hostlen + 1, domain);
- }
- hostname = fqdn;
- break;
- }
- }
-#endif /* HAVE_SYSINFO && defined (SI_SRPC_DOMAIN) */
-#endif /* 0 */
Vsystem_name = build_string (hostname);
#endif /* HAVE_GETHOSTNAME */
#endif /* VMS */
-#endif /* BSD4_1 */
{
unsigned char *p;
for (p = SDATA (Vsystem_name); *p; p++)
\f
#ifndef MSDOS
#ifndef VMS
-#if !defined (HAVE_SELECT) || defined (BROKEN_SELECT_NON_X)
+#if !defined (HAVE_SELECT)
#include "sysselect.h"
#undef select
select_alarm ()
{
select_alarmed = 1;
-#ifdef BSD4_1
- sigrelse (SIGALRM);
-#else /* not BSD4_1 */
signal (SIGALRM, SIG_IGN);
-#endif /* not BSD4_1 */
SIGNAL_THREAD_CHECK (SIGALRM);
if (read_alarm_should_throw)
longjmp (read_alarm_throw, 1);
}
}
-#if !defined (HAVE_SELECT) || defined (BROKEN_SELECT_NON_X)
+#if !defined (HAVE_SELECT)
#define select sys_select
#endif
#endif /* not VMS */
#endif /* not MSDOS */
\f
-#ifdef BSD4_1
-void
-init_sigio (fd)
- int fd;
-{
- if (noninteractive)
- return;
- lmode = LINTRUP | lmode;
- ioctl (fd, TIOCLSET, &lmode);
-}
-
-void
-reset_sigio (fd)
- int fd;
-{
- if (noninteractive)
- return;
- lmode = ~LINTRUP & lmode;
- ioctl (fd, TIOCLSET, &lmode);
-}
-
-void
-request_sigio ()
-{
- if (noninteractive)
- return;
- sigrelse (SIGTINT);
-
- interrupts_deferred = 0;
-}
-
-void
-unrequest_sigio ()
-{
- if (noninteractive)
- return;
- sighold (SIGTINT);
-
- interrupts_deferred = 1;
-}
-
-/* still inside #ifdef BSD4_1 */
-#ifdef subprocesses
-
-int sigheld; /* Mask of held signals */
-
-void
-sigholdx (signum)
- int signum;
-{
- sigheld |= sigbit (signum);
- sighold (signum);
-}
-
-void
-sigisheld (signum)
- int signum;
-{
- sigheld |= sigbit (signum);
-}
-
-void
-sigunhold (signum)
- int signum;
-{
- sigheld &= ~sigbit (signum);
- sigrelse (signum);
-}
-
-void
-sigfree () /* Free all held signals */
-{
- int i;
- for (i = 0; i < NSIG; i++)
- if (sigheld & sigbit (i))
- sigrelse (i);
- sigheld = 0;
-}
-
-int
-sigbit (i)
-{
- return 1 << (i - 1);
-}
-#endif /* subprocesses */
-#endif /* BSD4_1 */
-\f
/* POSIX signals support - DJB */
/* Anyone with POSIX signals should have ANSI C declarations */
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
{
register int rtnval;
-#ifdef BSD4_1
- if (oflag & O_CREAT)
- return creat (path, mode);
-#endif
-
while ((rtnval = open (path, oflag, mode)) == -1
&& (errno == EINTR))
QUIT;
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;
be truncated if you hit C-g in the middle of it. --Stef */
if (interrupt_input_pending)
handle_async_input ();
+ if (pending_atimers)
+ do_pending_atimers ();
#endif
continue;
}
return read (fildes, buf, (nbyte < MAXIOSIZE ? nbyte : MAXIOSIZE));
}
-#if 0
-int
-sys_write (fildes, buf, nbyte)
- int fildes;
- char *buf;
- unsigned int nbyte;
-{
- register int nwrote, rtnval = 0;
-
- while (nbyte > MAXIOSIZE && (nwrote = write (fildes, buf, MAXIOSIZE)) > 0) {
- nbyte -= nwrote;
- buf += nwrote;
- rtnval += nwrote;
- }
- if (nwrote < 0)
- return rtnval ? rtnval : -1;
- if ((nwrote = write (fildes, buf, nbyte)) < 0)
- return rtnval ? rtnval : -1;
- return (rtnval + nwrote);
-}
-#endif /* 0 */
-
/*
* VAX/VMS VAX C RTL really loses. It insists that records
* end with a newline (carriage return) character, and if they
}
#endif /* VMS */
\f
-#ifdef AIXHFT
-
-/* Called from init_sys_modes. */
-void
-hft_init (struct tty_display_info *tty_out)
-{
- int junk;
-
- /* If we're not on an HFT we shouldn't do any of this. We determine
- if we are on an HFT by trying to get an HFT error code. If this
- call fails, we're not on an HFT. */
-#ifdef IBMR2AIX
- if (ioctl (0, HFQERROR, &junk) < 0)
- return;
-#else /* not IBMR2AIX */
- if (ioctl (0, HFQEIO, 0) < 0)
- return;
-#endif /* not IBMR2AIX */
-
- /* On AIX the default hft keyboard mapping uses backspace rather than delete
- as the rubout key's ASCII code. Here this is changed. The bug is that
- there's no way to determine the old mapping, so in reset_sys_modes
- we need to assume that the normal map had been present. Of course, this
- code also doesn't help if on a terminal emulator which doesn't understand
- HFT VTD's. */
- {
- struct hfbuf buf;
- struct hfkeymap keymap;
-
- buf.hf_bufp = (char *)&keymap;
- buf.hf_buflen = sizeof (keymap);
- keymap.hf_nkeys = 2;
- keymap.hfkey[0].hf_kpos = 15;
- keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE;
-#ifdef IBMR2AIX
- keymap.hfkey[0].hf_keyidh = '<';
-#else /* not IBMR2AIX */
- keymap.hfkey[0].hf_page = '<';
-#endif /* not IBMR2AIX */
- keymap.hfkey[0].hf_char = 127;
- keymap.hfkey[1].hf_kpos = 15;
- keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT;
-#ifdef IBMR2AIX
- keymap.hfkey[1].hf_keyidh = '<';
-#else /* not IBMR2AIX */
- keymap.hfkey[1].hf_page = '<';
-#endif /* not IBMR2AIX */
- keymap.hfkey[1].hf_char = 127;
- hftctl (0, HFSKBD, &buf);
- }
-}
-
-/* Reset the rubout key to backspace. */
-
-void
-hft_reset (struct tty_display_info *tty_out)
-{
- struct hfbuf buf;
- struct hfkeymap keymap;
- int junk;
-
-#ifdef IBMR2AIX
- if (ioctl (0, HFQERROR, &junk) < 0)
- return;
-#else /* not IBMR2AIX */
- if (ioctl (0, HFQEIO, 0) < 0)
- return;
-#endif /* not IBMR2AIX */
-
- buf.hf_bufp = (char *)&keymap;
- buf.hf_buflen = sizeof (keymap);
- keymap.hf_nkeys = 2;
- keymap.hfkey[0].hf_kpos = 15;
- keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE;
-#ifdef IBMR2AIX
- keymap.hfkey[0].hf_keyidh = '<';
-#else /* not IBMR2AIX */
- keymap.hfkey[0].hf_page = '<';
-#endif /* not IBMR2AIX */
- keymap.hfkey[0].hf_char = 8;
- keymap.hfkey[1].hf_kpos = 15;
- keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT;
-#ifdef IBMR2AIX
- keymap.hfkey[1].hf_keyidh = '<';
-#else /* not IBMR2AIX */
- keymap.hfkey[1].hf_page = '<';
-#endif /* not IBMR2AIX */
- keymap.hfkey[1].hf_char = 8;
- hftctl (0, HFSKBD, &buf);
-}
-
-#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
#ifndef bzero
return signame;
}
#endif /* HAVE_STRSIGNAL */
+\f
+#ifdef HAVE_TERMIOS
+/* For make-serial-process */
+int serial_open (char *port)
+{
+ int fd = -1;
+
+ fd = emacs_open ((char*) port,
+ O_RDWR
+#ifdef O_NONBLOCK
+ | O_NONBLOCK
+#else
+ | O_NDELAY
+#endif
+#ifdef O_NOCTTY
+ | O_NOCTTY
+#endif
+ , 0);
+ if (fd < 0)
+ {
+ error ("Could not open %s: %s",
+ port, emacs_strerror (errno));
+ }
+#ifdef TIOCEXCL
+ ioctl (fd, TIOCEXCL, (char *) 0);
+#endif
+
+ return fd;
+}
+#endif /* TERMIOS */
+
+#ifdef HAVE_TERMIOS
+
+#if !defined (HAVE_CFMAKERAW)
+/* Workaround for targets which are missing cfmakeraw. */
+/* Pasted from man page. */
+static void cfmakeraw (struct termios *termios_p)
+{
+ termios_p->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
+ termios_p->c_oflag &= ~OPOST;
+ termios_p->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
+ termios_p->c_cflag &= ~(CSIZE|PARENB);
+ termios_p->c_cflag |= CS8;
+}
+#endif /* !defined (HAVE_CFMAKERAW */
+
+#if !defined (HAVE_CFSETSPEED)
+/* Workaround for targets which are missing cfsetspeed. */
+static int cfsetspeed (struct termios *termios_p, speed_t vitesse)
+{
+ return (cfsetispeed (termios_p, vitesse)
+ + cfsetospeed (termios_p, vitesse));
+}
+#endif
+
+/* For serial-process-configure */
+void
+serial_configure (struct Lisp_Process *p,
+ Lisp_Object contact)
+{
+ Lisp_Object childp2 = Qnil;
+ Lisp_Object tem = Qnil;
+ struct termios attr;
+ int err = -1;
+ char summary[4] = "???"; /* This usually becomes "8N1". */
+
+ childp2 = Fcopy_sequence (p->childp);
+
+ /* Read port attributes and prepare default configuration. */
+ err = tcgetattr (p->outfd, &attr);
+ if (err != 0)
+ error ("tcgetattr() failed: %s", emacs_strerror (errno));
+ cfmakeraw (&attr);
+#if defined (CLOCAL)
+ attr.c_cflag |= CLOCAL;
+#endif
+#if defined (CREAD)
+ attr.c_cflag | CREAD;
+#endif
+
+ /* Configure speed. */
+ if (!NILP (Fplist_member (contact, QCspeed)))
+ tem = Fplist_get (contact, QCspeed);
+ else
+ tem = Fplist_get (p->childp, QCspeed);
+ CHECK_NUMBER (tem);
+ err = cfsetspeed (&attr, XINT (tem));
+ if (err != 0)
+ error ("cfsetspeed(%d) failed: %s", XINT (tem), emacs_strerror (errno));
+ childp2 = Fplist_put (childp2, QCspeed, tem);
+
+ /* Configure bytesize. */
+ if (!NILP (Fplist_member (contact, QCbytesize)))
+ tem = Fplist_get (contact, QCbytesize);
+ else
+ tem = Fplist_get (p->childp, QCbytesize);
+ if (NILP (tem))
+ tem = make_number (8);
+ CHECK_NUMBER (tem);
+ if (XINT (tem) != 7 && XINT (tem) != 8)
+ error (":bytesize must be nil (8), 7, or 8");
+ summary[0] = XINT(tem) + '0';
+#if defined (CSIZE) && defined (CS7) && defined (CS8)
+ attr.c_cflag &= ~CSIZE;
+ attr.c_cflag |= ((XINT (tem) == 7) ? CS7 : CS8);
+#else
+ /* Don't error on bytesize 8, which should be set by cfmakeraw. */
+ if (XINT (tem) != 8)
+ error ("Bytesize cannot be changed");
+#endif
+ childp2 = Fplist_put (childp2, QCbytesize, tem);
+
+ /* Configure parity. */
+ if (!NILP (Fplist_member (contact, QCparity)))
+ tem = Fplist_get (contact, QCparity);
+ else
+ tem = Fplist_get (p->childp, QCparity);
+ if (!NILP (tem) && !EQ (tem, Qeven) && !EQ (tem, Qodd))
+ error (":parity must be nil (no parity), `even', or `odd'");
+#if defined (PARENB) && defined (PARODD) && defined (IGNPAR) && defined (INPCK)
+ attr.c_cflag &= ~(PARENB | PARODD);
+ attr.c_iflag &= ~(IGNPAR | INPCK);
+ if (NILP (tem))
+ {
+ summary[1] = 'N';
+ }
+ else if (EQ (tem, Qeven))
+ {
+ summary[1] = 'E';
+ attr.c_cflag |= PARENB;
+ attr.c_iflag |= (IGNPAR | INPCK);
+ }
+ else if (EQ (tem, Qodd))
+ {
+ summary[1] = 'O';
+ attr.c_cflag |= (PARENB | PARODD);
+ attr.c_iflag |= (IGNPAR | INPCK);
+ }
+#else
+ /* Don't error on no parity, which should be set by cfmakeraw. */
+ if (!NILP (tem))
+ error ("Parity cannot be configured");
+#endif
+ childp2 = Fplist_put (childp2, QCparity, tem);
+
+ /* Configure stopbits. */
+ if (!NILP (Fplist_member (contact, QCstopbits)))
+ tem = Fplist_get (contact, QCstopbits);
+ else
+ tem = Fplist_get (p->childp, QCstopbits);
+ if (NILP (tem))
+ tem = make_number (1);
+ CHECK_NUMBER (tem);
+ if (XINT (tem) != 1 && XINT (tem) != 2)
+ error (":stopbits must be nil (1 stopbit), 1, or 2");
+ summary[2] = XINT (tem) + '0';
+#if defined (CSTOPB)
+ attr.c_cflag &= ~CSTOPB;
+ if (XINT (tem) == 2)
+ attr.c_cflag |= CSTOPB;
+#else
+ /* Don't error on 1 stopbit, which should be set by cfmakeraw. */
+ if (XINT (tem) != 1)
+ error ("Stopbits cannot be configured");
+#endif
+ childp2 = Fplist_put (childp2, QCstopbits, tem);
+
+ /* Configure flowcontrol. */
+ if (!NILP (Fplist_member (contact, QCflowcontrol)))
+ tem = Fplist_get (contact, QCflowcontrol);
+ else
+ tem = Fplist_get (p->childp, QCflowcontrol);
+ if (!NILP (tem) && !EQ (tem, Qhw) && !EQ (tem, Qsw))
+ error (":flowcontrol must be nil (no flowcontrol), `hw', or `sw'");
+#if defined (CRTSCTS)
+ attr.c_cflag &= ~CRTSCTS;
+#endif
+#if defined (CNEW_RTSCTS)
+ attr.c_cflag &= ~CNEW_RTSCTS;
+#endif
+#if defined (IXON) && defined (IXOFF)
+ attr.c_iflag &= ~(IXON | IXOFF);
+#endif
+ if (NILP (tem))
+ {
+ /* Already configured. */
+ }
+ else if (EQ (tem, Qhw))
+ {
+#if defined (CRTSCTS)
+ attr.c_cflag |= CRTSCTS;
+#elif defined (CNEW_RTSCTS)
+ attr.c_cflag |= CNEW_RTSCTS;
+#else
+ error ("Hardware flowcontrol (RTS/CTS) not supported");
+#endif
+ }
+ else if (EQ (tem, Qsw))
+ {
+#if defined (IXON) && defined (IXOFF)
+ attr.c_iflag |= (IXON | IXOFF);
+#else
+ error ("Software flowcontrol (XON/XOFF) not supported");
+#endif
+ }
+ childp2 = Fplist_put (childp2, QCflowcontrol, tem);
+
+ /* Activate configuration. */
+ err = tcsetattr (p->outfd, TCSANOW, &attr);
+ if (err != 0)
+ error ("tcsetattr() failed: %s", emacs_strerror (errno));
+
+ childp2 = Fplist_put (childp2, QCsummary, build_string (summary));
+ p->childp = childp2;
+
+}
+#endif /* TERMIOS */
/* arch-tag: edb43589-4e09-4544-b325-978b5b121dcf
(do not change this comment) */