aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2013-05-24 20:08:42 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2013-05-24 20:08:42 +0200
commit2e8a9734c0bf678c090e7137d7ac8185a7ea08cc (patch)
tree22fc106b86783828d282e19d009658a223244b66 /libstdc++-v3/src
parent7f5d76fb976770ec90deaf562ba7cf566bf9b0be (diff)
downloadgcc-2e8a9734c0bf678c090e7137d7ac8185a7ea08cc.zip
gcc-2e8a9734c0bf678c090e7137d7ac8185a7ea08cc.tar.gz
gcc-2e8a9734c0bf678c090e7137d7ac8185a7ea08cc.tar.bz2
chrono.cc: If _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL, include unistd.h and sys/syscall.h.
* src/c++11/chrono.cc: If _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL, include unistd.h and sys/syscall.h. If _GLIBCXX_COMPATIBILITY_CXX0X, don't define system_clock::is_steady, system_clock::now() and steady_clock::is_steady. (std::chrono::system_clock::now()): If _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL, call syscall (SYS_clock_gettime, ...) instead of clock_gettime (...). (std::chrono::system_clock::now()): Likewise. Add weak attribute if _GLIBCXX_COMPATIBILITY_CXX0X and compatibility-chrono.cc will be non-empty. * src/Makefile.am (cxx11_sources): Add compatibility-chrono.cc. (compatibility-chrono.lo, compatibility-chrono.o): New goals. * src/c++11/compatibility-chrono.cc: New file. * acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): On linux*, check for syscall (SYS_clock_gettime, CLOCK_MONOTONIC, &tp). * testsuite/util/testsuite_abi.cc (check_version): Add GLIBCXX_3.4.20 version and make it the latest. * config/abi/pre/gnu.ver (_ZNSt6chrono12steady_clock3nowEv): Export also @@GLIBCXX_3.4.19. Move all symbols so far added for GCC 4.9 to @@GLIBCXX_3.4.20 instead. * config/abi/post/i386-linux-gnu/baseline_symbols.txt: Regenerated. * config/abi/post/s390x-linux-gnu/baseline_symbols.txt: Regenerated. * config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt: Regenerated. * config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt: Regenerated. * config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Regenerated. * config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt: Regenerated. * config/abi/post/powerpc-linux-gnu/baseline_symbols.txt: Regenerated. * config/abi/post/s390-linux-gnu/baseline_symbols.txt: Regenerated. * config/abi/post/i486-linux-gnu/baseline_symbols.txt: Regenerated. * config/abi/post/solaris2.10/baseline_symbols.txt: Regenerated. * config/abi/post/solaris2.10/amd64/baseline_symbols.txt: Regenerated. * config/abi/post/solaris2.10/sparcv9/baseline_symbols.txt: Regenerated. * config/abi/post/solaris2.9/baseline_symbols.txt: Regenerated. * config/abi/post/solaris2.9/sparcv9/baseline_symbols.txt: Regenerated. * config.h.in: Regenerated. * src/Makefile.in: Regenerated. * configure: Regenerated. From-SVN: r199307
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r--libstdc++-v3/src/Makefile.am8
-rw-r--r--libstdc++-v3/src/Makefile.in10
-rw-r--r--libstdc++-v3/src/c++11/chrono.cc43
-rw-r--r--libstdc++-v3/src/c++11/compatibility-chrono.cc58
4 files changed, 113 insertions, 6 deletions
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index 267a3db..092fd1b 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -50,7 +50,8 @@ cxx98_sources = \
cxx11_sources = \
compatibility-c++0x.cc \
compatibility-atomic-c++0x.cc \
- compatibility-thread-c++0x.cc
+ compatibility-thread-c++0x.cc \
+ compatibility-chrono.cc
libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
@@ -97,6 +98,11 @@ compatibility-thread-c++0x.lo: compatibility-thread-c++0x.cc
compatibility-thread-c++0x.o: compatibility-thread-c++0x.cc
$(CXXCOMPILE) -std=gnu++11 -c $<
+compatibility-chrono.lo: compatibility-chrono.cc
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
+compatibility-chrono.o: compatibility-chrono.cc
+ $(CXXCOMPILE) -std=gnu++11 -c $<
+
# A note on compatibility and static libraries.
#
# static lib == linked against only this version, should not need compat
diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in
index 69001b4..a7b3404 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -93,7 +93,7 @@ am__DEPENDENCIES_1 =
am__objects_2 = compatibility.lo compatibility-debug_list.lo \
compatibility-debug_list-2.lo $(am__objects_1)
am__objects_3 = compatibility-c++0x.lo compatibility-atomic-c++0x.lo \
- compatibility-thread-c++0x.lo
+ compatibility-thread-c++0x.lo compatibility-chrono.lo
am_libstdc___la_OBJECTS = $(am__objects_2) $(am__objects_3)
libstdc___la_OBJECTS = $(am_libstdc___la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
@@ -351,7 +351,8 @@ cxx98_sources = \
cxx11_sources = \
compatibility-c++0x.cc \
compatibility-atomic-c++0x.cc \
- compatibility-thread-c++0x.cc
+ compatibility-thread-c++0x.cc \
+ compatibility-chrono.cc
libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
libstdc___la_LIBADD = \
@@ -848,6 +849,11 @@ compatibility-thread-c++0x.lo: compatibility-thread-c++0x.cc
compatibility-thread-c++0x.o: compatibility-thread-c++0x.cc
$(CXXCOMPILE) -std=gnu++11 -c $<
+compatibility-chrono.lo: compatibility-chrono.cc
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
+compatibility-chrono.o: compatibility-chrono.cc
+ $(CXXCOMPILE) -std=gnu++11 -c $<
+
# Symbol versioning for shared libraries.
@ENABLE_SYMVERS_TRUE@libstdc++-symbols.ver: ${glibcxx_srcdir}/$(SYMVER_FILE) \
@ENABLE_SYMVERS_TRUE@ $(port_specific_symbol_files)
diff --git a/libstdc++-v3/src/c++11/chrono.cc b/libstdc++-v3/src/c++11/chrono.cc
index b45825e..15de4eb 100644
--- a/libstdc++-v3/src/c++11/chrono.cc
+++ b/libstdc++-v3/src/c++11/chrono.cc
@@ -22,7 +22,20 @@
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
+#include <bits/c++config.h>
+
+#ifndef _GLIBCXX_USE_CLOCK_MONOTONIC
+// If !_GLIBCXX_USE_CLOCK_MONOTONIC, std::chrono::steady_clock
+// is just a typedef to std::chrono::system_clock, for ABI compatibility
+// force it not to be a typedef now and export it anyway. Programs
+// using the headers where it is a typedef will actually just use
+// std::chrono::system_clock instead, and this remains here just as a fallback.
+#define _GLIBCXX_USE_CLOCK_MONOTONIC
+#include <chrono>
+#undef _GLIBCXX_USE_CLOCK_MONOTONIC
+#else
#include <chrono>
+#endif
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
@@ -32,13 +45,18 @@
defined(_GLIBCXX_USE_GETTIMEOFDAY)
#include <sys/time.h>
#endif
+#ifdef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL
+#include <unistd.h>
+#include <sys/syscall.h>
+#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace chrono
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
+
+#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
constexpr bool system_clock::is_steady;
system_clock::time_point
@@ -47,7 +65,11 @@ namespace std _GLIBCXX_VISIBILITY(default)
#ifdef _GLIBCXX_USE_CLOCK_REALTIME
timespec tp;
// -EINVAL, -EFAULT
+#ifdef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL
+ syscall(SYS_clock_gettime, CLOCK_REALTIME, &tp);
+#else
clock_gettime(CLOCK_REALTIME, &tp);
+#endif
return time_point(duration(chrono::seconds(tp.tv_sec)
+ chrono::nanoseconds(tp.tv_nsec)));
#elif defined(_GLIBCXX_USE_GETTIMEOFDAY)
@@ -61,20 +83,35 @@ namespace std _GLIBCXX_VISIBILITY(default)
return system_clock::from_time_t(__sec);
#endif
}
+#endif
-#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
+#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
constexpr bool steady_clock::is_steady;
+#endif
+#if defined(_GLIBCXX_SYMVER_GNU) && defined(_GLIBCXX_SHARED) \
+ && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE) \
+ && defined(_GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT) \
+ && !defined(_GLIBCXX_COMPATIBILITY_CXX0X)
+ __attribute__((__weak__))
+#endif
steady_clock::time_point
steady_clock::now() noexcept
{
+#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
timespec tp;
// -EINVAL, -EFAULT
+#ifdef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL
+ syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &tp);
+#else
clock_gettime(CLOCK_MONOTONIC, &tp);
+#endif
return time_point(duration(chrono::seconds(tp.tv_sec)
+ chrono::nanoseconds(tp.tv_nsec)));
- }
+#else
+ return time_point(system_clock::now().time_since_epoch());
#endif
+ }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace chrono
diff --git a/libstdc++-v3/src/c++11/compatibility-chrono.cc b/libstdc++-v3/src/c++11/compatibility-chrono.cc
new file mode 100644
index 0000000..ada0946
--- /dev/null
+++ b/libstdc++-v3/src/c++11/compatibility-chrono.cc
@@ -0,0 +1,58 @@
+// Compatibility symbols for previous versions, C++0x bits -*- C++ -*-
+
+// Copyright (C) 2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+#define _GLIBCXX_COMPATIBILITY_CXX0X
+#include <bits/c++config.h>
+
+#if defined(_GLIBCXX_SYMVER_GNU) && defined(_GLIBCXX_SHARED) \
+ && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE)\
+ && defined(_GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT)
+
+#define steady_clock steady_clockXX
+#include "chrono.cc"
+
+// The rename syntax for default exported names is
+// asm (".symver name1,exportedname@GLIBCXX_3.4.17")
+// asm (".symver name2,exportedname@@GLIBCXX_3.4.19")
+// In the future, GLIBCXX_ABI > 6 should remove all uses of
+// _GLIBCXX_*_SYMVER macros in this file.
+
+#define _GLIBCXX_3_4_17_SYMVER(XXname, name) \
+ extern "C" void \
+ _X##name() \
+ __attribute__ ((alias(#XXname))); \
+ asm (".symver " "_X" #name "," #name "@GLIBCXX_3.4.17");
+
+#define _GLIBCXX_3_4_19_SYMVER(XXname, name) \
+ extern "C" void \
+ _Y##name() \
+ __attribute__ ((alias(#XXname))); \
+ asm (".symver " "_Y" #name "," #name "@@GLIBCXX_3.4.19");
+
+_GLIBCXX_3_4_17_SYMVER(_ZNSt6chrono14steady_clockXX3nowEv,
+ _ZNSt6chrono12steady_clock3nowEv)
+_GLIBCXX_3_4_19_SYMVER(_ZNSt6chrono14steady_clockXX3nowEv,
+ _ZNSt6chrono12steady_clock3nowEv)
+
+#endif