]> Savannah Git Hosting - gnulib.git/commitdiff
openpty: provide a stub on mingw
authorEric Blake <eblake@redhat.com>
Wed, 9 Nov 2011 18:47:22 +0000 (11:47 -0700)
committerEric Blake <eblake@redhat.com>
Wed, 9 Nov 2011 18:47:22 +0000 (11:47 -0700)
On mingw, the compiler complained that 'struct termios' and
'struct winsize' were declared in the function prototype, then
failed to compile due to missing TCSAFLUSH.  Since we can't
emulate ptys on mingw, it's better to just make this module
be a stub that compiles but gracefully fails.

This patch assumes that the only portable way to use openpty()
is with the fourth and fifth arguments being NULL ('struct termios'
cannot be portably initialized in a standard-compliant manner
except by open(O_TTY_INIT)/tcgetattr(), and 'struct winsize' is
not standardized); for now, applications that want to alter termios
settings still have the burden of conditional compilation to avoid
the missing tcgetattr() on mingw.

* lib/pty.in.h (includes): Provide forward declarations.
* lib/openpty.c (openpty) [mingw]: Provide ENOSYS stub.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
lib/openpty.c
lib/pty.in.h

index 8b5a1ad9482f64e9e5890a2d7c6b58f928d19255..f51cc258d958643dbb57a6030fae3bd1fe48ae48 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2011-11-09  Eric Blake  <eblake@redhat.com>
 
+       openpty: provide a stub on mingw
+       * lib/pty.in.h (includes): Provide forward declarations.
+       * lib/openpty.c (openpty) [mingw]: Provide ENOSYS stub.
+
        raise: fix mingw handling of SIGPIPE
        * lib/sigprocmask.c (_gl_raise_SIGPIPE): Provide a return value.
 
index c398db5e69d0d1928fbb08b4cb871eb6b1517a74..d9d9773948efeef2da6aa7de9254aa6ba5719b6e 100644 (file)
@@ -32,7 +32,22 @@ rpl_openpty (int *amaster, int *aslave, char *name,
                   (struct winsize *) winp);
 }
 
-#else /* AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 10, mingw */
+#elif (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ /* mingw */
+
+# include <errno.h>
+
+int
+openpty (int *amaster _GL_UNUSED, int *aslave _GL_UNUSED,
+         char *name _GL_UNUSED,
+         struct termios const *termp _GL_UNUSED,
+         struct winsize const *winp _GL_UNUSED)
+{
+  /* Mingw lacks pseudo-terminals altogether.  */
+  errno = ENOSYS;
+  return -1;
+}
+
+#else /* AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 10 */
 
 # include <fcntl.h>
 # include <stdlib.h>
index aff989c79d5ce4f82489243a0400b9f73cc5d03b..b24dd10762d67f26b05ac20483ae1856ecf6fd4a 100644 (file)
 #if defined _AIX
 # include <sys/ioctl.h>
 #endif
+/* Mingw lacks 'struct termios' and 'struct winsize', but a forward
+   declaration of an opaque type is sufficient to allow compilation of
+   a stub openpty().  */
+struct termios;
+struct winsize;
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */