X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tests%2Ftest-pipe2.c;h=c278f7aaff9d7fe8756c7427d905710f09076b00;hb=471fc34ae463a72dcebf813153cbb73499c1e0a2;hp=8ca8e013633be27aee319cd21bb6533b2e4b1efb;hpb=0568a6e8985cc2ae9c57cb03fc81f5305458b7d2;p=gnulib.git diff --git a/tests/test-pipe2.c b/tests/test-pipe2.c index 8ca8e0136..c278f7aaf 100644 --- a/tests/test-pipe2.c +++ b/tests/test-pipe2.c @@ -29,11 +29,15 @@ SIGNATURE_CHECK (pipe2, int, (int[2], int)); /* Get declarations of the Win32 API functions. */ # define WIN32_LEAN_AND_MEAN # include +/* Get _get_osfhandle. */ +# include "msvc-nothrow.h" #endif #include "binary-io.h" #include "macros.h" -#include "nonblocking.h" +#if GNULIB_NONBLOCKING +# include "nonblocking.h" +#endif /* Return true if FD is open. */ static bool @@ -68,13 +72,30 @@ is_cloexec (int fd) #endif } +#if ! GNULIB_NONBLOCKING +static int +get_nonblocking_flag (int fd) +{ +# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + return 0; +# else +# ifndef F_GETFL +# error Please port fcntl to your platform +# endif + int flags; + ASSERT ((flags = fcntl (fd, F_GETFL)) >= 0); + return (flags & O_NONBLOCK) != 0; +# endif +} +#endif + int main () { int use_nonblocking; int use_cloexec; - for (use_nonblocking = 0; use_nonblocking <= 1; use_nonblocking++) + for (use_nonblocking = 0; use_nonblocking <= !!O_NONBLOCK; use_nonblocking++) for (use_cloexec = 0; use_cloexec <= !!O_CLOEXEC; use_cloexec++) { int o_flags;