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

Unified Diff: nptl/pthread_condattr_setclock.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 | « no previous file | nptl/pthread_condattr_setpshared.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: nptl/pthread_condattr_setclock.c
diff --git a/nptl/pthread_condattr_setclock.c b/nptl/pthread_condattr_setclock.c
index 5c54f764e62fbd6449fe2c4d33b9d69ab9098dfd..de66f4a1a854d456e1daa1ae058cd2882869df82 100644
--- a/nptl/pthread_condattr_setclock.c
+++ b/nptl/pthread_condattr_setclock.c
@@ -31,43 +31,20 @@ pthread_condattr_setclock (attr, clock_id)
pthread_condattr_t *attr;
clockid_t clock_id;
{
- /* Only a few clocks are allowed. CLOCK_REALTIME is always allowed.
- CLOCK_MONOTONIC only if the kernel has the necessary support. */
- if (clock_id == CLOCK_MONOTONIC)
+ switch (clock_id)
{
-#ifndef __ASSUME_POSIX_TIMERS
-# ifdef __NR_clock_getres
- /* Check whether the clock is available. */
- static int avail;
-
- if (avail == 0)
- {
- struct timespec ts;
-
- INTERNAL_SYSCALL_DECL (err);
- int val;
- val = INTERNAL_SYSCALL (clock_getres, err, 2, CLOCK_MONOTONIC, &ts);
- avail = INTERNAL_SYSCALL_ERROR_P (val, err) ? -1 : 1;
- }
-
- if (avail < 0)
-# endif
- /* Not available. */
- return EINVAL;
-#endif
+ case CLOCK_REALTIME:
+ /* This is the default state and the only one actually supported. */
+ return 0;
+
+ case CLOCK_MONOTONIC:
+ /* NaCl recognizes CLOCK_MONOTONIC for other purposes, so it is a
+ "known clock". But NaCl doesn't support it for this purpose. */
+ return ENOTSUP;
+
+ default:
+ /* The only other recognized clocks are CPU-time clocks,
+ which POSIX says should get EINVAL. */
+ return EINVAL;
}
- else if (clock_id != CLOCK_REALTIME)
- /* If more clocks are allowed some day the storing of the clock ID
- in the pthread_cond_t structure needs to be adjusted. */
- return EINVAL;
-
- /* Make sure the value fits in the bits we reserved. */
- assert (clock_id < (1 << COND_NWAITERS_SHIFT));
-
- int *valuep = &((struct pthread_condattr *) attr)->value;
-
- *valuep = ((*valuep & ~(((1 << COND_NWAITERS_SHIFT) - 1) << 1))
- | (clock_id << 1));
-
- return 0;
}
« no previous file with comments | « no previous file | nptl/pthread_condattr_setpshared.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698