From 358ed16f750576f266ebf86ea1ee56204d71bb52 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 29 Dec 2009 12:47:47 +0000 Subject: [PATCH] Use clock_gettime(CLOCK_SECOND) instead of gettimeofday(2) for implementation of time(3). CLOCK_SECOND is much faster. No objections from: phk Submitted by: Valentin Nechayev MFC after: 1 week --- lib/libc/gen/time.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/libc/gen/time.c b/lib/libc/gen/time.c index 840f9b6b7bcc..214dfce1bb8e 100644 --- a/lib/libc/gen/time.c +++ b/lib/libc/gen/time.c @@ -37,13 +37,12 @@ __FBSDID("$FreeBSD$"); #include time_t -time(t) - time_t *t; +time(time_t *t) { - struct timeval tt; + struct timespec tt; time_t retval; - if (gettimeofday(&tt, (struct timezone *)0) < 0) + if (clock_gettime(CLOCK_SECOND, &tt) < 0) retval = -1; else retval = tt.tv_sec;