From: Ben Gras Date: Mon, 21 Sep 2009 14:44:35 +0000 (+0000) Subject: ftime() X-Git-Tag: v3.1.5~127 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=e8b3ac74a65185aafa3c812a5aae0458fbba8217;p=minix.git ftime() --- diff --git a/lib/stdtime/Makefile.in b/lib/stdtime/Makefile.in index 3efdcb255..64eb936a5 100644 --- a/lib/stdtime/Makefile.in +++ b/lib/stdtime/Makefile.in @@ -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 index 000000000..cf4c30e70 --- /dev/null +++ b/lib/stdtime/ftime.c @@ -0,0 +1,24 @@ +/* Ported from glibc */ + +#include +#include + +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; +}