]> rtime.felk.cvut.cz Git - l4.git/blobdiff - 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
index 7e508aea00c8b7491737be7f57e81423544a5f9c..e6b396e1599eb570eb8ee756fb63e8c9110b332a 100644 (file)
@@ -8,12 +8,36 @@
  */
 
 #include <sys/syscall.h>
-#include <sys/time.h>
 
 #ifdef __USE_BSD
+# include <sys/time.h>
+# ifdef __NR_settimeofday
+_syscall2(int, settimeofday, const struct timeval *, tv,
+         const struct timezone *, tz)
+# elif defined __USE_SVID && defined __NR_stime
+#  define __need_NULL
+#  include <stddef.h>
+#  include <errno.h>
+#  include <time.h>
+int settimeofday(const struct timeval *tv, const struct timezone *tz)
+{
+       time_t when;
 
+       if (tv == NULL) {
+               __set_errno(EINVAL);
+               return -1;
+       }
 
-_syscall2(int, settimeofday, const struct timeval *, tv,
-                 const struct timezone *, tz)
+       if (tz != NULL || tv->tv_usec % 1000000 != 0) {
+               __set_errno(ENOSYS);
+               return -1;
+       }
+
+       when = tv->tv_sec + (tv->tv_usec / 1000000);
+       return stime(&when);
+}
+# endif
+# if defined __NR_settimeofday || (defined __USE_SVID && defined __NR_stime)
 libc_hidden_def(settimeofday)
+# endif
 #endif