-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththorax_time.hh
More file actions
75 lines (55 loc) · 1.9 KB
/
Copy paththorax_time.hh
File metadata and controls
75 lines (55 loc) · 1.9 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef THORAX_TIME_H_
#define THORAX_TIME_H_
#include "thorax_types.hh"
#ifndef _WIN32
#include <sys/time.h>
#else
#include <Windows.h>
#endif
#include <time.h>
#include <string>
#ifndef NSEC_PER_SEC
#define NSEC_PER_SEC 1000000000
#endif
#ifndef SEC_PER_NSEC
#define SEC_PER_NSEC 1.e-9
#endif
#ifdef __MACH__
#include <mach/mach_time.h>
#ifndef MACNANO
#define MACNANO (+1.0E-9)
#define MACGIGA UINT64_C(1000000000)
#endif // MACNANO
#endif // __MACH__
namespace thorax
{
#ifdef __MACH__
extern double thorax_timebase;
extern time_nsec_type thorax_timestart;
#endif // __MACH__
extern THORAX_API char date_time_format[];
#ifdef _WIN32
struct timespec
{
time_t tv_sec;
long tv_nsec;
#ifdef __cplusplus
inline bool operator==( const timespec& rhs ) const { return tv_nsec==rhs.tv_nsec && tv_sec==rhs.tv_sec; }
inline bool operator<( const timespec& rhs ) const { return tv_sec != rhs.tv_sec ? tv_sec < rhs.tv_sec : tv_nsec < rhs.tv_nsec; }
#endif
};
THORAX_API LARGE_INTEGER getFILETIMEoffset();
THORAX_API int clock_gettime( int X, struct timespec* tv );
#else
inline bool operator==( const timespec& lhs, const timespec& rhs ) { return lhs.tv_nsec==rhs.tv_nsec && lhs.tv_sec==rhs.tv_sec; }
inline bool operator<( const timespec& lhs, const timespec& rhs ) { return lhs.tv_sec != rhs.tv_sec ? lhs.tv_sec < rhs.tv_sec : lhs.tv_nsec < rhs.tv_nsec; }
#endif
THORAX_API int get_time_monotonic( struct timespec* time );
THORAX_API int get_time_current( struct timespec* time );
THORAX_API time_nsec_type time_to_nsec( struct timespec time );
THORAX_API double time_to_sec( struct timespec time );
THORAX_API void time_diff( struct timespec start, struct timespec end, struct timespec* diff );
THORAX_API size_t get_time_absolute_str( char* ptr );
THORAX_API std::string get_absolute_time_string();
}
#endif // THORAX_TIME_H_