* gettimeofday() now also fills in a passed in struct timezone, if any,
using the new _kern_get_timezone() syscall. * Added an implementation of ftime() based on the above function, this may fix bug #308. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16786 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4,6 +4,7 @@ UseHeaders $(TARGET_PRIVATE_KERNEL_HEADERS) : true ;
|
|||||||
|
|
||||||
MergeObject posix_sys.o :
|
MergeObject posix_sys.o :
|
||||||
chmod.c
|
chmod.c
|
||||||
|
ftime.c
|
||||||
getrusage.c
|
getrusage.c
|
||||||
gettimeofday.c
|
gettimeofday.c
|
||||||
itimer.c
|
itimer.c
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Axel Dörfler, [email protected]. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/timeb.h>
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
ftime(struct timeb *timeb)
|
||||||
|
{
|
||||||
|
struct timezone tz;
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
if (timeb == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
gettimeofday(&tv, &tz);
|
||||||
|
|
||||||
|
timeb->time = tv.tv_sec;
|
||||||
|
timeb->millitm = tv.tv_usec / 1000UL;
|
||||||
|
timeb->timezone = tz.tz_minuteswest;
|
||||||
|
timeb->dstflag = tz.tz_dsttime;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,25 +1,31 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2003-2006, Axel Dörfler, [email protected]. All rights reserved.
|
||||||
** Distributed under the terms of the OpenBeOS License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <OS.h>
|
#include <syscalls.h>
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
gettimeofday(struct timeval *tv, struct timezone *tz)
|
gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||||
{
|
{
|
||||||
bigtime_t usecs;
|
if (tv != NULL) {
|
||||||
|
bigtime_t usecs = real_time_clock_usecs();
|
||||||
|
|
||||||
if (tv == NULL)
|
tv->tv_sec = usecs / 1000000;
|
||||||
return 0;
|
tv->tv_usec = usecs % 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
usecs = real_time_clock_usecs();
|
if (tz != NULL) {
|
||||||
|
time_t timezoneOffset;
|
||||||
|
bool daylightSavingTime;
|
||||||
|
_kern_get_timezone(&timezoneOffset, &daylightSavingTime);
|
||||||
|
|
||||||
tv->tv_sec = usecs / 1000000;
|
tz->tz_minuteswest = timezoneOffset;
|
||||||
tv->tv_usec = usecs % 1000000;
|
tz->tz_dsttime = daylightSavingTime;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user