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

Unified Diff: fusl/src/thread/__timedwait.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 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
Index: fusl/src/thread/__timedwait.c
diff --git a/fusl/src/thread/__timedwait.c b/fusl/src/thread/__timedwait.c
index 13d8465a450552bf418f05ac06a3d81176c5b118..cfed587cbcfd276e35fe9a3660e4d386ca082340 100644
--- a/fusl/src/thread/__timedwait.c
+++ b/fusl/src/thread/__timedwait.c
@@ -5,42 +5,52 @@
#include "syscall.h"
#include "pthread_impl.h"
-int __pthread_setcancelstate(int, int *);
-int __clock_gettime(clockid_t, struct timespec *);
+int __pthread_setcancelstate(int, int*);
+int __clock_gettime(clockid_t, struct timespec*);
-int __timedwait_cp(volatile int *addr, int val,
- clockid_t clk, const struct timespec *at, int priv)
-{
- int r;
- struct timespec to, *top=0;
+int __timedwait_cp(volatile int* addr,
+ int val,
+ clockid_t clk,
+ const struct timespec* at,
+ int priv) {
+ int r;
+ struct timespec to, *top = 0;
- if (priv) priv = 128;
+ if (priv)
+ priv = 128;
- if (at) {
- if (at->tv_nsec >= 1000000000UL) return EINVAL;
- if (__clock_gettime(clk, &to)) return EINVAL;
- to.tv_sec = at->tv_sec - to.tv_sec;
- if ((to.tv_nsec = at->tv_nsec - to.tv_nsec) < 0) {
- to.tv_sec--;
- to.tv_nsec += 1000000000;
- }
- if (to.tv_sec < 0) return ETIMEDOUT;
- top = &to;
- }
+ if (at) {
+ if (at->tv_nsec >= 1000000000UL)
+ return EINVAL;
+ if (__clock_gettime(clk, &to))
+ return EINVAL;
+ to.tv_sec = at->tv_sec - to.tv_sec;
+ if ((to.tv_nsec = at->tv_nsec - to.tv_nsec) < 0) {
+ to.tv_sec--;
+ to.tv_nsec += 1000000000;
+ }
+ if (to.tv_sec < 0)
+ return ETIMEDOUT;
+ top = &to;
+ }
- r = -__syscall_cp(SYS_futex, addr, FUTEX_WAIT|priv, val, top);
- if (r == ENOSYS) r = -__syscall_cp(SYS_futex, addr, FUTEX_WAIT, val, top);
- if (r != EINTR && r != ETIMEDOUT && r != ECANCELED) r = 0;
+ r = -__syscall_cp(SYS_futex, addr, FUTEX_WAIT | priv, val, top);
+ if (r == ENOSYS)
+ r = -__syscall_cp(SYS_futex, addr, FUTEX_WAIT, val, top);
+ if (r != EINTR && r != ETIMEDOUT && r != ECANCELED)
+ r = 0;
- return r;
+ return r;
}
-int __timedwait(volatile int *addr, int val,
- clockid_t clk, const struct timespec *at, int priv)
-{
- int cs, r;
- __pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- r = __timedwait_cp(addr, val, clk, at, priv);
- __pthread_setcancelstate(cs, 0);
- return r;
+int __timedwait(volatile int* addr,
+ int val,
+ clockid_t clk,
+ const struct timespec* at,
+ int priv) {
+ int cs, r;
+ __pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
+ r = __timedwait_cp(addr, val, clk, at, priv);
+ __pthread_setcancelstate(cs, 0);
+ return r;
}

Powered by Google App Engine
This is Rietveld 408576698