@@ -90,6 +90,20 @@ uint64_t current_time(void)
return seconds + (since_boot_time() / 1000000000);
}
+/* The POSIX gettimeofday syscall normally takes a second argument, which is
+ * the timezone (struct timezone). However, it sould be NULL because linux
+ * doesn't use it anymore. So we need for us to add it in this function
+ */
+int gettimeofday(struct timeval *tp)
+{
+ if (!tp)
+ return -1;
+
+ tp->sec = current_time();
+ tp->nsec = shared_info.wc_nsec + (since_boot_time() % 1000000000);
+ return 0;
+}
+
/*
* Local variables:
* mode: C
@@ -8,6 +8,16 @@
#include <xtf/types.h>
+struct timeval {
+#if !defined(__i386__)
+ uint64_t sec;
+ uint64_t nsec;
+#else
+ uint32_t sec;
+ uint32_t nsec;
+#endif
+};
+
#if defined(__i386__)
/* Time from boot in nanoseconds */
uint32_t since_boot_time(void);
@@ -19,6 +29,8 @@ uint64_t since_boot_time(void);
uint64_t current_time(void);
#endif
+int gettimeofday(struct timeval *tp);
+
#endif /* XTF_TIME_H */
/*