diff options
author | lloyd <[email protected]> | 2008-11-21 16:55:57 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-21 16:55:57 +0000 |
commit | 4db9d2279629408a9df94b887a65c6aabcefeb6f (patch) | |
tree | cb1b3979ab2a1d7e4f9fc1b30dac43b87059b707 /src/timer/timer.cpp | |
parent | 8c885d8fca72e46a27f3f86f3645c780d34596b8 (diff) |
Make Timer a pure virtual interface and add a new subclass ANSI_Clock_Timer
which uses the ANSI/ISO clock function (previously this had been the
Timer::clock default implementation).
Diffstat (limited to 'src/timer/timer.cpp')
-rw-r--r-- | src/timer/timer.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/timer/timer.cpp b/src/timer/timer.cpp index a37cf39c3..7ea4f56ad 100644 --- a/src/timer/timer.cpp +++ b/src/timer/timer.cpp @@ -1,7 +1,7 @@ -/************************************************* -* Timestamp Functions Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/** +* Timestamp Functions Source File +* (C) 1999-2008 Jack Lloyd +*/ #include <botan/timer.h> #include <botan/loadstor.h> @@ -10,25 +10,17 @@ namespace Botan { -/************************************************* -* Get the system clock * -*************************************************/ +/** +* Get the system clock +*/ u64bit system_time() { return static_cast<u64bit>(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 * -*************************************************/ +/** +* Read the clock and return the output +*/ u32bit Timer::fast_poll(byte out[], u32bit length) { const u64bit clock_value = this->clock(); @@ -44,9 +36,9 @@ u32bit Timer::slow_poll(byte out[], u32bit length) return fast_poll(out, length); } -/************************************************* -* Combine a two time values into a single one * -*************************************************/ +/** +* 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; @@ -54,4 +46,13 @@ u64bit Timer::combine_timers(u32bit seconds, u32bit parts, u32bit parts_hz) return ((seconds * NANOSECONDS_UNITS) + parts); } +/** +* ANSI Clock +*/ +u64bit ANSI_Clock_Timer::clock() const + { + return combine_timers(std::time(0), std::clock(), CLOCKS_PER_SEC); + } + + } |