1
/* -*- buffer-read-only: t -*- vi: set ro: */
2
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
4
Copyright (C) 2009-2011 Free Software Foundation, Inc.
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 3, or (at your option)
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software Foundation,
18
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
24
#include "signature.h"
25
SIGNATURE_CHECK (pipe2, int, (int[2], int));
30
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
31
/* Get declarations of the Win32 API functions. */
32
# define WIN32_LEAN_AND_MEAN
36
#include "binary-io.h"
38
#include "nonblocking.h"
40
/* Return true if FD is open. */
44
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
45
/* On Win32, the initial state of unassigned standard file
46
descriptors is that they are open but point to an
47
INVALID_HANDLE_VALUE, and there is no fcntl. */
48
return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE;
51
# error Please port fcntl to your platform
53
return 0 <= fcntl (fd, F_GETFL);
57
/* Return true if FD is not inherited to child processes. */
61
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
62
HANDLE h = (HANDLE) _get_osfhandle (fd);
64
ASSERT (GetHandleInformation (h, &flags));
65
return (flags & HANDLE_FLAG_INHERIT) == 0;
68
ASSERT ((flags = fcntl (fd, F_GETFD)) >= 0);
69
return (flags & FD_CLOEXEC) != 0;
79
for (use_nonblocking = 0; use_nonblocking <= 1; use_nonblocking++)
80
for (use_cloexec = 0; use_cloexec <= !!O_CLOEXEC; use_cloexec++)
87
o_flags |= O_NONBLOCK;
93
ASSERT (pipe2 (fd, o_flags) >= 0);
96
ASSERT (fd[0] != fd[1]);
97
ASSERT (is_open (fd[0]));
98
ASSERT (is_open (fd[1]));
101
ASSERT (is_cloexec (fd[0]));
102
ASSERT (is_cloexec (fd[1]));
106
ASSERT (!is_cloexec (fd[0]));
107
ASSERT (!is_cloexec (fd[1]));
111
ASSERT (get_nonblocking_flag (fd[0]) == 1);
112
ASSERT (get_nonblocking_flag (fd[1]) == 1);
116
ASSERT (get_nonblocking_flag (fd[0]) == 0);
117
ASSERT (get_nonblocking_flag (fd[1]) == 0);
120
ASSERT (close (fd[0]) == 0);
121
ASSERT (close (fd[1]) == 0);