mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-19 15:11:08 +08:00
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
This commit is contained in:
parent
141368f01d
commit
15e38d0dce
libstdc++-v3
ChangeLogacinclude.m4config.h.in
config/abi/pre
configureconfigure.acdoc/doxygen
include
src
testsuite
17_intro/headers/c++200x
20_util
@ -1,3 +1,38 @@
|
||||
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.
|
||||
|
||||
2008-07-15 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR libstdc++/36832
|
||||
|
@ -1008,6 +1008,94 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
|
||||
])
|
||||
|
||||
|
||||
dnl
|
||||
dnl Check for IEEE Std 1003.1-2001 clock_gettime required for
|
||||
dnl 20.8.5 [time.clock] in the current C++0X working draft.
|
||||
dnl
|
||||
AC_DEFUN([GLIBCXX_CHECK_CLOCK_GETTIME], [
|
||||
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS -fno-exceptions"
|
||||
|
||||
AC_CHECK_HEADERS(unistd.h, ac_has_unistd_h=yes, ac_has_unistd_h=no)
|
||||
|
||||
ac_has_clock_monotonic=no;
|
||||
ac_has_clock_realtime=no;
|
||||
if test x"$ac_has_unistd_h" = x"yes"; then
|
||||
AC_MSG_CHECKING([for monotonic clock])
|
||||
AC_TRY_LINK(
|
||||
[#include <unistd.h>
|
||||
#include <time.h>
|
||||
],
|
||||
[#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
|
||||
timespec tp;
|
||||
#endif
|
||||
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||
], [ac_has_clock_monotonic=yes], [ac_has_clock_monotonic=no])
|
||||
|
||||
AC_MSG_RESULT($ac_has_clock_monotonic)
|
||||
|
||||
AC_MSG_CHECKING([for realtime clock])
|
||||
AC_TRY_LINK(
|
||||
[#include <unistd.h>
|
||||
#include <time.h>
|
||||
],
|
||||
[#if _POSIX_TIMERS > 0
|
||||
timespec tp;
|
||||
#endif
|
||||
clock_gettime(CLOCK_REALTIME, &tp);
|
||||
], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no])
|
||||
|
||||
AC_MSG_RESULT($ac_has_clock_realtime)
|
||||
fi
|
||||
|
||||
if test x"$ac_has_clock_monotonic" = x"yes"; then
|
||||
AC_DEFINE(_GLIBCXX_USE_CLOCK_MONOTONIC, 1,
|
||||
[ Defined if clock_gettime has monotonic clock support. ])
|
||||
fi
|
||||
|
||||
if test x"$ac_has_clock_realtime" = x"yes"; then
|
||||
AC_DEFINE(_GLIBCXX_USE_CLOCK_REALTIME, 1,
|
||||
[ Defined if clock_gettime has realtime clock support. ])
|
||||
fi
|
||||
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Check for IEEE Std 1003.1-2001 gettimeofday required for
|
||||
dnl 20.8.5 [time.clock] in the current C++0X working draft.
|
||||
dnl
|
||||
AC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [
|
||||
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS -fno-exceptions"
|
||||
|
||||
ac_has_gettimeofday=no;
|
||||
AC_CHECK_HEADERS(sys/time.h, ac_has_sys_time_h=yes, ac_has_sys_time_h=no)
|
||||
if test x"$ac_has_sys_time_h" = x"yes"; then
|
||||
AC_MSG_CHECKING([for gettimeofday])
|
||||
AC_TRY_LINK([#include <sys/time.h>],
|
||||
[timeval tv; gettimeofday(&tv, 0);],
|
||||
[ac_has_gettimeofday=yes], [ac_has_gettimeofday=no])
|
||||
|
||||
AC_MSG_RESULT($ac_has_gettimeofday)
|
||||
fi
|
||||
|
||||
if test x"$ac_has_gettimeofday" = x"yes"; then
|
||||
AC_DEFINE(_GLIBCXX_USE_GETTIMEOFDAY, 1,
|
||||
[ Defined if gettimeofday is available. ])
|
||||
fi
|
||||
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Check for ISO/IEC 9899:1999 "C99" support to ISO/IEC DTR 19768 "TR1"
|
||||
dnl facilities in Chapter 8, "C compatibility".
|
||||
|
@ -811,6 +811,15 @@
|
||||
namespace std::tr1. */
|
||||
#undef _GLIBCXX_USE_C99_STDINT_TR1
|
||||
|
||||
/* Defined if clock_gettime has monotonic clock support. */
|
||||
#undef _GLIBCXX_USE_CLOCK_MONOTONIC
|
||||
|
||||
/* Defined if clock_gettime has realtime clock support. */
|
||||
#undef _GLIBCXX_USE_CLOCK_REALTIME
|
||||
|
||||
/* Defined if gettimeofday is available. */
|
||||
#undef _GLIBCXX_USE_GETTIMEOFDAY
|
||||
|
||||
/* Define if LFS support is available. */
|
||||
#undef _GLIBCXX_USE_LFS
|
||||
|
||||
|
@ -885,6 +885,10 @@ GLIBCXX_3.4.11 {
|
||||
# char16_t and char32_t
|
||||
_ZNSt14numeric_limitsIu8char*;
|
||||
|
||||
# chrono
|
||||
_ZNSt6chrono12system_clock12is_monotonicE;
|
||||
_ZNSt6chrono12system_clock3nowEv;
|
||||
|
||||
} GLIBCXX_3.4.10;
|
||||
|
||||
# Symbols in the support library (libsupc++) have their own tag.
|
||||
|
565
libstdc++-v3/configure
vendored
565
libstdc++-v3/configure
vendored
@ -40947,6 +40947,571 @@ _ACEOF
|
||||
|
||||
|
||||
|
||||
# For clock_gettime support.
|
||||
|
||||
|
||||
|
||||
|
||||
ac_ext=cc
|
||||
ac_cpp='$CXXCPP $CPPFLAGS'
|
||||
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
|
||||
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||
|
||||
ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS -fno-exceptions"
|
||||
|
||||
|
||||
for ac_header in unistd.h
|
||||
do
|
||||
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||
if eval "test \"\${$as_ac_Header+set}\" = set"; then
|
||||
echo "$as_me:$LINENO: checking for $ac_header" >&5
|
||||
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
|
||||
if eval "test \"\${$as_ac_Header+set}\" = set"; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
|
||||
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
|
||||
else
|
||||
# Is the header compilable?
|
||||
echo "$as_me:$LINENO: checking $ac_header usability" >&5
|
||||
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
$ac_includes_default
|
||||
#include <$ac_header>
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
|
||||
(eval $ac_compile) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_cxx_werror_flag"
|
||||
|| test ! -s conftest.err'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest.$ac_objext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
ac_header_compiler=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_header_compiler=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
|
||||
echo "${ECHO_T}$ac_header_compiler" >&6
|
||||
|
||||
# Is the header present?
|
||||
echo "$as_me:$LINENO: checking $ac_header presence" >&5
|
||||
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
#include <$ac_header>
|
||||
_ACEOF
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
|
||||
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } >/dev/null; then
|
||||
if test -s conftest.err; then
|
||||
ac_cpp_err=$ac_cxx_preproc_warn_flag
|
||||
ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
|
||||
else
|
||||
ac_cpp_err=
|
||||
fi
|
||||
else
|
||||
ac_cpp_err=yes
|
||||
fi
|
||||
if test -z "$ac_cpp_err"; then
|
||||
ac_header_preproc=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_header_preproc=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_ext
|
||||
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
|
||||
echo "${ECHO_T}$ac_header_preproc" >&6
|
||||
|
||||
# So? What about this header?
|
||||
case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in
|
||||
yes:no: )
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
|
||||
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
|
||||
echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
|
||||
ac_header_preproc=yes
|
||||
;;
|
||||
no:yes:* )
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
|
||||
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
|
||||
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
|
||||
echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
|
||||
echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
|
||||
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
||||
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||
(
|
||||
cat <<\_ASBOX
|
||||
## ----------------------------------------- ##
|
||||
## Report this to the package-unused lists. ##
|
||||
## ----------------------------------------- ##
|
||||
_ASBOX
|
||||
) |
|
||||
sed "s/^/$as_me: WARNING: /" >&2
|
||||
;;
|
||||
esac
|
||||
echo "$as_me:$LINENO: checking for $ac_header" >&5
|
||||
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
|
||||
if eval "test \"\${$as_ac_Header+set}\" = set"; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
eval "$as_ac_Header=\$ac_header_preproc"
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
|
||||
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
|
||||
|
||||
fi
|
||||
if test `eval echo '${'$as_ac_Header'}'` = yes; then
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
|
||||
_ACEOF
|
||||
ac_has_unistd_h=yes
|
||||
else
|
||||
ac_has_unistd_h=no
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
ac_has_clock_monotonic=no;
|
||||
ac_has_clock_realtime=no;
|
||||
if test x"$ac_has_unistd_h" = x"yes"; then
|
||||
echo "$as_me:$LINENO: checking for monotonic clock" >&5
|
||||
echo $ECHO_N "checking for monotonic clock... $ECHO_C" >&6
|
||||
if test x$gcc_no_link = xyes; then
|
||||
{ { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5
|
||||
echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
|
||||
timespec tp;
|
||||
#endif
|
||||
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
||||
(eval $ac_link) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_cxx_werror_flag"
|
||||
|| test ! -s conftest.err'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest$ac_exeext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
ac_has_clock_monotonic=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_has_clock_monotonic=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
|
||||
echo "$as_me:$LINENO: result: $ac_has_clock_monotonic" >&5
|
||||
echo "${ECHO_T}$ac_has_clock_monotonic" >&6
|
||||
|
||||
echo "$as_me:$LINENO: checking for realtime clock" >&5
|
||||
echo $ECHO_N "checking for realtime clock... $ECHO_C" >&6
|
||||
if test x$gcc_no_link = xyes; then
|
||||
{ { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5
|
||||
echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
#if _POSIX_TIMERS > 0
|
||||
timespec tp;
|
||||
#endif
|
||||
clock_gettime(CLOCK_REALTIME, &tp);
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
||||
(eval $ac_link) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_cxx_werror_flag"
|
||||
|| test ! -s conftest.err'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest$ac_exeext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
ac_has_clock_realtime=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_has_clock_realtime=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
|
||||
echo "$as_me:$LINENO: result: $ac_has_clock_realtime" >&5
|
||||
echo "${ECHO_T}$ac_has_clock_realtime" >&6
|
||||
fi
|
||||
|
||||
if test x"$ac_has_clock_monotonic" = x"yes"; then
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define _GLIBCXX_USE_CLOCK_MONOTONIC 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
if test x"$ac_has_clock_realtime" = x"yes"; then
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define _GLIBCXX_USE_CLOCK_REALTIME 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||
ac_ext=c
|
||||
ac_cpp='$CPP $CPPFLAGS'
|
||||
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
|
||||
ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||
|
||||
|
||||
|
||||
# For gettimeofday support.
|
||||
|
||||
|
||||
|
||||
|
||||
ac_ext=cc
|
||||
ac_cpp='$CXXCPP $CPPFLAGS'
|
||||
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
|
||||
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||
|
||||
ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS -fno-exceptions"
|
||||
|
||||
ac_has_gettimeofday=no;
|
||||
|
||||
for ac_header in sys/time.h
|
||||
do
|
||||
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||
if eval "test \"\${$as_ac_Header+set}\" = set"; then
|
||||
echo "$as_me:$LINENO: checking for $ac_header" >&5
|
||||
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
|
||||
if eval "test \"\${$as_ac_Header+set}\" = set"; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
|
||||
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
|
||||
else
|
||||
# Is the header compilable?
|
||||
echo "$as_me:$LINENO: checking $ac_header usability" >&5
|
||||
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
$ac_includes_default
|
||||
#include <$ac_header>
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
|
||||
(eval $ac_compile) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_cxx_werror_flag"
|
||||
|| test ! -s conftest.err'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest.$ac_objext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
ac_header_compiler=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_header_compiler=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
|
||||
echo "${ECHO_T}$ac_header_compiler" >&6
|
||||
|
||||
# Is the header present?
|
||||
echo "$as_me:$LINENO: checking $ac_header presence" >&5
|
||||
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
#include <$ac_header>
|
||||
_ACEOF
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
|
||||
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } >/dev/null; then
|
||||
if test -s conftest.err; then
|
||||
ac_cpp_err=$ac_cxx_preproc_warn_flag
|
||||
ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
|
||||
else
|
||||
ac_cpp_err=
|
||||
fi
|
||||
else
|
||||
ac_cpp_err=yes
|
||||
fi
|
||||
if test -z "$ac_cpp_err"; then
|
||||
ac_header_preproc=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_header_preproc=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_ext
|
||||
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
|
||||
echo "${ECHO_T}$ac_header_preproc" >&6
|
||||
|
||||
# So? What about this header?
|
||||
case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in
|
||||
yes:no: )
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
|
||||
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
|
||||
echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
|
||||
ac_header_preproc=yes
|
||||
;;
|
||||
no:yes:* )
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
|
||||
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
|
||||
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
|
||||
echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
|
||||
echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
|
||||
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
||||
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||
(
|
||||
cat <<\_ASBOX
|
||||
## ----------------------------------------- ##
|
||||
## Report this to the package-unused lists. ##
|
||||
## ----------------------------------------- ##
|
||||
_ASBOX
|
||||
) |
|
||||
sed "s/^/$as_me: WARNING: /" >&2
|
||||
;;
|
||||
esac
|
||||
echo "$as_me:$LINENO: checking for $ac_header" >&5
|
||||
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
|
||||
if eval "test \"\${$as_ac_Header+set}\" = set"; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
eval "$as_ac_Header=\$ac_header_preproc"
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
|
||||
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
|
||||
|
||||
fi
|
||||
if test `eval echo '${'$as_ac_Header'}'` = yes; then
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
|
||||
_ACEOF
|
||||
ac_has_sys_time_h=yes
|
||||
else
|
||||
ac_has_sys_time_h=no
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
if test x"$ac_has_sys_time_h" = x"yes"; then
|
||||
echo "$as_me:$LINENO: checking for gettimeofday" >&5
|
||||
echo $ECHO_N "checking for gettimeofday... $ECHO_C" >&6
|
||||
if test x$gcc_no_link = xyes; then
|
||||
{ { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5
|
||||
echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
#include <sys/time.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
timeval tv; gettimeofday(&tv, 0);
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
||||
(eval $ac_link) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_cxx_werror_flag"
|
||||
|| test ! -s conftest.err'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest$ac_exeext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
ac_has_gettimeofday=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_has_gettimeofday=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
|
||||
echo "$as_me:$LINENO: result: $ac_has_gettimeofday" >&5
|
||||
echo "${ECHO_T}$ac_has_gettimeofday" >&6
|
||||
fi
|
||||
|
||||
if test x"$ac_has_gettimeofday" = x"yes"; then
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define _GLIBCXX_USE_GETTIMEOFDAY 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||
ac_ext=c
|
||||
ac_cpp='$CPP $CPPFLAGS'
|
||||
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
|
||||
ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||
|
||||
|
||||
|
||||
# For TLS support.
|
||||
|
||||
# Check whether --enable-tls or --disable-tls was given.
|
||||
|
@ -161,6 +161,12 @@ if $GLIBCXX_IS_NATIVE; then
|
||||
# For dev/random and dev/urandom for TR1.
|
||||
GLIBCXX_CHECK_RANDOM_TR1
|
||||
|
||||
# For clock_gettime support.
|
||||
GLIBCXX_CHECK_CLOCK_GETTIME
|
||||
|
||||
# For gettimeofday support.
|
||||
GLIBCXX_CHECK_GETTIMEOFDAY
|
||||
|
||||
# For TLS support.
|
||||
GCC_CHECK_TLS
|
||||
|
||||
|
@ -468,8 +468,8 @@ INPUT = @srcdir@/libsupc++/cxxabi.h \
|
||||
include/algorithm \
|
||||
include/array \
|
||||
include/bitset \
|
||||
include/chrono \
|
||||
include/condition_variable \
|
||||
include/date_time \
|
||||
include/deque \
|
||||
include/fstream \
|
||||
include/functional \
|
||||
@ -489,6 +489,7 @@ INPUT = @srcdir@/libsupc++/cxxabi.h \
|
||||
include/ostream \
|
||||
include/queue \
|
||||
include/random \
|
||||
include/ratio \
|
||||
include/regex \
|
||||
include/set \
|
||||
include/sstream \
|
||||
|
@ -32,6 +32,7 @@ std_headers = \
|
||||
${std_srcdir}/array \
|
||||
${std_srcdir}/bitset \
|
||||
${std_srcdir}/c++0x_warning.h \
|
||||
${std_srcdir}/chrono \
|
||||
${std_srcdir}/complex \
|
||||
${std_srcdir}/condition_variable \
|
||||
${std_srcdir}/deque \
|
||||
|
@ -285,6 +285,7 @@ std_headers = \
|
||||
${std_srcdir}/array \
|
||||
${std_srcdir}/bitset \
|
||||
${std_srcdir}/c++0x_warning.h \
|
||||
${std_srcdir}/chrono \
|
||||
${std_srcdir}/complex \
|
||||
${std_srcdir}/condition_variable \
|
||||
${std_srcdir}/deque \
|
||||
|
@ -98,8 +98,9 @@
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
#include <array>
|
||||
#include <date_time>
|
||||
#include <chrono>
|
||||
#include <random>
|
||||
#include <ratio>
|
||||
#include <regex>
|
||||
#include <system_error>
|
||||
#include <tuple>
|
||||
|
626
libstdc++-v3/include/std/chrono
Normal file
626
libstdc++-v3/include/std/chrono
Normal file
@ -0,0 +1,626 @@
|
||||
// <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.
|
||||
|
||||
/** @file include/chrono
|
||||
* This is a Standard C++ Library header.
|
||||
*/
|
||||
|
||||
#ifndef _GLIBCXX_CHRONO
|
||||
#define _GLIBCXX_CHRONO 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#ifndef __GXX_EXPERIMENTAL_CXX0X__
|
||||
# include <c++0x_warning.h>
|
||||
#else
|
||||
|
||||
#ifdef _GLIBCXX_INCLUDE_AS_TR1
|
||||
# error C++0x header cannot be included from TR1 header
|
||||
#endif
|
||||
|
||||
#include <ratio>
|
||||
#include <type_traits>
|
||||
#include <limits>
|
||||
#include <ctime>
|
||||
|
||||
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
|
||||
|
||||
namespace std
|
||||
{
|
||||
namespace chrono
|
||||
{
|
||||
template<typename _Rep, typename _Period = ratio<1>>
|
||||
struct duration;
|
||||
|
||||
template<typename _Clock, typename _Duration = typename _Clock::duration>
|
||||
struct time_point;
|
||||
}
|
||||
|
||||
// 20.8.2.3 specialization of common_type (for duration)
|
||||
template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
|
||||
struct common_type<chrono::duration<_Rep1, _Period1>,
|
||||
chrono::duration<_Rep2, _Period2>>
|
||||
{
|
||||
typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type,
|
||||
ratio<__static_gcd<_Period1::num, _Period2::num>::value,
|
||||
(_Period1::den / __static_gcd<_Period1::den, _Period2::den>::value)
|
||||
* _Period2::den>> type;
|
||||
};
|
||||
|
||||
// 20.8.2.3 specialization of common_type (for time_point)
|
||||
template<typename _Clock, typename _Duration1, typename _Duration2>
|
||||
struct common_type<chrono::time_point<_Clock, _Duration1>,
|
||||
chrono::time_point<_Clock, _Duration2>>
|
||||
{
|
||||
typedef chrono::time_point<_Clock,
|
||||
typename common_type<_Duration1, _Duration2>::type> type;
|
||||
};
|
||||
|
||||
namespace chrono
|
||||
{
|
||||
// primary template for duration_cast impl.
|
||||
template<typename _ToDuration, typename _CF, typename _CR,
|
||||
bool _NumIsOne = false, bool _DenIsOne = false>
|
||||
struct __duration_cast_impl
|
||||
{
|
||||
template<typename _Rep, typename _Period>
|
||||
static _ToDuration __cast(const duration<_Rep, _Period>& __d)
|
||||
{
|
||||
return _ToDuration(static_cast<
|
||||
typename _ToDuration::rep>(static_cast<_CR>(__d.count())
|
||||
* static_cast<_CR>(_CF::num)
|
||||
/ static_cast<_CR>(_CF::den)));
|
||||
}
|
||||
};
|
||||
|
||||
template<typename _ToDuration, typename _CF, typename _CR>
|
||||
struct __duration_cast_impl<_ToDuration, _CF, _CR, true, true>
|
||||
{
|
||||
template<typename _Rep, typename _Period>
|
||||
static _ToDuration __cast(const duration<_Rep, _Period>& __d)
|
||||
{
|
||||
return _ToDuration(
|
||||
static_cast<typename _ToDuration::rep>(__d.count()));
|
||||
}
|
||||
};
|
||||
|
||||
template<typename _ToDuration, typename _CF, typename _CR>
|
||||
struct __duration_cast_impl<_ToDuration, _CF, _CR, true, false>
|
||||
{
|
||||
template<typename _Rep, typename _Period>
|
||||
static _ToDuration __cast(const duration<_Rep, _Period>& __d)
|
||||
{
|
||||
return _ToDuration(static_cast<typename _ToDuration::rep>(
|
||||
static_cast<_CR>(__d.count()) / static_cast<_CR>(_CF::den)));
|
||||
}
|
||||
};
|
||||
|
||||
template<typename _ToDuration, typename _CF, typename _CR>
|
||||
struct __duration_cast_impl<_ToDuration, _CF, _CR, false, true>
|
||||
{
|
||||
template<typename _Rep, typename _Period>
|
||||
static _ToDuration __cast(const duration<_Rep, _Period>& __d)
|
||||
{
|
||||
return _ToDuration(static_cast<typename _ToDuration::rep>(
|
||||
static_cast<_CR>(__d.count()) * static_cast<_CR>(_CF::num)));
|
||||
}
|
||||
};
|
||||
|
||||
template<typename _ToDuration, typename _Rep, typename _Period>
|
||||
inline _ToDuration
|
||||
duration_cast(const duration<_Rep, _Period>& __d)
|
||||
{
|
||||
typedef typename
|
||||
ratio_divide<_Period, typename _ToDuration::period>::type __cf;
|
||||
typedef typename
|
||||
common_type<typename _ToDuration::rep, _Rep, intmax_t>::type __cr;
|
||||
|
||||
return __duration_cast_impl<_ToDuration, __cf, __cr,
|
||||
__cf::num == 1, __cf::den == 1>::__cast(__d);
|
||||
}
|
||||
|
||||
template<typename _Rep>
|
||||
struct treat_as_floating_point
|
||||
: is_floating_point<_Rep>
|
||||
{ };
|
||||
|
||||
template<typename _Rep>
|
||||
struct duration_values
|
||||
{
|
||||
static const _Rep
|
||||
zero()
|
||||
{ return _Rep(0); }
|
||||
|
||||
static const _Rep
|
||||
max()
|
||||
{ return numeric_limits<_Rep>::max(); }
|
||||
|
||||
static const _Rep
|
||||
min()
|
||||
{ return numeric_limits<_Rep>::min(); }
|
||||
};
|
||||
|
||||
template<typename _Rep, typename _Period>
|
||||
struct duration
|
||||
{
|
||||
static_assert(_Period::num > 0, "period must be positive");
|
||||
|
||||
typedef _Rep rep;
|
||||
typedef _Period period;
|
||||
|
||||
// construction / destruction
|
||||
duration ()
|
||||
: __r(rep(0))
|
||||
{ }
|
||||
|
||||
template<typename _Rep2>
|
||||
explicit duration(_Rep2 const& __rep)
|
||||
: __r(static_cast<rep>(__rep))
|
||||
{
|
||||
static_assert(is_convertible<_Rep2,rep>::value == true
|
||||
&& (treat_as_floating_point<rep>::value == true
|
||||
|| (!treat_as_floating_point<rep>::value
|
||||
&& !treat_as_floating_point<_Rep2>::value)),
|
||||
"cannot construct integral duration with floating point type");
|
||||
}
|
||||
|
||||
duration(const duration& __d)
|
||||
: __r(__d.count())
|
||||
{ }
|
||||
|
||||
// conversions
|
||||
template<typename _Rep2, typename _Period2>
|
||||
duration(const duration<_Rep2, _Period2>& __d)
|
||||
: __r(duration_cast<duration>(__d).count())
|
||||
{
|
||||
static_assert(treat_as_floating_point<rep>::value == true
|
||||
|| ratio_divide<_Period2, period>::type::den == 1,
|
||||
"the resulting duration is not exactly representable");
|
||||
}
|
||||
|
||||
// observer
|
||||
rep
|
||||
count() const
|
||||
{ return __r; }
|
||||
|
||||
// arithmetic
|
||||
duration
|
||||
operator+() const
|
||||
{ return *this; }
|
||||
|
||||
duration
|
||||
operator-() const
|
||||
{ return duration(-__r); }
|
||||
|
||||
duration&
|
||||
operator++()
|
||||
{
|
||||
++__r;
|
||||
return *this;
|
||||
}
|
||||
|
||||
duration
|
||||
operator++(int)
|
||||
{ return duration(__r++); }
|
||||
|
||||
duration&
|
||||
operator--()
|
||||
{
|
||||
--__r;
|
||||
return *this;
|
||||
}
|
||||
|
||||
duration
|
||||
operator--(int)
|
||||
{ return duration(__r--); }
|
||||
|
||||
duration&
|
||||
operator+=(const duration& __d)
|
||||
{
|
||||
__r += __d.count();
|
||||
return *this;
|
||||
}
|
||||
|
||||
duration&
|
||||
operator-=(const duration& __d)
|
||||
{
|
||||
__r -= __d.count();
|
||||
return *this;
|
||||
}
|
||||
|
||||
duration&
|
||||
operator*=(const rep& __rhs)
|
||||
{
|
||||
__r *= __rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
duration&
|
||||
operator/=(const rep& __rhs)
|
||||
{
|
||||
__r /= __rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// special values
|
||||
// TODO: These should be constexprs.
|
||||
static const duration
|
||||
zero()
|
||||
{ return duration(duration_values<rep>::zero()); }
|
||||
|
||||
static const duration
|
||||
min()
|
||||
{ return duration(duration_values<rep>::min()); }
|
||||
|
||||
static const duration
|
||||
max()
|
||||
{ return duration(duration_values<rep>::max()); }
|
||||
|
||||
private:
|
||||
rep __r;
|
||||
};
|
||||
|
||||
template<typename _Rep1, typename _Period1,
|
||||
typename _Rep2, typename _Period2>
|
||||
inline typename common_type<duration<_Rep1, _Period1>,
|
||||
duration<_Rep2, _Period2>>::type
|
||||
operator+(const duration<_Rep1, _Period1>& __lhs,
|
||||
const duration<_Rep2, _Period2>& __rhs)
|
||||
{
|
||||
typedef typename common_type<duration<_Rep1, _Period1>,
|
||||
duration<_Rep2, _Period2>>::type __ct;
|
||||
return __ct(__lhs) += __rhs;
|
||||
}
|
||||
|
||||
template<typename _Rep1, typename _Period1,
|
||||
typename _Rep2, typename _Period2>
|
||||
inline typename common_type<duration<_Rep1, _Period1>,
|
||||
duration<_Rep2, _Period2>>::type
|
||||
operator-(const duration<_Rep1, _Period1>& __lhs,
|
||||
const duration<_Rep2, _Period2>& __rhs)
|
||||
{
|
||||
typedef typename common_type<duration<_Rep1, _Period1>,
|
||||
duration<_Rep2, _Period2>>::type __ct;
|
||||
return __ct(__lhs) -= __rhs;
|
||||
}
|
||||
|
||||
template<typename _Rep1, typename _Period, typename _Rep2>
|
||||
inline duration<typename common_type<_Rep1, _Rep2>::type, _Period>
|
||||
operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
|
||||
{
|
||||
typedef typename common_type<_Rep1, _Rep2>::type __cr;
|
||||
return duration<__cr, _Period>(__d) *= __s;
|
||||
}
|
||||
|
||||
template<typename _Rep1, typename _Period, typename _Rep2>
|
||||
inline duration<typename common_type<_Rep1, _Rep2>::type, _Period>
|
||||
operator*(const _Rep2& __s, const duration<_Rep1, _Period>& __d)
|
||||
{ return __d * __s; }
|
||||
|
||||
template<typename _Tp>
|
||||
struct __is_not_duration
|
||||
: std::true_type
|
||||
{ };
|
||||
|
||||
template<typename _Rep, typename _Period>
|
||||
struct __is_not_duration<duration<_Rep, _Period>>
|
||||
: std::false_type
|
||||
{ };
|
||||
|
||||
template<typename _Tp, typename _Up, typename _Ep = void>
|
||||
struct __division_impl;
|
||||
|
||||
template<typename _Rep1, typename _Period, typename _Rep2>
|
||||
struct __division_impl<duration<_Rep1, _Period>, _Rep2,
|
||||
typename enable_if<__is_not_duration<_Rep2>::value>::type>
|
||||
{
|
||||
typedef typename common_type<_Rep1, _Rep2>::type __cr;
|
||||
typedef
|
||||
duration<typename common_type<_Rep1, _Rep2>::type, _Period> __rt;
|
||||
|
||||
static __rt
|
||||
__divide(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
|
||||
{ return duration<__cr, _Period>(__d) /= __s; }
|
||||
};
|
||||
|
||||
template<typename _Rep1, typename _Period1,
|
||||
typename _Rep2, typename _Period2>
|
||||
struct __division_impl<duration<_Rep1, _Period1>,
|
||||
duration<_Rep2, _Period2>>
|
||||
{
|
||||
typedef typename common_type<duration<_Rep1, _Period1>,
|
||||
duration<_Rep2, _Period2>>::type __ct;
|
||||
typedef typename common_type<_Rep1, _Rep2>::type __rt;
|
||||
|
||||
static __rt
|
||||
__divide(const duration<_Rep1, _Period1>& __lhs,
|
||||
const duration<_Rep2, _Period2>& __rhs)
|
||||
{ return __ct(__lhs).count() / __ct(__rhs).count(); }
|
||||
};
|
||||
|
||||
template<typename _Rep, typename _Period, typename _Up>
|
||||
inline typename __division_impl<duration<_Rep, _Period>, _Up>::__rt
|
||||
operator/(const duration<_Rep, _Period>& __d, const _Up& __u)
|
||||
{
|
||||
return
|
||||
__division_impl<duration<_Rep, _Period>, _Up>::__divide(__d, __u);
|
||||
}
|
||||
|
||||
// comparisons
|
||||
template<typename _Rep1, typename _Period1,
|
||||
typename _Rep2, typename _Period2>
|
||||
inline bool
|
||||
operator==(const duration<_Rep1, _Period1>& __lhs,
|
||||
const duration<_Rep2, _Period2>& __rhs)
|
||||
{
|
||||
typedef typename common_type<duration<_Rep1, _Period1>,
|
||||
duration<_Rep2, _Period2>>::type __ct;
|
||||
return __ct(__lhs).count() == __ct(__rhs).count();
|
||||
}
|
||||
|
||||
template<typename _Rep1, typename _Period1,
|
||||
typename _Rep2, typename _Period2>
|
||||
inline bool
|
||||
operator<(const duration<_Rep1, _Period1>& __lhs,
|
||||
const duration<_Rep2, _Period2>& __rhs)
|
||||
{
|
||||
typedef typename common_type<duration<_Rep1, _Period1>,
|
||||
duration<_Rep2, _Period2>>::type __ct;
|
||||
return __ct(__lhs).count() < __ct(__rhs).count();
|
||||
}
|
||||
|
||||
template<typename _Rep1, typename _Period1,
|
||||
typename _Rep2, typename _Period2>
|
||||
inline bool
|
||||
operator!=(const duration<_Rep1, _Period1>& __lhs,
|
||||
const duration<_Rep2, _Period2>& __rhs)
|
||||
{ return !(__lhs == __rhs); }
|
||||
|
||||
template<typename _Rep1, typename _Period1,
|
||||
typename _Rep2, typename _Period2>
|
||||
inline bool
|
||||
operator<=(const duration<_Rep1, _Period1>& __lhs,
|
||||
const duration<_Rep2, _Period2>& __rhs)
|
||||
{ return !(__rhs < __lhs); }
|
||||
|
||||
template<typename _Rep1, typename _Period1,
|
||||
typename _Rep2, typename _Period2>
|
||||
inline bool
|
||||
operator>(const duration<_Rep1, _Period1>& __lhs,
|
||||
const duration<_Rep2, _Period2>& __rhs)
|
||||
{ return __rhs < __lhs; }
|
||||
|
||||
template<typename _Rep1, typename _Period1,
|
||||
typename _Rep2, typename _Period2>
|
||||
inline bool
|
||||
operator>=(const duration<_Rep1, _Period1>& __lhs,
|
||||
const duration<_Rep2, _Period2>& __rhs)
|
||||
{ return !(__lhs < __rhs); }
|
||||
|
||||
typedef duration<int64_t, nano> nanoseconds;
|
||||
typedef duration<int64_t, micro> microseconds;
|
||||
typedef duration<int64_t, milli> milliseconds;
|
||||
typedef duration<int64_t > seconds;
|
||||
typedef duration<int, ratio< 60>> minutes;
|
||||
typedef duration<int, ratio<3600>> hours;
|
||||
|
||||
template<typename _Clock, typename _Duration>
|
||||
struct time_point
|
||||
{
|
||||
typedef _Clock clock;
|
||||
typedef _Duration duration;
|
||||
typedef typename duration::rep rep;
|
||||
typedef typename duration::period period;
|
||||
|
||||
time_point()
|
||||
: __d(duration::zero())
|
||||
{ }
|
||||
|
||||
explicit time_point(const duration& __dur)
|
||||
: __d(duration::zero() + __dur)
|
||||
{ }
|
||||
|
||||
// conversions
|
||||
template<typename _Duration2>
|
||||
time_point(const time_point<clock, _Duration2>& __t)
|
||||
: __d(__t.time_since_epoch())
|
||||
{ }
|
||||
|
||||
// observer
|
||||
duration
|
||||
time_since_epoch() const
|
||||
{ return __d; }
|
||||
|
||||
// arithmetic
|
||||
time_point&
|
||||
operator+=(const duration& __dur)
|
||||
{
|
||||
__d += __dur;
|
||||
return *this;
|
||||
}
|
||||
|
||||
time_point&
|
||||
operator-=(const duration& __dur)
|
||||
{
|
||||
__d -= __dur;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// special values
|
||||
// TODO: These should be constexprs.
|
||||
static const time_point
|
||||
min()
|
||||
{ return time_point(duration::min()); }
|
||||
|
||||
static const time_point
|
||||
max()
|
||||
{ return time_point(duration::max()); }
|
||||
|
||||
private:
|
||||
duration __d;
|
||||
};
|
||||
|
||||
template<typename _ToDuration, typename _Clock, typename _Duration>
|
||||
inline time_point<_Clock, _ToDuration>
|
||||
time_point_cast(const time_point<_Clock, _Duration>& __t)
|
||||
{
|
||||
return time_point<_Clock, _ToDuration>(
|
||||
duration_cast<_ToDuration>(__t.time_since_epoch()));
|
||||
}
|
||||
|
||||
template<typename _Clock, typename _Duration1,
|
||||
typename _Rep2, typename _Period2>
|
||||
inline time_point<_Clock,
|
||||
typename common_type<_Duration1, duration<_Rep2, _Period2>>::type>
|
||||
operator+(const time_point<_Clock, _Duration1>& __lhs,
|
||||
const duration<_Rep2, _Period2>& __rhs)
|
||||
{
|
||||
typedef time_point<_Clock,
|
||||
typename common_type<_Duration1,
|
||||
duration<_Rep2, _Period2>>::type> __ct;
|
||||
return __ct(__lhs) += __rhs;
|
||||
}
|
||||
|
||||
template<typename _Rep1, typename _Period1,
|
||||
typename _Clock, typename _Duration2>
|
||||
inline time_point<_Clock,
|
||||
typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
|
||||
operator+(const duration<_Rep1, _Period1>& __lhs,
|
||||
const time_point<_Clock, _Duration2>& __rhs)
|
||||
{ return __rhs + __lhs; }
|
||||
|
||||
template<typename _Clock, typename _Duration1,
|
||||
typename _Rep2, typename _Period2>
|
||||
inline time_point<_Clock,
|
||||
typename common_type<_Duration1, duration<_Rep2, _Period2>>::type>
|
||||
operator-(const time_point<_Clock, _Duration1>& __lhs,
|
||||
const duration<_Rep2, _Period2>& __rhs)
|
||||
{ return __lhs + (-__rhs); }
|
||||
|
||||
template<typename _Clock, typename _Duration1, typename _Duration2>
|
||||
inline typename common_type<_Duration1, _Duration2>::type
|
||||
operator-(const time_point<_Clock, _Duration1>& __lhs,
|
||||
const time_point<_Clock, _Duration2>& __rhs)
|
||||
{ return __lhs.time_since_epoch() - __rhs.time_since_epoch(); }
|
||||
|
||||
template<typename _Clock, typename _Duration1, typename _Duration2>
|
||||
inline bool
|
||||
operator==(const time_point<_Clock, _Duration1>& __lhs,
|
||||
const time_point<_Clock, _Duration2>& __rhs)
|
||||
{ return __lhs.time_since_epoch() == __rhs.time_since_epoch(); }
|
||||
|
||||
template<typename _Clock, typename _Duration1, typename _Duration2>
|
||||
inline bool
|
||||
operator!=(const time_point<_Clock, _Duration1>& __lhs,
|
||||
const time_point<_Clock, _Duration2>& __rhs)
|
||||
{ return !(__lhs == __rhs); }
|
||||
|
||||
template<typename _Clock, typename _Duration1, typename _Duration2>
|
||||
inline bool
|
||||
operator<(const time_point<_Clock, _Duration1>& __lhs,
|
||||
const time_point<_Clock, _Duration2>& __rhs)
|
||||
{ return __lhs.time_since_epoch() < __rhs.time_since_epoch(); }
|
||||
|
||||
template<typename _Clock, typename _Duration1, typename _Duration2>
|
||||
inline bool
|
||||
operator<=(const time_point<_Clock, _Duration1>& __lhs,
|
||||
const time_point<_Clock, _Duration2>& __rhs)
|
||||
{ return !(__rhs < __lhs); }
|
||||
|
||||
template<typename _Clock, typename _Duration1, typename _Duration2>
|
||||
inline bool
|
||||
operator>(const time_point<_Clock, _Duration1>& __lhs,
|
||||
const time_point<_Clock, _Duration2>& __rhs)
|
||||
{ return __rhs < __lhs; }
|
||||
|
||||
template<typename _Clock, typename _Duration1, typename _Duration2>
|
||||
inline bool
|
||||
operator>=(const time_point<_Clock, _Duration1>& __lhs,
|
||||
const time_point<_Clock, _Duration2>& __rhs)
|
||||
{ return !(__lhs < __rhs); }
|
||||
|
||||
struct system_clock
|
||||
{
|
||||
#if defined(_GLIBCXX_USE_CLOCK_MONOTONIC) || \
|
||||
defined(_GLIBCXX_USE_CLOCK_REALTIME)
|
||||
typedef chrono::nanoseconds duration;
|
||||
#elif defined(_GLIBCXX_USE_GETTIMEOFDAY)
|
||||
typedef chrono::microseconds duration;
|
||||
#else
|
||||
typedef chrono::seconds duration;
|
||||
#endif
|
||||
|
||||
typedef duration::rep rep;
|
||||
typedef duration::period period;
|
||||
typedef chrono::time_point<system_clock, duration> time_point;
|
||||
|
||||
#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
|
||||
static const bool is_monotonic = true;
|
||||
#else
|
||||
static const bool is_monotonic = false;
|
||||
#endif
|
||||
|
||||
static time_point
|
||||
now();
|
||||
|
||||
// Map to C API
|
||||
static std::time_t
|
||||
to_time_t(const time_point& __t)
|
||||
{
|
||||
return std::time_t(
|
||||
duration_cast<chrono::seconds>(__t.time_since_epoch()).count());
|
||||
}
|
||||
|
||||
static time_point
|
||||
from_time_t(std::time_t __t)
|
||||
{
|
||||
return time_point_cast<system_clock::duration>(
|
||||
chrono::time_point<system_clock, chrono::seconds>(
|
||||
chrono::seconds(__t)));
|
||||
}
|
||||
|
||||
// TODO: requires constexpr
|
||||
/*
|
||||
static_assert(
|
||||
system_clock::duration::min() <
|
||||
system_clock::duration::zero(),
|
||||
"a clock's minimum duration cannot be less than its epoch");
|
||||
*/
|
||||
};
|
||||
|
||||
typedef system_clock high_resolution_clock;
|
||||
typedef system_clock monotonic_clock;
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_GLIBCXX_USE_C99_STDINT_TR1
|
||||
|
||||
#endif //__GXX_EXPERIMENTAL_CXX0X__
|
||||
|
||||
#endif //_GLIBCXX_CHRONO
|
@ -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.
|
||||
|
@ -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
|
||||
|
76
libstdc++-v3/src/chrono.cc
Normal file
76
libstdc++-v3/src/chrono.cc
Normal file
@ -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
|
@ -95,6 +95,7 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <complex>
|
||||
#include <deque>
|
||||
@ -118,6 +119,7 @@
|
||||
#include <ostream>
|
||||
#include <queue>
|
||||
#include <random>
|
||||
#include <ratio>
|
||||
#include <regex>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
@ -93,6 +93,7 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <chrono>
|
||||
#include <complex>
|
||||
#include <deque>
|
||||
#include <exception>
|
||||
@ -114,6 +115,7 @@
|
||||
#include <ostream>
|
||||
#include <queue>
|
||||
#include <random>
|
||||
#include <ratio>
|
||||
#include <regex>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
@ -203,6 +205,7 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <chrono>
|
||||
#include <complex>
|
||||
#include <deque>
|
||||
#include <exception>
|
||||
@ -219,11 +222,13 @@
|
||||
#include <locale>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <new>
|
||||
#include <numeric>
|
||||
#include <ostream>
|
||||
#include <queue>
|
||||
#include <random>
|
||||
#include <ratio>
|
||||
#include <regex>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
39
libstdc++-v3/testsuite/20_util/clocks/1.cc
Normal file
39
libstdc++-v3/testsuite/20_util/clocks/1.cc
Normal file
@ -0,0 +1,39 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
|
||||
// Copyright (C) 2008 Free Software Foundation
|
||||
//
|
||||
// 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.
|
||||
|
||||
// 20.8.5 Clocks [time.clock]
|
||||
|
||||
#include <chrono>
|
||||
|
||||
// 20.8.5.1 system_clock [time.clock.system]
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
|
||||
system_clock::time_point t1 = system_clock::now();
|
||||
bool is_monotonic = system_clock::is_monotonic;
|
||||
is_monotonic = is_monotonic; // suppress unused warning
|
||||
std::time_t t2 = system_clock::to_time_t(t1);
|
||||
system_clock::time_point t3 = system_clock::from_time_t(t2);
|
||||
|
||||
return 0;
|
||||
}
|
94
libstdc++-v3/testsuite/20_util/duration/arithmetic/1.cc
Normal file
94
libstdc++-v3/testsuite/20_util/duration/arithmetic/1.cc
Normal file
@ -0,0 +1,94 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
|
||||
// Copyright (C) 2008 Free Software Foundation
|
||||
//
|
||||
// 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.
|
||||
|
||||
// 20.8.3 Class template duration [time.duration]
|
||||
|
||||
#include <chrono>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// 20.8.3.3 duration arithmetic [time.duration.arithmetic] (unary member ops)
|
||||
void
|
||||
test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std::chrono;
|
||||
|
||||
duration<int> d0(3);
|
||||
duration<int> d1 = -d0;
|
||||
VERIFY(d0.count() == 3);
|
||||
VERIFY(d1.count() == -3);
|
||||
|
||||
duration<int> d2 = (+d0);
|
||||
VERIFY(d2.count() == 3);
|
||||
|
||||
duration<int> d3(++d2);
|
||||
VERIFY(d2.count() == 4);
|
||||
VERIFY(d3.count() == 4);
|
||||
|
||||
duration<int> d4(d3++);
|
||||
VERIFY(d3.count() == 5);
|
||||
VERIFY(d4.count() == 4);
|
||||
|
||||
duration<int> d5(--d4);
|
||||
VERIFY(d4.count() == 3);
|
||||
VERIFY(d5.count() == 3);
|
||||
|
||||
duration<int> d6(d5--);
|
||||
VERIFY(d5.count() == 2);
|
||||
VERIFY(d6.count() == 3);
|
||||
}
|
||||
|
||||
// 20.8.3.3 duration arithmetic [time.duration.arithmetic] (binary member ops)
|
||||
void
|
||||
test02()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std::chrono;
|
||||
|
||||
duration<int> d7(3);
|
||||
duration<int> d8(9);
|
||||
d7 += d8;
|
||||
VERIFY(d7.count() == 12);
|
||||
VERIFY(d8.count() == 9);
|
||||
|
||||
duration<int> d9(3);
|
||||
duration<int> d10(9);
|
||||
d9 -= d10;
|
||||
VERIFY(d9.count() == -6);
|
||||
VERIFY(d10.count() == 9);
|
||||
|
||||
duration<int> d11(9);
|
||||
int i = 3;
|
||||
d11 *= i;
|
||||
VERIFY(d11.count() == 27);
|
||||
|
||||
duration<int> d12(12);
|
||||
d12 /= i;
|
||||
VERIFY(d12.count() == 4);
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
return 0;
|
||||
}
|
62
libstdc++-v3/testsuite/20_util/duration/arithmetic/2.cc
Normal file
62
libstdc++-v3/testsuite/20_util/duration/arithmetic/2.cc
Normal file
@ -0,0 +1,62 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
|
||||
// Copyright (C) 2008 Free Software Foundation
|
||||
//
|
||||
// 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.
|
||||
|
||||
// 20.8.3 Class template duration [time.duration]
|
||||
|
||||
#include <chrono>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// 20.8.3.5 duration non-member arithmetic [time.duration.nonmember]
|
||||
void
|
||||
test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std::chrono;
|
||||
|
||||
duration<int> d0(12);
|
||||
duration<int> d1(3);
|
||||
int i = 3;
|
||||
|
||||
duration<int> d2 = d0 + d1;
|
||||
VERIFY(d2.count() == 15);
|
||||
|
||||
duration<int> d3 = d0 - d1;
|
||||
VERIFY(d3.count() == 9);
|
||||
|
||||
duration<int> d4 = d0 * i;
|
||||
VERIFY(d4.count() == 36);
|
||||
|
||||
duration<int> d5 = i * d0;
|
||||
VERIFY(d5.count() == 36);
|
||||
|
||||
duration<int> d6 = d0 / i;
|
||||
VERIFY(d6.count() == 4);
|
||||
|
||||
int j = d0 / d1;
|
||||
VERIFY(j == 4);
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
56
libstdc++-v3/testsuite/20_util/duration/comparisons/1.cc
Normal file
56
libstdc++-v3/testsuite/20_util/duration/comparisons/1.cc
Normal file
@ -0,0 +1,56 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
|
||||
// Copyright (C) 2008 Free Software Foundation
|
||||
//
|
||||
// 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.
|
||||
|
||||
// 20.8.3 Class template duration [time.duration]
|
||||
|
||||
#include <chrono>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// 20.8.3.6 duration comparisons [time.duration.comparisons]
|
||||
void
|
||||
test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std::chrono;
|
||||
|
||||
duration<int> d0(12);
|
||||
duration<int> d1(3);
|
||||
duration<int> d2(3);
|
||||
|
||||
VERIFY(d1 < d0);
|
||||
VERIFY(d0 > d1);
|
||||
|
||||
VERIFY(d0 != d1);
|
||||
VERIFY(d1 == d2);
|
||||
|
||||
VERIFY(d1 <= d2);
|
||||
VERIFY(d1 >= d2);
|
||||
|
||||
VERIFY(d1 <= d0);
|
||||
VERIFY(d0 >= d1);
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
138
libstdc++-v3/testsuite/20_util/duration/cons/1.cc
Normal file
138
libstdc++-v3/testsuite/20_util/duration/cons/1.cc
Normal file
@ -0,0 +1,138 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
|
||||
// Copyright (C) 2008 Free Software Foundation
|
||||
//
|
||||
// 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.
|
||||
|
||||
// 20.8.3 Class template duration [time.duration]
|
||||
|
||||
#include <chrono>
|
||||
#include <type_traits>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
template<typename T>
|
||||
struct type_emulator
|
||||
{
|
||||
type_emulator()
|
||||
: i(T(0)) { }
|
||||
|
||||
type_emulator(T j)
|
||||
: i(j) { }
|
||||
|
||||
type_emulator(const type_emulator& e)
|
||||
: i(e.i) { }
|
||||
|
||||
type_emulator&
|
||||
operator*=(type_emulator a)
|
||||
{
|
||||
i *= a.i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
type_emulator&
|
||||
operator+=(type_emulator a)
|
||||
{
|
||||
i += a.i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator T ()
|
||||
{ return i; }
|
||||
|
||||
T i;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
bool
|
||||
operator==(type_emulator<T> a, type_emulator<T> b)
|
||||
{ return a.i == b.i; }
|
||||
|
||||
template<typename T>
|
||||
bool
|
||||
operator<(type_emulator<T> a, type_emulator<T> b)
|
||||
{ return a.i < b.i; }
|
||||
|
||||
template<typename T>
|
||||
type_emulator<T>
|
||||
operator+(type_emulator<T> a, type_emulator<T> b)
|
||||
{ return a += b; }
|
||||
|
||||
template<typename T>
|
||||
type_emulator<T>
|
||||
operator*(type_emulator<T> a, type_emulator<T> b)
|
||||
{ return a *= b; }
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<typename T, typename U>
|
||||
struct common_type<type_emulator<T>, U>
|
||||
{ typedef typename common_type<T,U>::type type; };
|
||||
|
||||
template<typename T, typename U>
|
||||
struct common_type<U, type_emulator<T>>
|
||||
{ typedef typename common_type<U,T>::type type; };
|
||||
|
||||
template<typename T, typename U>
|
||||
struct common_type<type_emulator<T>, type_emulator<U>>
|
||||
{ typedef typename common_type<T,U>::type type; };
|
||||
|
||||
namespace chrono
|
||||
{
|
||||
template<typename T>
|
||||
struct treat_as_floating_point<type_emulator<T>>
|
||||
: is_floating_point<T>
|
||||
{ };
|
||||
}
|
||||
}
|
||||
|
||||
typedef type_emulator<int> int_emulator;
|
||||
typedef type_emulator<double> dbl_emulator;
|
||||
|
||||
// 20.8.3.1 duration constructors [time.duration.cons]
|
||||
void
|
||||
test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using std::chrono::duration;
|
||||
|
||||
duration<int> d0;
|
||||
VERIFY(d0.count() == static_cast<duration<int>::rep>(0));
|
||||
|
||||
int r = 3;
|
||||
duration<int> d1(r);
|
||||
VERIFY(d1.count() == static_cast<duration<int>::rep>(r));
|
||||
|
||||
double s = 8.0;
|
||||
duration<double> d2(s);
|
||||
VERIFY(d2.count() == static_cast<duration<double>::rep>(s));
|
||||
|
||||
int_emulator ie(3);
|
||||
duration<int_emulator> d3(ie);
|
||||
VERIFY(d3.count() == static_cast<duration<int_emulator>::rep>(ie));
|
||||
|
||||
dbl_emulator de(4.0);
|
||||
duration<dbl_emulator> d4(de);
|
||||
VERIFY(d4.count() == static_cast<duration<dbl_emulator>::rep>(de));
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
46
libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc
Normal file
46
libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc
Normal file
@ -0,0 +1,46 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
|
||||
// Copyright (C) 2008 Free Software Foundation
|
||||
//
|
||||
// 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.
|
||||
|
||||
// 20.8.3.1 duration constructors [time.duration.cons]
|
||||
|
||||
#include <chrono>
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
std::chrono::duration<int> d1(1.0);
|
||||
}
|
||||
|
||||
void
|
||||
test02()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
|
||||
duration<int, std::micro> d2(8);
|
||||
duration<int, std::milli> d2_copy(d2);
|
||||
}
|
||||
|
||||
// { dg-error "instantiated from here" "" { target *-*-* } 30 }
|
||||
// { dg-error "instantiated from here" "" { target *-*-* } 39 }
|
||||
// { dg-error "not exactly representable" "" { target *-*-* } 202 }
|
||||
// { dg-error "integral duration with floating point" "" { target *-*-* } 186 }
|
||||
// { dg-excess-errors "In instantiation of" }
|
120
libstdc++-v3/testsuite/20_util/duration/cons/2.cc
Normal file
120
libstdc++-v3/testsuite/20_util/duration/cons/2.cc
Normal file
@ -0,0 +1,120 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
|
||||
// Copyright (C) 2008 Free Software Foundation
|
||||
//
|
||||
// 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.
|
||||
|
||||
// 20.8.3 Class template duration [time.duration]
|
||||
|
||||
#include <chrono>
|
||||
#include <type_traits>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
template<typename T>
|
||||
struct type_emulator
|
||||
{
|
||||
type_emulator() : i(T(0)) { }
|
||||
type_emulator(T j) : i(j) { }
|
||||
type_emulator(const type_emulator& e) : i(e.i) { }
|
||||
|
||||
type_emulator& operator*=(type_emulator a)
|
||||
{ i *= a.i; return *this; }
|
||||
|
||||
type_emulator& operator+=(type_emulator a)
|
||||
{ i += a.i; return *this; }
|
||||
|
||||
operator T () { return i; }
|
||||
T i;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
bool operator==(type_emulator<T> a, type_emulator<T> b)
|
||||
{ return a.i == b.i; }
|
||||
|
||||
template<typename T>
|
||||
bool operator<(type_emulator<T> a, type_emulator<T> b)
|
||||
{ return a.i < b.i; }
|
||||
|
||||
template<typename T>
|
||||
type_emulator<T> operator+(type_emulator<T> a, type_emulator<T> b)
|
||||
{ return a += b; }
|
||||
|
||||
template<typename T>
|
||||
type_emulator<T> operator*(type_emulator<T> a, type_emulator<T> b)
|
||||
{ return a *= b; }
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<typename T, typename U>
|
||||
struct common_type<type_emulator<T>, U>
|
||||
{ typedef typename common_type<T,U>::type type; };
|
||||
|
||||
template<typename T, typename U>
|
||||
struct common_type<U, type_emulator<T>>
|
||||
{ typedef typename common_type<U,T>::type type; };
|
||||
|
||||
template<typename T, typename U>
|
||||
struct common_type<type_emulator<T>, type_emulator<U>>
|
||||
{ typedef typename common_type<T,U>::type type; };
|
||||
|
||||
namespace chrono
|
||||
{
|
||||
template<typename T>
|
||||
struct treat_as_floating_point<type_emulator<T>>
|
||||
: is_floating_point<T>
|
||||
{ };
|
||||
}
|
||||
}
|
||||
|
||||
typedef type_emulator<int> int_emulator;
|
||||
typedef type_emulator<double> dbl_emulator;
|
||||
|
||||
// 20.8.3.1 duration constructors [time.duration.cons]
|
||||
void
|
||||
test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std::chrono;
|
||||
|
||||
duration<int> d0(3);
|
||||
duration<int> d0_copy(d0);
|
||||
VERIFY(d0_copy.count() == d0.count());
|
||||
|
||||
duration<int, std::milli> d1(5);
|
||||
duration<int, std::micro> d1_copy(d1);
|
||||
VERIFY(d1.count() * 1000 == d1_copy.count());
|
||||
|
||||
duration<double, std::micro> d2(8.0);
|
||||
duration<double, std::milli> d2_copy(d2);
|
||||
VERIFY(d2.count() == d2_copy.count() * 1000.0);
|
||||
|
||||
duration<int_emulator, std::milli> d3(5);
|
||||
duration<int_emulator, std::micro> d3_copy(d3);
|
||||
VERIFY(d3.count() * 1000 == d3_copy.count());
|
||||
|
||||
duration<dbl_emulator, std::micro> d4(5.0);
|
||||
duration<dbl_emulator, std::milli> d4_copy(d4);
|
||||
VERIFY(d4.count() == d4_copy.count() * dbl_emulator(1000.0));
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
27
libstdc++-v3/testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc
Normal file
27
libstdc++-v3/testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc
Normal file
@ -0,0 +1,27 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
|
||||
// Copyright (C) 2008 Free Software Foundation
|
||||
//
|
||||
// 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.
|
||||
|
||||
#include <ratio>
|
||||
#include <chrono>
|
||||
|
||||
template class std::chrono::duration<int>;
|
||||
template class std::chrono::duration<float, std::ratio<2,3>>;
|
49
libstdc++-v3/testsuite/20_util/time_point/1.cc
Normal file
49
libstdc++-v3/testsuite/20_util/time_point/1.cc
Normal file
@ -0,0 +1,49 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
|
||||
// Copyright (C) 2008 Free Software Foundation
|
||||
//
|
||||
// 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.
|
||||
|
||||
// 20.8.4 Class template time_point [time.point]
|
||||
|
||||
#include <chrono>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// 20.8.4.1 time_point constructors [time.point.cons]
|
||||
void
|
||||
test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std::chrono;
|
||||
|
||||
time_point<system_clock> t1;
|
||||
VERIFY(t1.time_since_epoch() == system_clock::duration::zero());
|
||||
|
||||
time_point<monotonic_clock> t2;
|
||||
VERIFY(t2.time_since_epoch() == monotonic_clock::duration::zero());
|
||||
|
||||
time_point<high_resolution_clock> t3;
|
||||
VERIFY(t3.time_since_epoch() == high_resolution_clock::duration::zero());
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
72
libstdc++-v3/testsuite/20_util/time_point/2.cc
Normal file
72
libstdc++-v3/testsuite/20_util/time_point/2.cc
Normal file
@ -0,0 +1,72 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
|
||||
// Copyright (C) 2008 Free Software Foundation
|
||||
//
|
||||
// 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.
|
||||
|
||||
// 20.8.4 Class template time_point [time.point]
|
||||
|
||||
#include <chrono>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// 20.8.4.3 time_point arithmetic [time.point.arithmetic]
|
||||
void
|
||||
test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std::chrono;
|
||||
|
||||
time_point<system_clock> t1, t2;
|
||||
t1 += seconds(1);
|
||||
VERIFY(t2.time_since_epoch() + seconds(1) == t1.time_since_epoch());
|
||||
|
||||
t1 -= std::chrono::seconds(1);
|
||||
VERIFY(t2.time_since_epoch() == t1.time_since_epoch());
|
||||
}
|
||||
|
||||
// 20.8.4.5 time_point non-member arithmetic [time.point.nonmember]
|
||||
void
|
||||
test02()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std::chrono;
|
||||
|
||||
time_point<system_clock> t1;
|
||||
time_point<system_clock> t2(t1 + seconds(1));
|
||||
VERIFY(t2.time_since_epoch() == t1.time_since_epoch() + seconds(1));
|
||||
|
||||
time_point<system_clock> t3(seconds(1) + t1);
|
||||
VERIFY(t3.time_since_epoch() == t1.time_since_epoch() + seconds(1));
|
||||
|
||||
time_point<system_clock> t4(seconds(1));
|
||||
time_point<system_clock> t5(seconds(2));
|
||||
|
||||
time_point<system_clock> t6(t5 - seconds(1));
|
||||
VERIFY(t6.time_since_epoch() == t4.time_since_epoch());
|
||||
|
||||
time_point<system_clock> t7(t5 - t4);
|
||||
VERIFY(t7.time_since_epoch() == t4.time_since_epoch());
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
return 0;
|
||||
}
|
53
libstdc++-v3/testsuite/20_util/time_point/3.cc
Normal file
53
libstdc++-v3/testsuite/20_util/time_point/3.cc
Normal file
@ -0,0 +1,53 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
|
||||
// Copyright (C) 2008 Free Software Foundation
|
||||
//
|
||||
// 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.
|
||||
|
||||
// 20.8.4 Class template time_point [time.point]
|
||||
|
||||
#include <chrono>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// 20.8.4.6 time_point comparisons [time.point.comparisons]
|
||||
void
|
||||
test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std::chrono;
|
||||
|
||||
time_point<system_clock> t1(seconds(1));
|
||||
time_point<system_clock> t2(seconds(1));
|
||||
time_point<system_clock> t3(seconds(2));
|
||||
|
||||
VERIFY(t1 == t2);
|
||||
VERIFY(t1 != t3);
|
||||
VERIFY(t1 < t3);
|
||||
VERIFY(t1 <= t3);
|
||||
VERIFY(t1 <= t2);
|
||||
VERIFY(t3 > t1);
|
||||
VERIFY(t3 >= t1);
|
||||
VERIFY(t2 >= t1);
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
25
libstdc++-v3/testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc
Normal file
25
libstdc++-v3/testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc
Normal file
@ -0,0 +1,25 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
|
||||
// Copyright (C) 2008 Free Software Foundation
|
||||
//
|
||||
// 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.
|
||||
|
||||
#include <chrono>
|
||||
|
||||
template class std::chrono::time_point<std::chrono::system_clock>;
|
Loading…
x
Reference in New Issue
Block a user