1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* POSIX compatible read() function.
4 Copyright (C) 2008-2013 Free Software Foundation, Inc.
5 Written by Bruno Haible <bruno@clisp.org>, 2011.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
30 # define WIN32_LEAN_AND_MEAN /* avoid including junk */
33 # include "msvc-inval.h"
34 # include "msvc-nothrow.h"
38 # if HAVE_MSVC_INVALID_PARAMETER_HANDLER
40 read_nothrow (int fd, void *buf, size_t count)
46 result = read (fd, buf, count);
58 # define read_nothrow read
62 rpl_read (int fd, void *buf, size_t count)
64 ssize_t ret = read_nothrow (fd, buf, count);
66 # if GNULIB_NONBLOCKING
68 && GetLastError () == ERROR_NO_DATA)
70 HANDLE h = (HANDLE) _get_osfhandle (fd);
71 if (GetFileType (h) == FILE_TYPE_PIPE)
73 /* h is a pipe or socket. */
75 if (GetNamedPipeHandleState (h, &state, NULL, NULL, NULL, NULL, 0)
76 && (state & PIPE_NOWAIT) != 0)
77 /* h is a pipe in non-blocking mode.
78 Change errno from EINVAL to EAGAIN. */