diff options
author | Andy Wingo <wingo@pobox.com> | 2011-10-27 13:45:04 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-10-27 13:45:04 +0200 |
commit | 4938d3cb742de2a356586c55e5af32e193c5990b (patch) | |
tree | b4bfe0fd26e102c5fa38ca9965bc4ebdbae8e3b4 /lib/read.c | |
parent | 9d013330154852bc2309947adaa30b32418642c0 (diff) | |
parent | 2be3feb17e5456bba71749e0e97adf45c32c4e0e (diff) | |
download | guile-4938d3cb742de2a356586c55e5af32e193c5990b.tar.gz |
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
GUILE-VERSION
libguile/deprecated.c
libguile/gc-malloc.c
module/language/tree-il/peval.scm
Diffstat (limited to 'lib/read.c')
-rw-r--r-- | lib/read.c | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/lib/read.c b/lib/read.c index d161a40c2..a0b26377c 100644 --- a/lib/read.c +++ b/lib/read.c @@ -20,23 +20,48 @@ /* Specification. */ #include <unistd.h> -/* Replace this function only if module 'nonblocking' is requested. */ -#if GNULIB_NONBLOCKING +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# include <errno.h> +# include <io.h> -# include <errno.h> -# include <io.h> +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include <windows.h> -# define WIN32_LEAN_AND_MEAN /* avoid including junk */ -# include <windows.h> +# include "msvc-inval.h" +# include "msvc-nothrow.h" + +# undef read + +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +static inline ssize_t +read_nothrow (int fd, void *buf, size_t count) +{ + ssize_t result; + + TRY_MSVC_INVAL + { + result = read (fd, buf, count); + } + CATCH_MSVC_INVAL + { + result = -1; + errno = EBADF; + } + DONE_MSVC_INVAL; + + return result; +} +# else +# define read_nothrow read +# endif ssize_t rpl_read (int fd, void *buf, size_t count) -#undef read { - ssize_t ret = read (fd, buf, count); + ssize_t ret = read_nothrow (fd, buf, count); +# if GNULIB_NONBLOCKING if (ret < 0 && GetLastError () == ERROR_NO_DATA) { @@ -52,8 +77,9 @@ rpl_read (int fd, void *buf, size_t count) errno = EAGAIN; } } +# endif + return ret; } -# endif #endif |