diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/timer/timer.cpp | 43 | ||||
-rw-r--r-- | src/timer/timer.h | 28 |
2 files changed, 40 insertions, 31 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); + } + + } diff --git a/src/timer/timer.h b/src/timer/timer.h index 9aa95f261..dfa04ee3a 100644 --- a/src/timer/timer.h +++ b/src/timer/timer.h @@ -1,7 +1,7 @@ -/************************************************* -* Timestamp Functions Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/** +* Timestamp Functions Header File +* (C) 1999-2008 Jack Lloyd +*/ #ifndef BOTAN_TIMERS_H__ #define BOTAN_TIMERS_H__ @@ -10,23 +10,31 @@ namespace Botan { -/************************************************* -* Timer Interface * -*************************************************/ +/** +* Timer Interface +*/ class BOTAN_DLL Timer : public EntropySource { public: - virtual u64bit clock() const; + virtual u64bit clock() const = 0; u32bit slow_poll(byte[], u32bit); u32bit fast_poll(byte[], u32bit); - std::string name() const { return "ANSI clock"; } - virtual ~Timer() {} protected: static u64bit combine_timers(u32bit, u32bit, u32bit); }; +/** +* ANSI Clock Timer +*/ +class BOTAN_DLL ANSI_Clock_Timer : public Timer + { + public: + std::string name() const { return "ANSI clock"; } + u64bit clock() const; + }; + } #endif |