monotone

monotone Mtn Source Tree

Root/botan/timers.cpp

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

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status