MFC r201194:

Use clock_gettime(CLOCK_SECOND) instead of gettimeofday(2) for
implementation of time(3). CLOCK_SECOND is much faster.
This commit is contained in:
kib 2010-01-05 12:32:09 +00:00
parent 7186116758
commit 194840d7a1

View File

@ -37,13 +37,12 @@ __FBSDID("$FreeBSD$");
#include <sys/time.h> #include <sys/time.h>
time_t time_t
time(t) time(time_t *t)
time_t *t;
{ {
struct timeval tt; struct timespec tt;
time_t retval; time_t retval;
if (gettimeofday(&tt, (struct timezone *)0) < 0) if (clock_gettime(CLOCK_SECOND, &tt) < 0)
retval = -1; retval = -1;
else else
retval = tt.tv_sec; retval = tt.tv_sec;