Patchwork Default to --enable-libstdcxx-time=auto

login
register
mail settings
Submitter Jonathan Wakely
Date May 28, 2013, 9:15 p.m.
Message ID <CAH6eHdQwGw5ZGWGVpHW0CQBRcashr-4gHHWDHO0C6SQ=uSah+g@mail.gmail.com>
Download mbox | patch
Permalink /patch/246964/
State New
Headers show

Comments

Jonathan Wakely - May 28, 2013, 9:15 p.m.
* src/c++11/compatibility-chrono.cc (steady_clock::now()): If
        !_GLIBCXX_USE_GETTIMEOFDAY perform conversion inline instead of
        calling non-existent from_time_t.

Tested x86_64-linux, committed to trunk and the 4.8 branch.

Steve, trunk should build OK now, thanks for testing and reporting it.
commit 024a5d2b1618f46c950bf3d43b5dcb7a3e019ff7
Author: Jonathan Wakely <jwakely.gcc@gmail.com>
Date:   Tue May 28 20:46:06 2013 +0100

    	* src/c++11/compatibility-chrono.cc (steady_clock::now()): If
    	!_GLIBCXX_USE_GETTIMEOFDAY perform conversion inline instead of
    	calling non-existent from_time_t.

Patch

diff --git a/libstdc++-v3/src/c++11/compatibility-chrono.cc b/libstdc++-v3/src/c++11/compatibility-chrono.cc
index fd67dae..efc32f5 100644
--- a/libstdc++-v3/src/c++11/compatibility-chrono.cc
+++ b/libstdc++-v3/src/c++11/compatibility-chrono.cc
@@ -78,7 +78,10 @@  namespace std _GLIBCXX_VISIBILITY(default)
 				 + chrono::microseconds(tv.tv_usec)));
 #else
       std::time_t __sec = std::time(0);
-      return system_clock::from_time_t(__sec);
+      // This is the conversion done by system_clock::from_time_t(__sec)
+      typedef chrono::time_point<system_clock, seconds>	__from;
+      return time_point_cast<system_clock::duration>
+	     (__from(chrono::seconds(__sec)));
 #endif
     }