ftime()
This commit is contained in:
parent
b2adf0c1ae
commit
e8b3ac74a6
2 changed files with 25 additions and 0 deletions
|
@ -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
|
||||
|
|
24
lib/stdtime/ftime.c
Normal file
24
lib/stdtime/ftime.c
Normal file
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue