bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

openpty, forkpty: fix build error on Solaris 11.4


From: Bruno Haible
Subject: openpty, forkpty: fix build error on Solaris 11.4
Date: Thu, 28 Nov 2019 00:35:20 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; )

On Solaris 11.4, I'm seeing compilation errors such as these:

In file included from /usr/include/sys/time.h:447:0,
                 from ./sys/time.h:39,
                 from /usr/include/sys/termios.h:15,
                 from /usr/include/termios.h:8,
                 from ./termios.h:38,
                 from ./pty.h:44,
                 from ../../gllib/forkpty.c:20:
./pty.h:526:1: error: conflicting types for 'forkpty'
 _GL_FUNCDECL_SYS (forkpty, int,
 ^
In file included from /usr/include/termios.h:8:0,
                 from ./termios.h:38,
                 from ./pty.h:44,
                 from ../../gllib/forkpty.c:20:
/usr/include/sys/termios.h:540:14: note: previous declaration of 'forkpty' was 
here
 extern pid_t forkpty(int *, char *, struct termios *, struct winsize *);
              ^~~~~~~
In file included from /usr/include/sys/time.h:447:0,
                 from ./sys/time.h:39,
                 from /usr/include/sys/termios.h:15,
                 from /usr/include/termios.h:8,
                 from ./termios.h:38,
                 from ./pty.h:44,
                 from ../../gllib/forkpty.c:20:
./pty.h:560:1: error: conflicting types for 'openpty'
 _GL_FUNCDECL_SYS (openpty, int,
 ^
In file included from /usr/include/termios.h:8:0,
                 from ./termios.h:38,
                 from ./pty.h:44,
                 from ../../gllib/forkpty.c:20:
/usr/include/sys/termios.h:538:12: note: previous declaration of 'openpty' was 
here
 extern int openpty(int *, int *, char *, struct termios *, struct winsize *);
            ^~~~~~~


The cause is that Solaris has put the declarations of openpty and forkpty in
a header file where no other platform has them, namely in <termios.h>.
This patch fixes it.


2019-11-27  Bruno Haible  <address@hidden>

        openpty, forkpty: Fix build error on Solaris 11.4.
        * m4/pty_h.m4 (gl_PTY_H): Test for termios.h. Look for the declarations
        also in <termios.h>.
        * m4/pty.m4 (gl_FUNC_FORKPTY, gl_FUNC_OPENPTY): Look for the declaration
        of the function also in <termios.h>.
        * doc/glibc-functions/openpty.texi: Mention the Solaris 11.4 problems.
        * doc/glibc-functions/forkpty.texi: Likewise.

diff --git a/doc/glibc-functions/forkpty.texi b/doc/glibc-functions/forkpty.texi
index 937005f..c4cf82c 100644
--- a/doc/glibc-functions/forkpty.texi
+++ b/doc/glibc-functions/forkpty.texi
@@ -29,13 +29,14 @@ and Mac OS X) linking with @code{-lutil} is not required.
 On glibc, OpenBSD, NetBSD and FreeBSD linking with @code{-lutil} is
 required.
 @item
-The function is declared in pty.h on Cygwin
-and glibc.  It is declared in util.h on Mac OS X, OpenBSD and NetBSD.
+The function is declared in pty.h on glibc and Cygwin.
+It is declared in util.h on Mac OS X, OpenBSD, and NetBSD.
 It is declared in libutil.h on FreeBSD.
+It is declared in termios.h on Solaris.
 @item
 Some platforms declare the function without marking the last two
 parameters @code{const}.
-FreeBSD, Cygwin 1.7.1.
+FreeBSD, Solaris 11.4, Cygwin 1.7.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/doc/glibc-functions/openpty.texi b/doc/glibc-functions/openpty.texi
index d5f4cf9..33f6b74 100644
--- a/doc/glibc-functions/openpty.texi
+++ b/doc/glibc-functions/openpty.texi
@@ -29,13 +29,14 @@ and Mac OS X) linking with @code{-lutil} is not required.
 On glibc, OpenBSD, NetBSD and FreeBSD linking with @code{-lutil} is
 required.
 @item
-The function is declared in pty.h on Cygwin
-and glibc.  It is declared in util.h on Mac OS X, OpenBSD and NetBSD.
+The function is declared in pty.h on glibc and Cygwin.
+It is declared in util.h on Mac OS X, OpenBSD, and NetBSD.
 It is declared in libutil.h on FreeBSD.
+It is declared in termios.h on Solaris.
 @item
 Some platforms declare the function without marking the last two
 parameters @code{const}.
-FreeBSD, Cygwin 1.7.1.
+FreeBSD, Solaris 11.4, Cygwin 1.7.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/m4/pty.m4 b/m4/pty.m4
index 9e60873..51ad647 100644
--- a/m4/pty.m4
+++ b/m4/pty.m4
@@ -1,4 +1,4 @@
-# pty.m4 serial 13
+# pty.m4 serial 14
 dnl Copyright (C) 2010-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -39,6 +39,9 @@ AC_DEFUN([gl_FUNC_FORKPTY],
 #if HAVE_LIBUTIL_H
 # include <libutil.h>
 #endif
+#if HAVE_TERMIOS_H
+# include <termios.h>
+#endif
 ]])
   if test $ac_cv_have_decl_forkpty = yes; then
     dnl The system has forkpty.
@@ -58,6 +61,9 @@ AC_DEFUN([gl_FUNC_FORKPTY],
 #if HAVE_LIBUTIL_H
 # include <libutil.h>
 #endif
+#if HAVE_TERMIOS_H
+# include <termios.h>
+#endif
           ]], [[
             int forkpty (int *, char *, struct termios const *,
                          struct winsize const *);
@@ -98,6 +104,9 @@ AC_DEFUN([gl_FUNC_OPENPTY],
 #if HAVE_LIBUTIL_H
 # include <libutil.h>
 #endif
+#if HAVE_TERMIOS_H
+# include <termios.h>
+#endif
 ]])
   if test $ac_cv_have_decl_openpty = yes; then
     AC_DEFINE([HAVE_OPENPTY], [1],
@@ -119,6 +128,9 @@ AC_DEFUN([gl_FUNC_OPENPTY],
 #if HAVE_LIBUTIL_H
 # include <libutil.h>
 #endif
+#if HAVE_TERMIOS_H
+# include <termios.h>
+#endif
           ]], [[
             int openpty (int *, int *, char *, struct termios const *,
                        struct winsize const *);
diff --git a/m4/pty_h.m4 b/m4/pty_h.m4
index d797f23..5fb4ddb 100644
--- a/m4/pty_h.m4
+++ b/m4/pty_h.m4
@@ -1,4 +1,4 @@
-# pty_h.m4 serial 10
+# pty_h.m4 serial 11
 dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -22,6 +22,7 @@ AC_DEFUN_ONCE([gl_PTY_H],
     if test $ac_cv_header_libutil_h = yes; then
       HAVE_LIBUTIL_H=1
     fi
+    AC_CHECK_HEADERS_ONCE([termios.h])
   else # Have <pty.h>, assume forkpty is declared there.
     HAVE_PTY_H=1
   fi
@@ -43,6 +44,9 @@ AC_DEFUN_ONCE([gl_PTY_H],
 #if HAVE_LIBUTIL_H
 # include <libutil.h>
 #endif
+#if HAVE_TERMIOS_H
+# include <termios.h>
+#endif
     ]], [forkpty openpty])
 ])
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]