svn commit: r201574 - stable/8/lib/libc/gen

Konstantin Belousov kib at FreeBSD.org
Tue Jan 5 12:32:09 UTC 2010


Author: kib
Date: Tue Jan  5 12:32:09 2010
New Revision: 201574
URL: http://svn.freebsd.org/changeset/base/201574

Log:
  MFC r201194:
  Use clock_gettime(CLOCK_SECOND) instead of gettimeofday(2) for
  implementation of time(3). CLOCK_SECOND is much faster.

Modified:
  stable/8/lib/libc/gen/time.c
Directory Properties:
  stable/8/lib/libc/   (props changed)
  stable/8/lib/libc/stdtime/   (props changed)

Modified: stable/8/lib/libc/gen/time.c
==============================================================================
--- stable/8/lib/libc/gen/time.c	Tue Jan  5 12:29:03 2010	(r201573)
+++ stable/8/lib/libc/gen/time.c	Tue Jan  5 12:32:09 2010	(r201574)
@@ -37,13 +37,12 @@ __FBSDID("$FreeBSD$");
 #include <sys/time.h>
 
 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;


More information about the svn-src-stable mailing list