public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* libgo: use clock_gettime to get current time
@ 2015-11-21  1:42 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2015-11-21  1:42 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 275 bytes --]

PR 66574 aka https://golang.org/issue/11222 points out that libgo is
only retrieving the current time in microseconds, when it should be
using nanoseconds.  This patch fixes the problem.  Bootstrapped and
ran Go testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1483 bytes --]

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 230689)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-f79db38cf3484b63f7807abef05eecb23e9d0806
+b839c8c35af49bd6d86306ad34449654a4657cb1
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/configure.ac
===================================================================
--- libgo/configure.ac	(revision 230463)
+++ libgo/configure.ac	(working copy)
@@ -501,9 +501,10 @@ PTHREAD_LIBS=
 AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS=-lpthread)
 AC_SUBST(PTHREAD_LIBS)
 
-dnl Test if -lrt is required for sched_yield and/or nanosleep.
+dnl Test if -lrt is required for sched_yield or nanosleep or clock_gettime.
 AC_SEARCH_LIBS([sched_yield], [rt])
 AC_SEARCH_LIBS([nanosleep], [rt])
+AC_SEARCH_LIBS([clock_gettime], [rt])
 
 AC_C_BIGENDIAN
 
Index: libgo/runtime/go-now.c
===================================================================
--- libgo/runtime/go-now.c	(revision 230463)
+++ libgo/runtime/go-now.c	(working copy)
@@ -13,11 +13,11 @@
 struct time_now_ret
 now()
 {
-  struct timeval tv;
+  struct timespec ts;
   struct time_now_ret ret;
 
-  gettimeofday (&tv, NULL);
-  ret.sec = tv.tv_sec;
-  ret.nsec = tv.tv_usec * 1000;
+  clock_gettime (CLOCK_REALTIME, &ts);
+  ret.sec = ts.tv_sec;
+  ret.nsec = ts.tv_nsec;
   return ret;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-21  1:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-21  1:42 libgo: use clock_gettime to get current time Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).