7b05dbe6f0ad3eb09a128ebc9ee3cb18186eaafa
[bertos.git] / os / hptime.h
1 /*!
2  * \file
3  * <!--
4  * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
5  * All rights reserved.
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
14 /*
15  * $Log$
16  * Revision 1.1  2004/06/03 09:01:06  bernie
17  * Import into DevLib.
18  *
19  */
20 #ifndef HPTIME_H
21 #define HPTIME_H
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26
27 #ifdef _WIN32
28
29         /* type for time expressed in ms */
30         typedef unsigned long mtime_t;
31
32         /* our type for "high precision absolute time" */
33         typedef unsigned __int64 hptime_t;
34
35         #define HPTIME_TICKS_PER_SECOND         ((hptime_t)10000000I64)
36         #define HPTIME_TICKS_PER_MILLISEC       ((hptime_t)10000I64)
37         #define HPTIME_TICKS_PER_MICRO          ((hptime_t)10I64)
38
39 #elif defined(__unix__)
40
41         /* type for time expressed in ms */
42         typedef long mtime_t;
43
44         /* our type for "high precision absolute time" */
45         typedef long long hptime_t;
46
47         #define HPTIME_TICKS_PER_SECOND         ((hptime_t)1000000LL)
48         #define HPTIME_TICKS_PER_MILLISEC       ((hptime_t)1000LL)
49         #define HPTIME_TICKS_PER_MICRO          ((hptime_t)1LL)
50
51 #else /* !__unix__ */
52         #error OS dependent support code missing for this OS
53 #endif /* !__unix__ */
54
55 /*!
56  * Return the current time with the maximum precision made available from the hosting OS
57  */
58 extern hptime_t hptime_get(void);
59
60 #ifdef __cplusplus
61 }
62 #endif /* __cplusplus */
63
64 #endif /* HPTIME_H */