diff options
author | lloyd <[email protected]> | 2008-04-10 05:52:37 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-04-10 05:52:37 +0000 |
commit | f15ca39257de8983babb95f7f5d589a4e555a864 (patch) | |
tree | 3f41f5e38cc5d07e3241db716d582fa146a4ac3d /src/timers.cpp | |
parent | 59e71322cad61ff2f09664fc3e59b5446af4566a (diff) | |
parent | 9ec64ce60cad6c825b7cf40306a359d019e2c13c (diff) |
propagate from branch 'net.randombit.botan' (head 6afe2db1f710f75bc27e189bb8bdb23613ce1ca3)
to branch 'net.randombit.botan.remove-libstate' (head e40f0dbdfd847024c30fa0092c2acefc19a550b8)
Diffstat (limited to 'src/timers.cpp')
-rw-r--r-- | src/timers.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/timers.cpp b/src/timers.cpp index 86839ad85..55ee12236 100644 --- a/src/timers.cpp +++ b/src/timers.cpp @@ -4,24 +4,19 @@ *************************************************/ #include <botan/timers.h> -#include <botan/libstate.h> +#include <botan/loadstor.h> #include <ctime> namespace Botan { /************************************************* -* Timer Access Functions * +* Get the system clock * *************************************************/ u64bit system_time() { return static_cast<u64bit>(std::time(0)); } -u64bit system_clock() - { - return global_state().system_clock(); - } - /************************************************* * Default Timer clock reading * *************************************************/ @@ -31,11 +26,24 @@ u64bit Timer::clock() const } /************************************************* +* Read the clock and return the output * +*************************************************/ +u32bit Timer::slow_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; + } + +/************************************************* * Combine a two time values into a single one * *************************************************/ u64bit Timer::combine_timers(u32bit seconds, u32bit parts, u32bit parts_hz) { - const u64bit NANOSECONDS_UNITS = 1000000000; + static const u64bit NANOSECONDS_UNITS = 1000000000; parts *= (NANOSECONDS_UNITS / parts_hz); return ((seconds * NANOSECONDS_UNITS) + parts); } |