diff options
author | Chris Fairles <chris.fairles@gmail.com> | 2008-07-15 23:23:23 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2008-07-15 23:23:23 +0000 |
commit | 15e38d0dce922e77304932817a10f1f42579553f (patch) | |
tree | eafc38353a48e1cd63e574edc380874a144179ef /libstdc++-v3/src | |
parent | 141368f01df366809a596c6093825d205835c86b (diff) | |
download | gcc-15e38d0dce922e77304932817a10f1f42579553f.zip gcc-15e38d0dce922e77304932817a10f1f42579553f.tar.gz gcc-15e38d0dce922e77304932817a10f1f42579553f.tar.bz2 |
chrono: New, as per N2661.
2008-07-15 Chris Fairles <chris.fairles@gmail.com>
* include/std/chrono: New, as per N2661.
* src/chrono.cc: New.
* include/Makefile.am: Update.
* src/Makefile.am: Likewise.
* include/Makefile.in: Regenerate.
* src/Makefile.in: Likewise.
* acinclude.m4: Add tests for clock_gettime and gettimeofday that
define _GLIBCXX_HAS_CLOCK_GETTIME and/or _GLIBCXX_HAS_GETTIMEOFDAY.
* configure.ac: Use them.
* configure: Regenerate.
* config.h.in: Likewise.
* config/abi/pre/gnu.ver: Add symbols for system_clock::now() and
system_clock::is_monotonic.
* testsuite/20_util/duration/cons/1.cc: New.
* testsuite/20_util/duration/cons/2.cc: Likewise.
* testsuite/20_util/duration/cons/1_neg.cc: Likewise.
* testsuite/20_util/duration/requirements/explicit_instantiation/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/duration/arithmetic/1.cc: Likewise.
* testsuite/20_util/duration/arithmetic/2.cc: Likewise.
* testsuite/20_util/duration/comparisons/1.cc: Likewise.
* testsuite/20_util/time_point/requirements/explicit_instantiation/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/time_point/1.cc: Likewise.
* testsuite/20_util/time_point/2.cc: Likewise.
* testsuite/20_util/time_point/3.cc: Likewise.
* testsuite/20_util/clocks/1.cc: Likewise.
* testsuite/17_intro/headers/c++200x/all_multiple_inclusion.cc: Add
missing headers.
* testsuite/17_intro/headers/c++200x/all.cc: Likewise.
* include/precompiled/stdc++.h: Likewise and remove <date_time>.
* doc/doxygen/user.cfg.in: Likewise.
From-SVN: r137858
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r-- | libstdc++-v3/src/Makefile.am | 6 | ||||
-rw-r--r-- | libstdc++-v3/src/Makefile.in | 16 | ||||
-rw-r--r-- | libstdc++-v3/src/chrono.cc | 76 |
3 files changed, 93 insertions, 5 deletions
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am index 8d2cbf5..d41f3eb 100644 --- a/libstdc++-v3/src/Makefile.am +++ b/libstdc++-v3/src/Makefile.am @@ -186,6 +186,7 @@ sources = \ wstring-inst.cc \ mutex.cc \ condition_variable.cc \ + chrono.cc \ ${host_sources} \ ${host_sources_extra} @@ -272,6 +273,11 @@ atomic.lo: atomic.cc atomic.o: atomic.cc $(CXXCOMPILE) -x c++ -std=gnu++0x -c $< +chrono.lo: chrono.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +chrono.o: chrono.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + if GLIBCXX_LDBL_COMPAT # Use special rules for compatibility-ldbl.cc compilation, as we need to # pass -mlong-double-64. diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in index f0e9897..27c9b70 100644 --- a/libstdc++-v3/src/Makefile.in +++ b/libstdc++-v3/src/Makefile.in @@ -84,10 +84,10 @@ am__libstdc___la_SOURCES_DIST = atomic.cc bitmap_allocator.cc \ istream-inst.cc istream.cc locale-inst.cc misc-inst.cc \ ostream-inst.cc sstream-inst.cc streambuf-inst.cc streambuf.cc \ string-inst.cc valarray-inst.cc wlocale-inst.cc \ - wstring-inst.cc mutex.cc condition_variable.cc atomicity.cc \ - codecvt_members.cc collate_members.cc ctype_members.cc \ - messages_members.cc monetary_members.cc numeric_members.cc \ - time_members.cc basic_file.cc c++locale.cc \ + wstring-inst.cc mutex.cc condition_variable.cc chrono.cc \ + atomicity.cc codecvt_members.cc collate_members.cc \ + ctype_members.cc messages_members.cc monetary_members.cc \ + numeric_members.cc time_members.cc basic_file.cc c++locale.cc \ compatibility-ldbl.cc parallel_list.cc parallel_settings.cc am__objects_1 = atomicity.lo codecvt_members.lo collate_members.lo \ ctype_members.lo messages_members.lo monetary_members.lo \ @@ -109,7 +109,7 @@ am__objects_5 = atomic.lo bitmap_allocator.lo pool_allocator.lo \ istream-inst.lo istream.lo locale-inst.lo misc-inst.lo \ ostream-inst.lo sstream-inst.lo streambuf-inst.lo streambuf.lo \ string-inst.lo valarray-inst.lo wlocale-inst.lo \ - wstring-inst.lo mutex.lo condition_variable.lo \ + wstring-inst.lo mutex.lo condition_variable.lo chrono.lo \ $(am__objects_1) $(am__objects_4) am_libstdc___la_OBJECTS = $(am__objects_5) libstdc___la_OBJECTS = $(am_libstdc___la_OBJECTS) @@ -422,6 +422,7 @@ sources = \ wstring-inst.cc \ mutex.cc \ condition_variable.cc \ + chrono.cc \ ${host_sources} \ ${host_sources_extra} @@ -866,6 +867,11 @@ atomic.lo: atomic.cc atomic.o: atomic.cc $(CXXCOMPILE) -x c++ -std=gnu++0x -c $< +chrono.lo: chrono.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +chrono.o: chrono.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + # Use special rules for compatibility-ldbl.cc compilation, as we need to # pass -mlong-double-64. @GLIBCXX_LDBL_COMPAT_TRUE@compatibility-ldbl.lo: compatibility-ldbl.cc diff --git a/libstdc++-v3/src/chrono.cc b/libstdc++-v3/src/chrono.cc new file mode 100644 index 0000000..88fb4c1 --- /dev/null +++ b/libstdc++-v3/src/chrono.cc @@ -0,0 +1,76 @@ +// chrono -*- C++ -*- + +// Copyright (C) 2008 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 2, 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include <chrono> + +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + +// conditional inclusion of sys/time.h for gettimeofday +#if !defined(_GLIBCXX_USE_CLOCK_MONOTONIC) && \ + !defined(_GLIBCXX_USE_CLOCK_REALTIME) && \ + defined(_GLIBCXX_USE_GETTIMEOFDAY) +#include <sys/time.h> +#endif + +namespace std +{ + namespace chrono + { + const bool system_clock::is_monotonic; + + system_clock::time_point + system_clock::now() + { +#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC + timespec tp; + // -EINVAL, -EFAULT + clock_gettime(CLOCK_MONOTONIC, &tp); + return time_point(duration(chrono::seconds(tp.tv_sec) + + chrono::nanoseconds(tp.tv_nsec))); +#elif defined(_GLIBCXX_USE_CLOCK_REALTIME) + timespec tp; + // -EINVAL, -EFAULT + clock_gettime(CLOCK_REALTIME, &tp); + return time_point(duration(chrono::seconds(tp.tv_sec) + + chrono::nanoseconds(tp.tv_nsec))); +#elif defined(_GLIBCXX_USE_GETTIMEOFDAY) + timeval tv; + // EINVAL, EFAULT + gettimeofday(&tv, NULL); + return time_point(duration(chrono::seconds(tv.tv_sec) + + chrono::microseconds(tv.tv_usec))); +#else + std::time_t __sec = std::time(0); + return system_clock::from_time_t(__sec); +#endif + } + } +} + +#endif // _GLIBCXX_USE_C99_STDINT_TR1 |