# HG changeset patch # User Eric Blake # Date 1320864442 25200 # Node ID 7ecf82aec60c1476bbd7942f8b5901b3959a536e # Parent 7dd7edd3fc9a26e29f6b6b16e9d8770d10cad9a5 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 diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-11-09 Eric Blake + 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 --- a/lib/openpty.c +++ b/lib/openpty.c @@ -32,7 +32,22 @@ (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 + +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 # include diff --git a/lib/pty.in.h b/lib/pty.in.h --- a/lib/pty.in.h +++ b/lib/pty.in.h @@ -45,6 +45,11 @@ #if defined _AIX # include #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. */