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

Side by Side Diff: fusl/src/time/clock_gettime.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « fusl/src/time/clock_getres.c ('k') | fusl/src/time/clock_nanosleep.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include <time.h>
2 #include <errno.h>
3 #include <stdint.h>
4 #include "syscall.h"
5 #include "libc.h"
6 #include "atomic.h"
7
8 static int sc_clock_gettime(clockid_t clk, struct timespec *ts)
9 {
10 int r = __syscall(SYS_clock_gettime, clk, ts);
11 if (!r) return r;
12 if (r == -ENOSYS) {
13 if (clk == CLOCK_REALTIME) {
14 __syscall(SYS_gettimeofday, ts, 0);
15 ts->tv_nsec = (int)ts->tv_nsec * 1000;
16 return 0;
17 }
18 r = -EINVAL;
19 }
20 errno = -r;
21 return -1;
22 }
23
24 void *__vdsosym(const char *, const char *);
25
26 int __clock_gettime(clockid_t clk, struct timespec *ts)
27 {
28 #ifdef VDSO_CGT_SYM
29 static int (*volatile cgt)(clockid_t, struct timespec *);
30 if (!cgt) {
31 void *f = __vdsosym(VDSO_CGT_VER, VDSO_CGT_SYM);
32 if (!f) f = (void *)sc_clock_gettime;
33 a_cas_p(&cgt, 0, f);
34 }
35 return cgt(clk, ts);
36 #else
37 return sc_clock_gettime(clk, ts);
38 #endif
39 }
40
41 weak_alias(__clock_gettime, clock_gettime);
OLDNEW
« no previous file with comments | « fusl/src/time/clock_getres.c ('k') | fusl/src/time/clock_nanosleep.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698