]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/common/settimeofday.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / common / settimeofday.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * settimeofday() for uClibc
4  *
5  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
6  *
7  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8  */
9
10 #include <sys/syscall.h>
11
12 #ifdef __USE_BSD
13 # include <sys/time.h>
14 # ifdef __NR_settimeofday
15 _syscall2(int, settimeofday, const struct timeval *, tv,
16           const struct timezone *, tz)
17 # elif defined __USE_SVID && defined __NR_stime
18 #  define __need_NULL
19 #  include <stddef.h>
20 #  include <errno.h>
21 #  include <time.h>
22 int settimeofday(const struct timeval *tv, const struct timezone *tz)
23 {
24         time_t when;
25
26         if (tv == NULL) {
27                 __set_errno(EINVAL);
28                 return -1;
29         }
30
31         if (tz != NULL || tv->tv_usec % 1000000 != 0) {
32                 __set_errno(ENOSYS);
33                 return -1;
34         }
35
36         when = tv->tv_sec + (tv->tv_usec / 1000000);
37         return stime(&when);
38 }
39 # endif
40 # if defined __NR_settimeofday || (defined __USE_SVID && defined __NR_stime)
41 libc_hidden_def(settimeofday)
42 # endif
43 #endif