From 0ab7b23ae0a12669fef7f5939fbb0161f29280a2 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Thu, 12 Jul 2012 00:10:44 -0700 Subject: [PATCH] Move PTY_OPEN from src/s to configure * configure.ac (PTY_OPEN) Move here from src/s. * src/s/cygwin.h, src/s/darwin.h, src/s/gnu-linux.h, src/s/irix6-5.h: Move PTY_OPEN to configure. --- ChangeLog | 2 +- configure.ac | 12 ++++++++++++ src/ChangeLog | 3 +++ src/s/cygwin.h | 13 ------------- src/s/darwin.h | 13 ------------- src/s/gnu-linux.h | 1 - src/s/irix6-5.h | 20 -------------------- 7 files changed, 16 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index cd5300ff235..4fbc8457a18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,7 +6,7 @@ * configure.ac (NARROWPROTO, NO_ABORT, BROKEN_GET_CURRENT_DIR_NAME) (BROKEN_FIONREAD, BROKEN_PTY_READ_AFTER_EAGAIN, BROKEN_SIGAIO) (BROKEN_SIGPOLL, BROKEN_SIGPTY, FIRST_PTY_LETTER) - (G_SLICE_ALWAYS_MALLOC, PREFER_VSUSP, PTY_ITERATION) + (G_SLICE_ALWAYS_MALLOC, PREFER_VSUSP, PTY_ITERATION, PTY_OPEN) (RUN_TIME_REMAP, SETPGRP_RELEASES_CTTY, TAB3, TABDLY, RUN_TIME_REMAP (XOS_NEEDS_TIME_H): Move here from src/s. diff --git a/configure.ac b/configure.ac index 77fe10c0e54..c9a97d9f282 100644 --- a/configure.ac +++ b/configure.ac @@ -3298,6 +3298,7 @@ dnl Only used if !PTY_ITERATION. Iterate from FIRST_PTY_LETTER to z, dnl trying suffixes 0-16. AH_TEMPLATE(FIRST_PTY_LETTER, [Letter to use in finding device name of first PTY, if PTYs are supported.]) +AH_TEMPLATE(PTY_OPEN, [How to open a PTY, if non-standard.]) case $opsys in aix4-2 ) @@ -3306,12 +3307,18 @@ case $opsys in cygwin ) AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)] ) + dnl multi-line AC_DEFINEs are hard. :( + AC_DEFINE(PTY_OPEN, [ do { int dummy; SIGMASKTYPE mask; mask = sigblock (sigmask (SIGCHLD)); if (-1 == openpty (&fd, &dummy, pty_name, 0, 0)) fd = -1; sigsetmask (mask); if (fd >= 0) emacs_close (dummy); } while (0)] ) ;; darwin ) AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)] ) dnl Not used, because PTY_ITERATION is defined. AC_DEFINE(FIRST_PTY_LETTER, ['p']) + dnl Note that openpty may fork via grantpt on Mac OS X 10.4/Darwin 8. + dnl But we don't have to block SIGCHLD because it is blocked in the + dnl implementation of grantpt. + AC_DEFINE(PTY_OPEN, [ do { int slave; if (openpty (&fd, &slave, pty_name, NULL, NULL) == -1) fd = -1; else emacs_close (slave); } while (0)] ) ;; gnu | hpux* | freebsd | netbsd | openbsd ) @@ -3322,6 +3329,10 @@ case $opsys in dnl if HAVE_GRANTPT if test "x$ac_cv_func_grantpt" = xyes; then AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)] ) + dnl if HAVE_GETPT + if test "x$ac_cv_func_getpt" = xyes; then + AC_DEFINE(PTY_OPEN, [fd = getpt ()]) + fi else AC_DEFINE(FIRST_PTY_LETTER, ['p']) fi @@ -3341,6 +3352,7 @@ case $opsys in AC_DEFINE(PTY_ITERATION, []) dnl Not used, because PTY_ITERATION is defined. AC_DEFINE(FIRST_PTY_LETTER, ['q']) + AC_DEFINE(PTY_OPEN, [ { struct sigaction ocstat, cstat; struct stat stb; char * name; sigemptyset(&cstat.sa_mask); cstat.sa_handler = SIG_DFL; cstat.sa_flags = 0; sigaction(SIGCLD, &cstat, &ocstat); name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); sigaction(SIGCLD, &ocstat, (struct sigaction *)0); if (name == 0) return -1; if (fd < 0) return -1; if (fstat (fd, &stb) < 0) return -1; strcpy (pty_name, name); }] ) ;; sol2* | unixware ) diff --git a/src/ChangeLog b/src/ChangeLog index 19b89259067..8ba63959ba4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2012-07-12 Glenn Morris + * s/cygwin.h, s/darwin.h, s/gnu-linux.h, s/irix6-5.h: + Move PTY_OPEN to configure. + * s/aix4-2.h, s/bsd-common.h, s/cygwin.h, s/darwin.h: * s/gnu-linux.h, s/hpux10-20.h, s/irix6-5.h, s/template.h: * s/usg5-4-common.h: Move FIRST_PTY_LETTER, PTY_ITERATION to configure. diff --git a/src/s/cygwin.h b/src/s/cygwin.h index 89db0a047bc..79a8999b034 100644 --- a/src/s/cygwin.h +++ b/src/s/cygwin.h @@ -19,19 +19,6 @@ along with GNU Emacs. If not, see . */ #define PTY_NAME_SPRINTF /* none */ #define PTY_TTY_NAME_SPRINTF /* none */ -#define PTY_OPEN \ - do \ - { \ - int dummy; \ - SIGMASKTYPE mask; \ - mask = sigblock (sigmask (SIGCHLD)); \ - if (-1 == openpty (&fd, &dummy, pty_name, 0, 0)) \ - fd = -1; \ - sigsetmask (mask); \ - if (fd >= 0) \ - emacs_close (dummy); \ - } \ - while (0) /* Used in various places to enable cygwin-specific code changes. */ #define CYGWIN 1 diff --git a/src/s/darwin.h b/src/s/darwin.h index 68667ed7c90..569b24e3a6e 100644 --- a/src/s/darwin.h +++ b/src/s/darwin.h @@ -32,19 +32,6 @@ along with GNU Emacs. If not, see . */ #define PTY_NAME_SPRINTF /* none */ #define PTY_TTY_NAME_SPRINTF /* none */ -/* Note that openpty may fork via grantpt on Mac OS X 10.4/Darwin 8. - But we don't have to block SIGCHLD because it is blocked in the - implementation of grantpt. */ -#define PTY_OPEN \ - do \ - { \ - int slave; \ - if (openpty (&fd, &slave, pty_name, NULL, NULL) == -1) \ - fd = -1; \ - else \ - emacs_close (slave); \ - } \ - while (0) /* PTYs only work correctly on Darwin 7 or higher. So make the default for process-connection-type dependent on the kernel version. */ diff --git a/src/s/gnu-linux.h b/src/s/gnu-linux.h index dd4de41f84b..20a2354a2ab 100644 --- a/src/s/gnu-linux.h +++ b/src/s/gnu-linux.h @@ -30,7 +30,6 @@ along with GNU Emacs. If not, see . */ #ifdef HAVE_GETPT #define PTY_NAME_SPRINTF -#define PTY_OPEN fd = getpt () #else /* not HAVE_GETPT */ #define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx"); #endif /* not HAVE_GETPT */ diff --git a/src/s/irix6-5.h b/src/s/irix6-5.h index cd7b2902026..b053634d17c 100644 --- a/src/s/irix6-5.h +++ b/src/s/irix6-5.h @@ -34,26 +34,6 @@ along with GNU Emacs. If not, see . */ #ifdef emacs char *_getpty(); #endif -/* Here is how to do it. */ -#define PTY_OPEN \ -{ \ - struct sigaction ocstat, cstat; \ - struct stat stb; \ - char * name; \ - sigemptyset(&cstat.sa_mask); \ - cstat.sa_handler = SIG_DFL; \ - cstat.sa_flags = 0; \ - sigaction(SIGCLD, &cstat, &ocstat); \ - name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); \ - sigaction(SIGCLD, &ocstat, (struct sigaction *)0); \ - if (name == 0) \ - return -1; \ - if (fd < 0) \ - return -1; \ - if (fstat (fd, &stb) < 0) \ - return -1; \ - strcpy (pty_name, name); \ -} /* Ulimit(UL_GMEMLIM) is busted... */ #define ULIMIT_BREAK_VALUE 0x14000000 -- 2.39.2