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

Side by Side Diff: fusl/src/linux/adjtime.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 unified diff | Download patch
OLDNEW
1 #define _GNU_SOURCE 1 #define _GNU_SOURCE
2 #include <sys/time.h> 2 #include <sys/time.h>
3 #include <sys/timex.h> 3 #include <sys/timex.h>
4 #include <errno.h> 4 #include <errno.h>
5 #include "syscall.h" 5 #include "syscall.h"
6 6
7 int adjtime(const struct timeval *in, struct timeval *out) 7 int adjtime(const struct timeval* in, struct timeval* out) {
8 { 8 struct timex tx = {0};
9 » struct timex tx = { 0 }; 9 if (in) {
10 » if (in) { 10 if (in->tv_sec > 1000 || in->tv_usec > 1000000000) {
11 » » if (in->tv_sec > 1000 || in->tv_usec > 1000000000) { 11 errno = EINVAL;
12 » » » errno = EINVAL; 12 return -1;
13 » » » return -1; 13 }
14 » » } 14 tx.offset = in->tv_sec * 1000000 + in->tv_usec;
15 » » tx.offset = in->tv_sec*1000000 + in->tv_usec; 15 tx.modes = ADJ_OFFSET_SINGLESHOT;
16 » » tx.modes = ADJ_OFFSET_SINGLESHOT; 16 }
17 » } 17 if (syscall(SYS_adjtimex, &tx) < 0)
18 » if (syscall(SYS_adjtimex, &tx) < 0) return -1; 18 return -1;
19 » if (out) { 19 if (out) {
20 » » out->tv_sec = tx.offset / 1000000; 20 out->tv_sec = tx.offset / 1000000;
21 » » if ((out->tv_usec = tx.offset % 1000000) < 0) { 21 if ((out->tv_usec = tx.offset % 1000000) < 0) {
22 » » » out->tv_sec--; 22 out->tv_sec--;
23 » » » out->tv_usec += 1000000; 23 out->tv_usec += 1000000;
24 » » } 24 }
25 » } 25 }
26 » return 0; 26 return 0;
27 } 27 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698