From 460e417caa50ecb7906b2cd3419c2a3c4588dd2e Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 17 Feb 2004 13:53:36 +0000 Subject: 19429: configure test for ptmx --- ChangeLog | 3 +++ Src/Modules/zpty.c | 20 +++++++++++--------- configure.ac | 24 ++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3ba4a9458..1b372ee59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2004-02-17 Peter Stephenson + * 19428: configure.ac, Src/Modules/pty.c: use configure to + test if we can create pty pairs using /dev/ptmx. + * 19428: configure.ac: fix test for #include'ing STREAMS headers. diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index 7d33bd064..e1f75c30a 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -154,12 +154,10 @@ getptycmd(char *name) return NULL; } -/**** maybe we should use configure here */ -/**** and we certainly need more/better #if tests */ +#if defined(HAVE_DEV_PTMX) && defined(HAVE_GRANTPT) && \ + defined(HAVE_PTSNAME) && defined(HAVE_UNLOCKPT) -#if defined(__SVR4) || defined(sinix) || defined(__CYGWIN__) - -#if !defined(__CYGWIN__) +#ifdef HAVE_SYS_STROPTS_H #include #endif @@ -192,7 +190,11 @@ get_pty(int master, int *retfd) close(mfd); return 1; } -#if !defined(__CYGWIN__) +#if defined(I_FIND) && defined(I_PUSH) + /* + * Use if STREAMS is available. The test is probably OK, + * but we could use e.g. the sys/stropts.h test. + */ if ((ret = ioctl(sfd, I_FIND, "ptem")) != 1) if (ret == -1 || ioctl(sfd, I_PUSH, "ptem") == -1) { close(mfd); @@ -211,14 +213,14 @@ get_pty(int master, int *retfd) close(sfd); return 1; } -#endif /* !defined(__CYGWIN__) */ +#endif *retfd = sfd; return 0; } -#else /* ! (defined(__SVR4) || defined(sinix) || defined(__CYGWIN__)) */ +#else /* No /dev/ptmx or no pt functions */ static int get_pty(int master, int *retfd) @@ -267,7 +269,7 @@ get_pty(int master, int *retfd) return 1; } -#endif /* __SVR4 */ +#endif /* /dev/ptmx or alternatives */ static int newptycmd(char *nam, char *pname, char **args, int echo, int nblock) diff --git a/configure.ac b/configure.ac index 76fdab2a2..8dac87afd 100644 --- a/configure.ac +++ b/configure.ac @@ -505,7 +505,8 @@ AC_CHECK_HEADERS(sys/time.h sys/times.h sys/select.h termcap.h termio.h \ limits.h fcntl.h libc.h sys/utsname.h sys/resource.h \ locale.h errno.h stdio.h stdlib.h unistd.h sys/capability.h \ utmp.h utmpx.h sys/types.h pwd.h grp.h poll.h sys/mman.h \ - netinet/in_systm.h pcre.h langinfo.h wchar.h stddef.h) + netinet/in_systm.h pcre.h langinfo.h wchar.h stddef.h \ + sys/stropts.h) if test $dynamic = yes; then AC_CHECK_HEADERS(dlfcn.h) AC_CHECK_HEADERS(dl.h) @@ -1029,7 +1030,8 @@ AC_CHECK_FUNCS(strftime difftime gettimeofday \ pcre_compile pcre_study pcre_exec \ nl_langinfo \ erand48 open_memstream \ - wctomb iconv) + wctomb iconv \ + grantpt unlockpt ptsname) AC_FUNC_STRCOLL dnl Check if tgetent accepts NULL (and will allocate its own termcap buffer) @@ -1795,6 +1797,24 @@ dnl --------------- zsh_CHECK_SOCKLEN_T +dnl --------------- +dnl Check for pty multiplexer for use in pty module. +dnl We need to open it read/write, so make sure it is writeable. +dnl Yet another test which won't work when cross-compiling. +dnl --------------- +AH_TEMPLATE([HAVE_DEV_PTMX], +[Define to 1 if your system can use /dev/ptmx for creating ptys.]) +AC_CACHE_CHECK(if your system has /dev/ptmx, +ac_cv_have_dev_ptmx, +[if test -w /dev/ptmx; then + ac_cv_have_dev_ptmx=yes +else + ac_cv_have_dev_ptmx=no +fi]) +if test $ac_cv_have_dev_ptmx = yes; then + AC_DEFINE(HAVE_DEV_PTMX) +fi + dnl --------------- dnl dynamic loading dnl --------------- -- cgit 1.4.1