Merge branch 'upstream' into tizen
[platform/upstream/iotivity.git] / resource / c_common / oic_time / include / oic_time.h
1 //******************************************************************
2 //
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef OIC_TIME_H_
22 #define OIC_TIME_H_
23
24 #include <stdint.h>
25
26 #define MS_PER_SEC  (1000)
27 #define US_PER_SEC  (1000000)
28 #define US_PER_MS   (1000)
29 #define NS_PER_US   (1000)
30 #define NS_PER_MS   (1000000)
31
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif // __cplusplus
37
38 typedef enum
39 {
40     TIME_IN_MS = 0,
41     TIME_IN_US,
42 }OICTimePrecision;
43
44 /*
45  * If monotonic coarse/monotonic clock supported then gets current time as monotonic time
46  * in milliseconds or microseconds as the elapsed time since some unspecified starting point
47  * else gets current time in milliseconds or microseconds as the elapsed time since the epoch.
48  *
49  * For Arduino gets current time in milliseconds or microseconds since Arduino board begin
50  * running this program.
51  *
52  * @param     precision   based on this parameter, current time is returned in milliseconds or
53  *                        microseconds
54  *
55  * @note
56  *            On Arduino platform:
57  *            if the time precision is in milliseconds then the function will overflow
58  *            (go back to 0) after approximately 50 days.
59  *            if the time precision is in microseconds then the function will overflow
60  *            (go back to 0) after approximately 70minutes.
61  *
62  * @return
63  *         returns current time in milliseconds or microseconds.
64  */
65 uint64_t OICGetCurrentTime(OICTimePrecision precision);
66
67 #ifdef __cplusplus
68 }
69 #endif // __cplusplus
70 #endif // OIC_TIME_H_