Commit 3f922c37 authored by Glenn Morris's avatar Glenn Morris

Move PTY_NAME_SPRINTF, PTY_TTY_NAME_SPRINTF from src/s to configure

* configure.ac (PTY_NAME_SPRINTF, PTY_TTY_NAME_SPRINTF): Move here from src/s.

* src/s/aix4-2.h, src/s/cygwin.h, src/s/darwin.h:
* src/s/gnu-linux.h, src/s/hpux10-20.h, src/s/irix6-5.h:
* src/s/sol2-6.h, src/s/unixware.h, src/s/usg5-4-common.h:
Move PTY_NAME_SPRINTF, PTY_TTY_NAME_SPRINTF to configure.
parent 0ab7b23a
......@@ -7,7 +7,8 @@
(BROKEN_FIONREAD, BROKEN_PTY_READ_AFTER_EAGAIN, BROKEN_SIGAIO)
(BROKEN_SIGPOLL, BROKEN_SIGPTY, FIRST_PTY_LETTER)
(G_SLICE_ALWAYS_MALLOC, PREFER_VSUSP, PTY_ITERATION, PTY_OPEN)
(RUN_TIME_REMAP, SETPGRP_RELEASES_CTTY, TAB3, TABDLY, RUN_TIME_REMAP
(PTY_NAME_SPRINTF, PTY_TTY_NAME_SPRINTF, RUN_TIME_REMAP)
(SETPGRP_RELEASES_CTTY, TAB3, TABDLY, RUN_TIME_REMAP)
(XOS_NEEDS_TIME_H): Move here from src/s.
2012-07-11 Glenn Morris <rgm@gnu.org>
......
......@@ -3299,16 +3299,26 @@ 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.])
AH_TEMPLATE(PTY_NAME_SPRINTF, [How to get the device name of the control
end of a PTY, if non-standard.])
AH_TEMPLATE(PTY_TTY_NAME_SPRINTF, [How to get device name of the tty
end of a PTY, if non-standard.])
case $opsys in
aix4-2 )
AC_DEFINE(PTY_ITERATION, [int c; for (c = 0; !c ; c++)] )
dnl You allocate a pty by opening /dev/ptc to get the master side.
dnl To get the name of the slave side, you just ttyname() the master side.
AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptc");] )
AC_DEFINE(PTY_TTY_NAME_SPRINTF, [strcpy (pty_name, ttyname (fd));] )
;;
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)] )
AC_DEFINE(PTY_NAME_SPRINTF, [] )
AC_DEFINE(PTY_TTY_NAME_SPRINTF, [] )
;;
darwin )
......@@ -3319,9 +3329,11 @@ case $opsys in
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)] )
AC_DEFINE(PTY_NAME_SPRINTF, [] )
AC_DEFINE(PTY_TTY_NAME_SPRINTF, [] )
;;
gnu | hpux* | freebsd | netbsd | openbsd )
gnu | freebsd | netbsd | openbsd )
AC_DEFINE(FIRST_PTY_LETTER, ['p'])
;;
......@@ -3329,15 +3341,27 @@ 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 Note that grantpt and unlockpt may fork. We must block SIGCHLD
dnl to prevent sigchld_handler from intercepting the child's death.
AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptyname; sigblock (sigmask (SIGCHLD)); if (grantpt (fd) == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname(fd))) { sigunblock (sigmask (SIGCHLD)); close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); sigunblock (sigmask (SIGCHLD)); }] )
dnl if HAVE_GETPT
if test "x$ac_cv_func_getpt" = xyes; then
AC_DEFINE(PTY_OPEN, [fd = getpt ()])
AC_DEFINE(PTY_NAME_SPRINTF, [] )
else
AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");] )
fi
else
AC_DEFINE(FIRST_PTY_LETTER, ['p'])
fi
;;
hpux*)
AC_DEFINE(FIRST_PTY_LETTER, ['p'])
AC_DEFINE(PTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/ptym/pty%c%x", c, i);] )
AC_DEFINE(PTY_TTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/pty/tty%c%x", c, i);] )
;;
irix6-5 )
dnl It looks like this cannot be right, because it is not a loop.
dnl However, process.c actually does this:
......@@ -3353,12 +3377,31 @@ case $opsys in
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); }] )
dnl No need to get the pty name at all.
AC_DEFINE(PTY_NAME_SPRINTF, [] )
dnl No need to use sprintf to get the tty name--we get that from _getpty.
AC_DEFINE(PTY_TTY_NAME_SPRINTF, [] )
;;
sol2* | unixware )
sol2* )
dnl This change means that we don't loop through allocate_pty too
dnl many times in the (rare) event of a failure.
AC_DEFINE(FIRST_PTY_LETTER, ['z'])
AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");] )
dnl Uses sigblock/sigunblock rather than sighold/sigrelse,
dnl which appear to be BSD4.1 specific. It may also be appropriate
dnl for SVR4.x (x<2) but I'm not sure. fnf@cygnus.com
dnl On SysVr4, grantpt(3) forks a subprocess, so keep sigchld_handler()
dnl from intercepting that death. If any child but grantpt's should die
dnl within, it should be caught after sigrelse(2).
AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; sigblock (sigmask (SIGCLD)); if (grantpt (fd) == -1) { emacs_close (fd); return -1; } sigunblock (sigmask (SIGCLD)); if (unlockpt (fd) == -1) { emacs_close (fd); return -1; } if (!(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }] )
;;
dnl Comments are as per sol2*.
unixware )
AC_DEFINE(FIRST_PTY_LETTER, ['z'])
AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");] )
AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; sigblock(sigmask(SIGCLD)); if (grantpt(fd) == -1) fatal("could not grant slave pty"); sigunblock(sigmask(SIGCLD)); if (unlockpt(fd) == -1) fatal("could not unlock slave pty"); if (!(ptyname = ptsname(fd))) fatal ("could not enable slave pty"); snprintf (pty_name, sizeof pty_name, "%s", ptyname); }] )
;;
esac
......
2012-07-12 Glenn Morris <rgm@gnu.org>
* src/s/aix4-2.h, src/s/cygwin.h, src/s/darwin.h:
* src/s/gnu-linux.h, src/s/hpux10-20.h, src/s/irix6-5.h:
* src/s/sol2-6.h, src/s/unixware.h, src/s/usg5-4-common.h:
Move PTY_NAME_SPRINTF, PTY_TTY_NAME_SPRINTF to configure.
* s/cygwin.h, s/darwin.h, s/gnu-linux.h, s/irix6-5.h:
Move PTY_OPEN to configure.
......
......@@ -26,11 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define _AIX
#endif
/* In AIX, you allocate a pty by opening /dev/ptc to get the master side.
To get the name of the slave side, you just ttyname() the master side. */
#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptc");
#define PTY_TTY_NAME_SPRINTF strcpy (pty_name, ttyname (fd));
/* Special items needed to make Emacs run on this system. */
......
......@@ -17,8 +17,5 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define PTY_NAME_SPRINTF /* none */
#define PTY_TTY_NAME_SPRINTF /* none */
/* Used in various places to enable cygwin-specific code changes. */
#define CYGWIN 1
......@@ -30,9 +30,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
distinguish OS X from pure Darwin. */
#define DARWIN_OS
#define PTY_NAME_SPRINTF /* none */
#define PTY_TTY_NAME_SPRINTF /* none */
/* PTYs only work correctly on Darwin 7 or higher. So make the default
for process-connection-type dependent on the kernel version. */
#define MIN_PTY_KERNEL_VERSION '7'
......
......@@ -27,31 +27,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#if defined HAVE_GRANTPT
#define UNIX98_PTYS
#ifdef HAVE_GETPT
#define PTY_NAME_SPRINTF
#else /* not HAVE_GETPT */
#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx");
#endif /* not HAVE_GETPT */
/* Note that grantpt and unlockpt may fork. We must block SIGCHLD to
prevent sigchld_handler from intercepting the child's death. */
#define PTY_TTY_NAME_SPRINTF \
{ \
char *ptyname; \
\
sigblock (sigmask (SIGCHLD)); \
if (grantpt (fd) == -1 || unlockpt (fd) == -1 \
|| !(ptyname = ptsname(fd))) \
{ \
sigunblock (sigmask (SIGCHLD)); \
close (fd); \
return -1; \
} \
snprintf (pty_name, sizeof pty_name, "%s", ptyname); \
sigunblock (sigmask (SIGCHLD)); \
}
#endif /* HAVE_GRANTPT */
/* Here, on a separate page, add any special hacks needed
......
......@@ -26,14 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Special hacks needed to make Emacs run on this system. */
/* This is how to get the device name of the tty end of a pty. */
#define PTY_TTY_NAME_SPRINTF \
sprintf (pty_name, "/dev/pty/tty%c%x", c, i);
/* This is how to get the device name of the control end of a pty. */
#define PTY_NAME_SPRINTF \
sprintf (pty_name, "/dev/ptym/pty%c%x", c, i);
/* Assar Westerlund <assar@sics.se> says this is necessary for
HP-UX 10.20, and that it works for HP-UX 0 as well. */
#define NO_EDITRES
......
......@@ -26,11 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#undef SETUP_SLAVE_PTY
/* No need to use sprintf to get the tty name--we get that from _getpty. */
#define PTY_TTY_NAME_SPRINTF
/* No need to get the pty name at all. */
#undef PTY_NAME_SPRINTF
#define PTY_NAME_SPRINTF
#ifdef emacs
char *_getpty();
#endif
......
......@@ -21,28 +21,4 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define SOLARIS2
/* This is the same definition as in usg5-4-common.h, but with sigblock/sigunblock
rather than sighold/sigrelse, which appear to be BSD4.1 specific.
It may also be appropriate for SVR4.x
(x<2) but I'm not sure. fnf@cygnus.com */
/* This sets the name of the slave side of the PTY. On SysVr4,
grantpt(3) forks a subprocess, so keep sigchld_handler() from
intercepting that death. If any child but grantpt's should die
within, it should be caught after sigrelse(2). */
#define PTY_TTY_NAME_SPRINTF \
{ \
char *ptsname (int), *ptyname; \
\
sigblock (sigmask (SIGCLD)); \
if (grantpt (fd) == -1) \
{ emacs_close (fd); return -1; } \
sigunblock (sigmask (SIGCLD)); \
if (unlockpt (fd) == -1) \
{ emacs_close (fd); return -1; } \
if (!(ptyname = ptsname (fd))) \
{ emacs_close (fd); return -1; } \
snprintf (pty_name, sizeof pty_name, "%s", ptyname); \
}
#define GC_SETJMP_WORKS 1
......@@ -20,29 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "usg5-4-common.h"
/* This is the same definition as in usg5-4-common.h, but with sigblock/sigunblock
rather than sighold/sigrelse, which appear to be BSD4.1 specific.
It may also be appropriate for SVR4.x
(x<2) but I'm not sure. fnf@cygnus.com */
/* This sets the name of the slave side of the PTY. On SysVr4,
grantpt(3) forks a subprocess, so keep sigchld_handler() from
intercepting that death. If any child but grantpt's should die
within, it should be caught after sigrelse(2). */
#define PTY_TTY_NAME_SPRINTF \
{ \
char *ptsname (int), *ptyname; \
\
sigblock(sigmask(SIGCLD)); \
if (grantpt(fd) == -1) \
fatal("could not grant slave pty"); \
sigunblock(sigmask(SIGCLD)); \
if (unlockpt(fd) == -1) \
fatal("could not unlock slave pty"); \
if (!(ptyname = ptsname(fd))) \
fatal ("could not enable slave pty"); \
snprintf (pty_name, sizeof pty_name, "%s", ptyname); \
}
/* Conservative garbage collection has not been tested, so for now
play it safe and stick with the old-fashioned way of marking. */
#define GC_MARK_STACK GC_USE_GCPROS_AS_BEFORE
......@@ -64,9 +64,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
this is all we need. */
#define TIOCSIGSEND TIOCSIGNAL
/* This sets the name of the master side of the PTY. */
#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx");
/* Push various streams modules onto a PTY channel. */
#define SETUP_SLAVE_PTY \
if (ioctl (xforkin, I_PUSH, "ptem") == -1) \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment