summaryrefslogtreecommitdiff
path: root/time/settimeofday.c
diff options
context:
space:
mode:
Diffstat (limited to 'time/settimeofday.c')
-rw-r--r--time/settimeofday.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/time/settimeofday.c b/time/settimeofday.c
index 6aa4832d65..ad57ad41a1 100644
--- a/time/settimeofday.c
+++ b/time/settimeofday.c
@@ -16,6 +16,7 @@
<https://www.gnu.org/licenses/>. */
#include <errno.h>
+#include <time.h>
#include <sys/time.h>
/* Set the current time of day and timezone information.
@@ -23,9 +24,24 @@
int
__settimeofday (const struct timeval *tv, const struct timezone *tz)
{
- __set_errno (ENOSYS);
- return -1;
+ if (__glibc_unlikely (tz != 0))
+ {
+ if (tv != 0)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+ return __settimezone (tz);
+ }
+
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (tv, &ts);
+ return __clock_settime (CLOCK_REALTIME, &ts);
}
-stub_warning (settimeofday)
-weak_alias (__settimeofday, settimeofday)
+#ifdef VERSION_settimeofday
+weak_alias (__settimeofday, __settimeofday_w);
+default_symbol_version (__settimeofday_w, settimeofday, VERSION_settimeofday);
+#else
+weak_alias (__settimeofday, settimeofday);
+#endif