blob: 1bed0e51df08167fff0de6972d00bd199d122736 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/*************************************************
* Timestamp Functions Source File *
* (C) 1999-2006 The Botan Project *
*************************************************/
#include <botan/timers.h>
#include <botan/libstate.h>
#include <botan/util.h>
#include <ctime>
namespace Botan {
/*************************************************
* Timer Access Functions *
*************************************************/
u64bit system_time()
{
return std::time(0);
}
u64bit system_clock()
{
return global_state().system_clock();
}
/*************************************************
* Default Timer clock reading *
*************************************************/
u64bit Timer::clock() const
{
return combine_timers(std::time(0), std::clock(), CLOCKS_PER_SEC);
}
/*************************************************
* Combine a two time values into a single one *
*************************************************/
u64bit combine_timers(u32bit seconds, u32bit parts, u32bit parts_hz)
{
const u64bit NANOSECONDS_UNITS = 1000000000;
parts *= (NANOSECONDS_UNITS / parts_hz);
return ((seconds * NANOSECONDS_UNITS) + parts);
}
}
|