diff options
author | Christopher Faylor <me@cgf.cx> | 2002-12-14 07:01:32 +0300 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-12-14 07:01:32 +0300 |
commit | 8bce0d723c50924b908dca1467037c8008e872be (patch) | |
tree | dcaf982175c090c0e7668af5fa00dac09fb07b27 /winsup/cygwin/fhandler_random.cc | |
parent | ec085641a9b4d25e16df12d7449f7ad689934117 (diff) |
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_random.cc')
-rw-r--r-- | winsup/cygwin/fhandler_random.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/winsup/cygwin/fhandler_random.cc b/winsup/cygwin/fhandler_random.cc index 2447b4e78..6d02db587 100644 --- a/winsup/cygwin/fhandler_random.cc +++ b/winsup/cygwin/fhandler_random.cc @@ -110,27 +110,33 @@ fhandler_dev_random::pseudo_read (void *ptr, size_t len) return len; } -int __stdcall -fhandler_dev_random::read (void *ptr, size_t len) +void __stdcall +fhandler_dev_random::read (void *ptr, size_t& len) { if (!len) - return 0; + return; + if (!ptr) { set_errno (EINVAL); - return -1; + (ssize_t) len = -1; + return; } if (crypt_gen_random (ptr, len)) - return len; + return; + /* If device is /dev/urandom, use pseudo number generator as fallback. Don't do this for /dev/random since it's intended for uses that need very high quality randomness. */ if (unit == URANDOM) - return pseudo_read (ptr, len); + { + len = pseudo_read (ptr, len); + return; + } __seterrno (); - return -1; + (ssize_t) len = -1; } __off64_t |