Better sparse support.
[bertos.git] / os / hptime.h
1 /**
2  * \file
3  * <!--
4  * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
5  * This file is part of DevLib - See README.devlib for information.
6  * -->
7  *
8  * \brief Portable abstraction for high-resolution time handling (interface)
9  *
10  * \author Bernardo Innocenti <bernie@develer.com>
11  */
12 #ifndef HPTIME_H
13 #define HPTIME_H
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif /* __cplusplus */
18
19 #ifdef _WIN32
20
21         /** our type for "high precision absolute time" */
22         typedef __int64 hptime_t;
23
24         #define HPTIME_TICKS_PER_SECOND         (10000000I64)
25         #define HPTIME_TICKS_PER_MILLISEC       (10000I64)
26         #define HPTIME_TICKS_PER_MICRO          (10I64)
27
28 #elif defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
29
30         #include <stdint.h> /* int64_t */
31
32         #ifndef DEVLIB_MTIME_DEFINED
33                 #define DEVLIB_MTIME_DEFINED 1 /* Resolve conflict with <cfg/compiler.h> */
34                 typedef int32_t mtime_t;
35                 #define SIZEOF_MTIME_T (32 / CPU_BITS_PER_CHAR)
36                 #define MTIME_INFINITE 0x7FFFFFFFL
37         #endif
38
39         /** Type for "high precision absolute time". */
40         typedef int64_t hptime_t;
41
42         #define HPTIME_TICKS_PER_SECOND         (1000000LL)
43         #define HPTIME_TICKS_PER_MILLISEC       (1000LL)
44         #define HPTIME_TICKS_PER_MICRO          (1LL)
45
46 #else /* !__unix__ */
47         #error OS dependent support code missing for this OS
48 #endif /* !__unix__ */
49
50 /**
51  * Return the current time with the maximum precision made available from the hosting OS
52  */
53 extern hptime_t hptime_get(void);
54
55 #ifdef __cplusplus
56 }
57 #endif /* __cplusplus */
58
59 #endif /* HPTIME_H */