summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/thread.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2013-09-25 14:44:45 +0000
committerChristopher Faylor <me@cgf.cx>2013-09-25 14:44:45 +0000
commit1dc2c177f40875f9095dc3a10a5c93ad6eb45934 (patch)
tree313867e2adc19f38c56a166e81d2c214c63f52a0 /winsup/cygwin/thread.cc
parent31fb5c643306b16496e97e075495de5b0335f11a (diff)
downloadcygnal-1dc2c177f40875f9095dc3a10a5c93ad6eb45934.tar.gz
cygnal-1dc2c177f40875f9095dc3a10a5c93ad6eb45934.tar.bz2
cygnal-1dc2c177f40875f9095dc3a10a5c93ad6eb45934.zip
* thread.cc (semaphore::_getvalue): Set *sval as appropriate. Set errno and
return -1 on error.
Diffstat (limited to 'winsup/cygwin/thread.cc')
-rw-r--r--winsup/cygwin/thread.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 0256ad717..0e0d30127 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -3443,9 +3443,19 @@ semaphore::_getvalue (int *sval)
status = NtQuerySemaphore (win32_obj_id, SemaphoreBasicInformation, &sbi,
sizeof sbi, NULL);
+ int res;
if (NT_SUCCESS (status))
- return sbi.CurrentCount;
- return startvalue;
+ {
+ *sval = sbi.CurrentCount;
+ res = 0;
+ }
+ else
+ {
+ *sval = startvalue;
+ __seterrno_from_nt_status (status);
+ res = -1;
+ }
+ return res;
}
int