From 6eff33ae263109ccbbeb32bd0ffb25c77140cc45 Mon Sep 17 00:00:00 2001 From: lloyd Date: Tue, 11 Nov 2008 20:56:49 +0000 Subject: Rename timers.h to timer.h --- src/utils/timer/cpu_counter/tm_hard.h | 2 +- src/utils/timer/gettimeofday/tm_unix.h | 2 +- src/utils/timer/info.txt | 4 +- src/utils/timer/posix_rt/tm_posix.h | 2 +- src/utils/timer/timer.cpp | 57 +++++++++++++++++++++++++ src/utils/timer/timer.h | 30 +++++++++++++ src/utils/timer/timers.cpp | 57 ------------------------- src/utils/timer/timers.h | 30 ------------- src/utils/timer/win32_query_perf_ctr/tm_win32.h | 2 +- 9 files changed, 93 insertions(+), 93 deletions(-) create mode 100644 src/utils/timer/timer.cpp create mode 100644 src/utils/timer/timer.h delete mode 100644 src/utils/timer/timers.cpp delete mode 100644 src/utils/timer/timers.h (limited to 'src/utils') diff --git a/src/utils/timer/cpu_counter/tm_hard.h b/src/utils/timer/cpu_counter/tm_hard.h index 436cec22c..ec5268085 100644 --- a/src/utils/timer/cpu_counter/tm_hard.h +++ b/src/utils/timer/cpu_counter/tm_hard.h @@ -6,7 +6,7 @@ #ifndef BOTAN_TIMER_HARDWARE_H__ #define BOTAN_TIMER_HARDWARE_H__ -#include +#include namespace Botan { diff --git a/src/utils/timer/gettimeofday/tm_unix.h b/src/utils/timer/gettimeofday/tm_unix.h index 1b6c935a3..21afb3ee8 100644 --- a/src/utils/timer/gettimeofday/tm_unix.h +++ b/src/utils/timer/gettimeofday/tm_unix.h @@ -6,7 +6,7 @@ #ifndef BOTAN_TIMER_UNIX_H__ #define BOTAN_TIMER_UNIX_H__ -#include +#include namespace Botan { diff --git a/src/utils/timer/info.txt b/src/utils/timer/info.txt index 3637d4c94..c9a860a78 100644 --- a/src/utils/timer/info.txt +++ b/src/utils/timer/info.txt @@ -5,6 +5,6 @@ define TIMER load_on auto -timers.cpp -timers.h +timer.cpp +timer.h diff --git a/src/utils/timer/posix_rt/tm_posix.h b/src/utils/timer/posix_rt/tm_posix.h index 0aee67abb..077636a0a 100644 --- a/src/utils/timer/posix_rt/tm_posix.h +++ b/src/utils/timer/posix_rt/tm_posix.h @@ -6,7 +6,7 @@ #ifndef BOTAN_TIMER_POSIX_H__ #define BOTAN_TIMER_POSIX_H__ -#include +#include namespace Botan { diff --git a/src/utils/timer/timer.cpp b/src/utils/timer/timer.cpp new file mode 100644 index 000000000..a37cf39c3 --- /dev/null +++ b/src/utils/timer/timer.cpp @@ -0,0 +1,57 @@ +/************************************************* +* Timestamp Functions Source File * +* (C) 1999-2007 Jack Lloyd * +*************************************************/ + +#include +#include +#include +#include + +namespace Botan { + +/************************************************* +* Get the system clock * +*************************************************/ +u64bit system_time() + { + return static_cast(std::time(0)); + } + +/************************************************* +* Default Timer clock reading * +*************************************************/ +u64bit Timer::clock() const + { + return combine_timers(std::time(0), std::clock(), CLOCKS_PER_SEC); + } + +/************************************************* +* Read the clock and return the output * +*************************************************/ +u32bit Timer::fast_poll(byte out[], u32bit length) + { + const u64bit clock_value = this->clock(); + + for(u32bit j = 0; j != sizeof(clock_value); ++j) + out[j % length] ^= get_byte(j, clock_value); + + return (length < 8) ? length : 8; + } + +u32bit Timer::slow_poll(byte out[], u32bit length) + { + return fast_poll(out, length); + } + +/************************************************* +* Combine a two time values into a single one * +*************************************************/ +u64bit Timer::combine_timers(u32bit seconds, u32bit parts, u32bit parts_hz) + { + static const u64bit NANOSECONDS_UNITS = 1000000000; + parts *= (NANOSECONDS_UNITS / parts_hz); + return ((seconds * NANOSECONDS_UNITS) + parts); + } + +} diff --git a/src/utils/timer/timer.h b/src/utils/timer/timer.h new file mode 100644 index 000000000..5ad2cfbea --- /dev/null +++ b/src/utils/timer/timer.h @@ -0,0 +1,30 @@ +/************************************************* +* Timestamp Functions Header File * +* (C) 1999-2007 Jack Lloyd * +*************************************************/ + +#ifndef BOTAN_TIMERS_H__ +#define BOTAN_TIMERS_H__ + +#include + +namespace Botan { + +/************************************************* +* Timer Interface * +*************************************************/ +class BOTAN_DLL Timer : public EntropySource + { + public: + virtual u64bit clock() const; + u32bit slow_poll(byte[], u32bit); + u32bit fast_poll(byte[], u32bit); + + virtual ~Timer() {} + protected: + static u64bit combine_timers(u32bit, u32bit, u32bit); + }; + +} + +#endif diff --git a/src/utils/timer/timers.cpp b/src/utils/timer/timers.cpp deleted file mode 100644 index b10b09038..000000000 --- a/src/utils/timer/timers.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/************************************************* -* Timestamp Functions Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ - -#include -#include -#include -#include - -namespace Botan { - -/************************************************* -* Get the system clock * -*************************************************/ -u64bit system_time() - { - return static_cast(std::time(0)); - } - -/************************************************* -* Default Timer clock reading * -*************************************************/ -u64bit Timer::clock() const - { - return combine_timers(std::time(0), std::clock(), CLOCKS_PER_SEC); - } - -/************************************************* -* Read the clock and return the output * -*************************************************/ -u32bit Timer::fast_poll(byte out[], u32bit length) - { - const u64bit clock_value = this->clock(); - - for(u32bit j = 0; j != sizeof(clock_value); ++j) - out[j % length] ^= get_byte(j, clock_value); - - return (length < 8) ? length : 8; - } - -u32bit Timer::slow_poll(byte out[], u32bit length) - { - return fast_poll(out, length); - } - -/************************************************* -* Combine a two time values into a single one * -*************************************************/ -u64bit Timer::combine_timers(u32bit seconds, u32bit parts, u32bit parts_hz) - { - static const u64bit NANOSECONDS_UNITS = 1000000000; - parts *= (NANOSECONDS_UNITS / parts_hz); - return ((seconds * NANOSECONDS_UNITS) + parts); - } - -} diff --git a/src/utils/timer/timers.h b/src/utils/timer/timers.h deleted file mode 100644 index 5ad2cfbea..000000000 --- a/src/utils/timer/timers.h +++ /dev/null @@ -1,30 +0,0 @@ -/************************************************* -* Timestamp Functions Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ - -#ifndef BOTAN_TIMERS_H__ -#define BOTAN_TIMERS_H__ - -#include - -namespace Botan { - -/************************************************* -* Timer Interface * -*************************************************/ -class BOTAN_DLL Timer : public EntropySource - { - public: - virtual u64bit clock() const; - u32bit slow_poll(byte[], u32bit); - u32bit fast_poll(byte[], u32bit); - - virtual ~Timer() {} - protected: - static u64bit combine_timers(u32bit, u32bit, u32bit); - }; - -} - -#endif diff --git a/src/utils/timer/win32_query_perf_ctr/tm_win32.h b/src/utils/timer/win32_query_perf_ctr/tm_win32.h index 916bf2127..d458d0a3f 100644 --- a/src/utils/timer/win32_query_perf_ctr/tm_win32.h +++ b/src/utils/timer/win32_query_perf_ctr/tm_win32.h @@ -6,7 +6,7 @@ #ifndef BOTAN_TIMER_WIN32_H__ #define BOTAN_TIMER_WIN32_H__ -#include +#include namespace Botan { -- cgit v1.2.3