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

Unified Diff: nptl/pthread_condattr_setpshared.c

Issue 1234673002: Clean up error returns for unsupported pthread mutex/cond attr values (Closed) Base URL: https://chromium.googlesource.com/native_client/nacl-glibc.git@master
Patch Set: Created 5 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 | « nptl/pthread_condattr_setclock.c ('k') | nptl/pthread_mutexattr_setpshared.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: nptl/pthread_condattr_setpshared.c
diff --git a/nptl/pthread_condattr_setpshared.c b/nptl/pthread_condattr_setpshared.c
index f00858780b93028b8bc27ac2965cbda7edaf6f9f..f1813da7f10feb2715a729693546c6f4d8309028 100644
--- a/nptl/pthread_condattr_setpshared.c
+++ b/nptl/pthread_condattr_setpshared.c
@@ -20,18 +20,21 @@
#include <errno.h>
#include <pthreadP.h>
+
int
pthread_condattr_setpshared (attr, pshared)
pthread_condattr_t *attr;
int pshared;
{
- if (pshared != PTHREAD_PROCESS_PRIVATE
- && __builtin_expect (pshared != PTHREAD_PROCESS_SHARED, 0))
- return EINVAL;
-
- int *valuep = &((struct pthread_condattr *) attr)->value;
+ switch (pshared)
+ {
+ case PTHREAD_PROCESS_PRIVATE: /* This is the default state. */
+ return 0;
- *valuep = (*valuep & ~1) | (pshared != PTHREAD_PROCESS_PRIVATE);
+ case PTHREAD_PROCESS_SHARED: /* NaCl does not support this. */
+ return ENOTSUP;
- return 0;
+ default: /* Anything else is bogus. */
+ return EINVAL;
+ }
}
« no previous file with comments | « nptl/pthread_condattr_setclock.c ('k') | nptl/pthread_mutexattr_setpshared.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698