diff options
author | lloyd <[email protected]> | 2012-02-20 21:12:29 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-02-20 21:12:29 +0000 |
commit | 49f333282279cc22fa8af7423447973b9dcfeee9 (patch) | |
tree | 574a19e310aeb158dcc08016b3ce91a9d0ac0f81 /src/utils | |
parent | 73e7730306b524aeee6fcfe8dd9f41b9673cf31b (diff) |
Remove get_nanoseconds_clock as we'll rely on std::chrono's high
resolution clock for this in C++11. Now that the only remaining
function in time.h is calendar_point, rename the header to
calendar.h. Hopefully that last use will go away once a TR2 datetime
library becomes available.
Use std::chrono inside the library benchmark code.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/calendar.cpp (renamed from src/utils/time.cpp) | 58 | ||||
-rw-r--r-- | src/utils/calendar.h (renamed from src/utils/time.h) | 11 | ||||
-rw-r--r-- | src/utils/info.txt | 4 |
3 files changed, 7 insertions, 66 deletions
diff --git a/src/utils/time.cpp b/src/utils/calendar.cpp index d5b74828b..a51ef876c 100644 --- a/src/utils/time.cpp +++ b/src/utils/calendar.cpp @@ -1,36 +1,14 @@ /* -* Time Functions +* Calendar Functions * (C) 1999-2010 Jack Lloyd * * Distributed under the terms of the Botan license */ -#include <botan/time.h> +#include <botan/calendar.h> #include <botan/exceptn.h> #include <ctime> -#if defined(BOTAN_TARGET_OS_HAS_WIN32_GET_SYSTEMTIME) - #include <windows.h> -#endif - -#if defined(BOTAN_TARGET_OS_HAS_GETTIMEOFDAY) - #include <sys/time.h> -#endif - -#if defined(BOTAN_TARGET_OS_HAS_CLOCK_GETTIME) - - #ifndef _POSIX_C_SOURCE - #define _POSIX_C_SOURCE 199309 - #endif - - #include <time.h> - - #ifndef CLOCK_REALTIME - #define CLOCK_REALTIME 0 - #endif - -#endif - namespace Botan { namespace { @@ -83,36 +61,4 @@ calendar_point calendar_value( tm.tm_sec); } -u64bit get_nanoseconds_clock() - { -#if defined(BOTAN_TARGET_OS_HAS_CLOCK_GETTIME) - - struct ::timespec tv; - ::clock_gettime(CLOCK_REALTIME, &tv); - return combine_timers(tv.tv_sec, tv.tv_nsec, 1000000000); - -#elif defined(BOTAN_TARGET_OS_HAS_GETTIMEOFDAY) - - struct ::timeval tv; - ::gettimeofday(&tv, 0); - return combine_timers(tv.tv_sec, tv.tv_usec, 1000000); - -#elif defined(BOTAN_TARGET_OS_HAS_WIN32_GET_SYSTEMTIME) - - // Returns time since January 1, 1601 in 100-ns increments - ::FILETIME tv; - ::GetSystemTimeAsFileTime(&tv); - u64bit tstamp = (static_cast<u64bit>(tv.dwHighDateTime) << 32) | - tv.dwLowDateTime; - - return (tstamp * 100); // Scale to 1 nanosecond units - -#else - - return combine_timers(static_cast<u32bit>(std::time(0)), - std::clock(), CLOCKS_PER_SEC); - -#endif - } - } diff --git a/src/utils/time.h b/src/utils/calendar.h index 516efba3e..d617cc9a0 100644 --- a/src/utils/time.h +++ b/src/utils/calendar.h @@ -1,12 +1,12 @@ /* -* Time Functions +* Calendar Functions * (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ -#ifndef BOTAN_TIME_H__ -#define BOTAN_TIME_H__ +#ifndef BOTAN_CALENDAR_H__ +#define BOTAN_CALENDAR_H__ #include <botan/types.h> #include <chrono> @@ -58,11 +58,6 @@ struct BOTAN_DLL calendar_point BOTAN_DLL calendar_point calendar_value( const std::chrono::system_clock::time_point& time_point); -/** -* @return nanoseconds resolution timestamp, unknown epoch -*/ -BOTAN_DLL u64bit get_nanoseconds_clock(); - } #endif diff --git a/src/utils/info.txt b/src/utils/info.txt index 4350ed410..e2ffd2714 100644 --- a/src/utils/info.txt +++ b/src/utils/info.txt @@ -4,11 +4,11 @@ load_on always <source> assert.cpp +calendar.cpp charset.cpp cpuid.cpp mlock.cpp parsing.cpp -time.cpp version.cpp </source> @@ -24,6 +24,7 @@ xor_buf.h <header:public> bswap.h +calendar.h charset.h cpuid.h exceptn.h @@ -31,7 +32,6 @@ loadstor.h mem_ops.h parsing.h rotate.h -time.h types.h version.h get_byte.h |