summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2011-11-09 11:47:22 -0700
committerEric Blake <eblake@redhat.com>2011-11-09 11:47:22 -0700
commit822c53fb8aac23cad1ee4918a85e3843f0621eaa (patch)
treec207aa0c8bce196aa75d77fa0fa5e6a265fa7979
parent7a95153e34b888730afdce3467653f70c4c724e1 (diff)
downloadgnulib-822c53fb8aac23cad1ee4918a85e3843f0621eaa.tar.gz
openpty: provide a stub on mingw
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>
-rw-r--r--ChangeLog4
-rw-r--r--lib/openpty.c17
-rw-r--r--lib/pty.in.h5
3 files changed, 25 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 8b5a1ad948..f51cc258d9 100644
--- 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.
diff --git a/lib/openpty.c b/lib/openpty.c
index c398db5e69..d9d9773948 100644
--- a/lib/openpty.c
+++ b/lib/openpty.c
@@ -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>
diff --git a/lib/pty.in.h b/lib/pty.in.h
index aff989c79d..b24dd10762 100644
--- a/lib/pty.in.h
+++ b/lib/pty.in.h
@@ -45,6 +45,11 @@
#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. */