projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add further ioctl time64 fallback conversions
[musl]
/
src
/
linux
/
settimeofday.c
diff --git
a/src/linux/settimeofday.c
b/src/linux/settimeofday.c
index
d741f66
..
860fb5d
100644
(file)
--- a/
src/linux/settimeofday.c
+++ b/
src/linux/settimeofday.c
@@
-1,7
+1,13
@@
+#define _BSD_SOURCE
#include <sys/time.h>
#include <sys/time.h>
+#include <time.h>
+#include <errno.h>
#include "syscall.h"
#include "syscall.h"
-int settimeofday(const struct timeval *tv,
void
*tz)
+int settimeofday(const struct timeval *tv,
const struct timezone
*tz)
{
{
- return syscall(SYS_settimeofday, tv, 0);
+ if (!tv) return 0;
+ if (tv->tv_usec >= 1000000ULL) return __syscall_ret(-EINVAL);
+ return clock_settime(CLOCK_REALTIME, &((struct timespec){
+ .tv_sec = tv->tv_sec, .tv_nsec = tv->tv_usec * 1000}));
}
}