diff options
author | Christopher Faylor <me@cgf.cx> | 2002-12-14 04:01:32 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-12-14 04:01:32 +0000 |
commit | 8bce0d723c50924b908dca1467037c8008e872be (patch) | |
tree | dcaf982175c090c0e7668af5fa00dac09fb07b27 /winsup/cygwin/fhandler_raw.cc | |
parent | ec085641a9b4d25e16df12d7449f7ad689934117 (diff) | |
download | newlib-8bce0d723c50924b908dca1467037c8008e872be.zip newlib-8bce0d723c50924b908dca1467037c8008e872be.tar.gz newlib-8bce0d723c50924b908dca1467037c8008e872be.tar.bz2 |
Throughout, change fhandler_*::read and fhandler_*::raw_read to void functions
whose second arguments are both the lenght and the return value.
* fhandler.cc (fhandler_base::read): Rework slightly to use second argument as
input/output. Tweak CRLF stuff.
(fhandler_base::readv): Accommodate fhandler_*::read changes.
* cygthread.h (cygthread::detach): Declare as taking optional handle argument.
(cygthread::detach): When given a handle argument, wait for the handle to be
signalled before waiting for thread to detach. Return true when signal
detected.
Diffstat (limited to 'winsup/cygwin/fhandler_raw.cc')
-rw-r--r-- | winsup/cygwin/fhandler_raw.cc | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc index 2b8470a..45ce414 100644 --- a/winsup/cygwin/fhandler_raw.cc +++ b/winsup/cygwin/fhandler_raw.cc @@ -189,8 +189,8 @@ fhandler_dev_raw::close (void) return fhandler_base::close (); } -int -fhandler_dev_raw::raw_read (void *ptr, size_t ulen) +void +fhandler_dev_raw::raw_read (void *ptr, size_t& ulen) { DWORD bytes_read = 0; DWORD read2; @@ -204,21 +204,22 @@ fhandler_dev_raw::raw_read (void *ptr, size_t ulen) if (ret) { set_errno (is_eom (ret) ? ENOSPC : EACCES); - return -1; + goto err; } /* Checking a previous end of file */ if (eof_detected && !lastblk_to_read) { eof_detected = 0; - return 0; + ulen = 0; + return; } /* Checking a previous end of media */ if (eom_detected && !lastblk_to_read) { set_errno (ENOSPC); - return -1; + goto err; } if (devbuf) @@ -269,7 +270,7 @@ fhandler_dev_raw::raw_read (void *ptr, size_t ulen) { debug_printf ("return -1, set errno to EACCES"); set_errno (EACCES); - return -1; + goto err; } if (is_eof (ret)) @@ -283,7 +284,7 @@ fhandler_dev_raw::raw_read (void *ptr, size_t ulen) { debug_printf ("return -1, set errno to ENOSPC"); set_errno (ENOSPC); - return -1; + goto err; } break; } @@ -311,7 +312,7 @@ fhandler_dev_raw::raw_read (void *ptr, size_t ulen) { debug_printf ("return -1, set errno to EACCES"); set_errno (EACCES); - return -1; + goto err; } if (bytes_read) { @@ -324,11 +325,16 @@ fhandler_dev_raw::raw_read (void *ptr, size_t ulen) { debug_printf ("return -1, set errno to ENOSPC"); set_errno (ENOSPC); - return -1; + goto err; } } - return bytes_read; + (ssize_t) ulen = bytes_read; + return; + +err: + (ssize_t) ulen = -1; + return; } int |