]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR go/66574
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 21 Nov 2015 01:27:44 +0000 (01:27 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 21 Nov 2015 01:27:44 +0000 (01:27 +0000)
    runtime: Use clock_gettime to get current time.

    Fetch the current time in nanoseconds, not microseconds, by using
    clock_gettime rather than gettimeofday.

    Update golang/go#11222.

    Fixes https://gcc.gnu.org/PR66574.

    Reviewed-on: https://go-review.googlesource.com/17156

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230694 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/MERGE
libgo/configure
libgo/configure.ac
libgo/runtime/go-now.c

index 3ccd3fc3039f30f8bd9c90b69c2dbb3121d1716f..4097bab3073f4ef25492445e88de3d2087f4217f 100644 (file)
@@ -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 eb37e29d2f8e29c6f6e0988f4a43abee9bb8296a..e024b2f4b6294681f36184008fbd0bc2ad9c6bb0 100755 (executable)
@@ -14477,6 +14477,62 @@ ac_res=$ac_cv_search_nanosleep
 if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5
+$as_echo_n "checking for library containing clock_gettime... " >&6; }
+if test "${ac_cv_search_clock_gettime+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char clock_gettime ();
+int
+main ()
+{
+return clock_gettime ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' rt; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_clock_gettime=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_clock_gettime+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_clock_gettime+set}" = set; then :
+
+else
+  ac_cv_search_clock_gettime=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5
+$as_echo "$ac_cv_search_clock_gettime" >&6; }
+ac_res=$ac_cv_search_clock_gettime
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
 fi
 
 
index 6e23a85fa6d698fbeadf3edb1baf90626c52b038..6eddb860974dd04f8050eca56a87d7d947f86950 100644 (file)
@@ -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 ea8d070e9f3514f3fcaffde50c83a27169086918..d24e6ee76af17794b0a324d7c93e118c3810a8a6 100644 (file)
 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;
 }