]> Zhao Yanbai Git Server - minix.git/commitdiff
ftime()
authorBen Gras <ben@minix3.org>
Mon, 21 Sep 2009 14:44:35 +0000 (14:44 +0000)
committerBen Gras <ben@minix3.org>
Mon, 21 Sep 2009 14:44:35 +0000 (14:44 +0000)
lib/stdtime/Makefile.in
lib/stdtime/ftime.c [new file with mode: 0644]

index 3efdcb25556ffa45afef84c9be5065a34df9c4cd..64eb936a56942f07bc80867034c9573eb4b9c944 100644 (file)
@@ -6,6 +6,7 @@ CFLAGS="-D_MINIX -D_POSIX_SOURCE -D__USG -I$Z"
 
 LIBRARIES=libc
 libc_FILES="
+       ftime.c
        asctime.c
        localtime.c
        strftime.c
diff --git a/lib/stdtime/ftime.c b/lib/stdtime/ftime.c
new file mode 100644 (file)
index 0000000..cf4c30e
--- /dev/null
@@ -0,0 +1,24 @@
+/* Ported from glibc */
+
+#include <sys/timeb.h>
+#include <sys/time.h>
+
+int ftime(struct timeb *timebuf)
+{
+       struct timeval tv;
+       struct timezone tz;
+
+       if (gettimeofday (&tv, &tz) < 0)
+               return -1;
+
+       timebuf->time = tv.tv_sec;
+       timebuf->millitm = (tv.tv_usec + 500) / 1000;
+       if (timebuf->millitm == 1000)
+       {
+               ++timebuf->time;
+               timebuf->millitm = 0;
+       }
+       timebuf->timezone = tz.tz_minuteswest;
+       timebuf->dstflag = tz.tz_dsttime;
+       return 0;
+}