Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Unified Diff: src/untrusted/pthread/nc_semaphore.c

Issue 18796006: libpthread: Implement sem_trywait() and sem_getvalue() (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Remove NULL checks Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/syscalls/semaphore_tests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/untrusted/pthread/nc_semaphore.c
diff --git a/src/untrusted/pthread/nc_semaphore.c b/src/untrusted/pthread/nc_semaphore.c
index 635dc859bc5c5fe4ca1b0504951001d6e9418e6d..cb1973c7a70ba14ca284f34375977a062a9e1ade 100644
--- a/src/untrusted/pthread/nc_semaphore.c
+++ b/src/untrusted/pthread/nc_semaphore.c
@@ -90,6 +90,14 @@ int sem_wait(sem_t *sem) {
return 0;
}
+int sem_trywait(sem_t *sem) {
+ if (decrement_if_positive(&sem->count))
+ return 0;
+
+ errno = EAGAIN;
+ return -1;
+}
+
int sem_post(sem_t *sem) {
/* Increment sem->count, checking for overflow. */
int old_value;
@@ -114,3 +122,8 @@ int sem_post(sem_t *sem) {
}
return 0;
}
+
+int sem_getvalue(sem_t *sem, int *value) {
+ *value = sem->count;
+ return 0;
+}
« no previous file with comments | « no previous file | tests/syscalls/semaphore_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698