Cast constants to hptime_t.
[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  * \version $Id$
11  * \author Bernardo Innocenti <bernie@develer.com>
12  */
13 #ifndef HPTIME_H
14 #define HPTIME_H
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
19
20 #ifdef _WIN32
21
22         /** our type for "high precision absolute time" */
23         typedef __int64 hptime_t;
24
25         #define HPTIME_TICKS_PER_SECOND         ((hptime_t)10000000I64)
26         #define HPTIME_TICKS_PER_MILLISEC       ((hptime_t)10000I64)
27         #define HPTIME_TICKS_PER_MICRO          ((hptime_t)10I64)
28
29 #elif defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
30
31         #include <stdint.h> /* int64_t */
32
33         /** Type for "high precision absolute time". */
34         typedef int64_t hptime_t;
35
36         #define HPTIME_TICKS_PER_SECOND         ((hptime_t)1000000LL)
37         #define HPTIME_TICKS_PER_MILLISEC       ((hptime_t)1000LL)
38         #define HPTIME_TICKS_PER_MICRO          ((hptime_t)1LL)
39
40 #else /* !__unix__ */
41         #error OS dependent support code missing for this OS
42 #endif /* !__unix__ */
43
44 /**
45  * Return the current time with the maximum precision made available from the hosting OS
46  */
47 extern hptime_t hptime_get(void);
48
49 #ifdef __cplusplus
50 }
51 #endif /* __cplusplus */
52
53 #endif /* HPTIME_H */