aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/api/odp_time.h
blob: 4f510708d4c91a3782eb811ff9dbcc51c0d2bf51 (plain)
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
76
77
78
79
80
/* Copyright (c) 2013, Linaro Limited
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */


/**
 * @file
 *
 * ODP time
 */

#ifndef ODP_TIME_H_
#define ODP_TIME_H_

#ifdef __cplusplus
extern "C" {
#endif


#include <odp_std_types.h>

/** @defgroup odp_system ODP SYSTEM
 *  @{
 */

/* Time in nanoseconds */
#define ODP_TIME_USEC 1000UL       /**< Microsecond in nsec */
#define ODP_TIME_MSEC 1000000UL    /**< Millisecond in nsec */
#define ODP_TIME_SEC  1000000000UL /**< Second in nsec */


/**
 * Current time in CPU cycles
 *
 * @return Current time in CPU cycles
 */
uint64_t odp_time_cycles(void);


/**
 * Time difference
 *
 * @param t1    First time stamp
 * @param t2    Second time stamp
 *
 * @return Difference of time stamps in CPU cycles
 */
uint64_t odp_time_diff_cycles(uint64_t t1, uint64_t t2);


/**
 * Convert CPU cycles to nanoseconds
 *
 * @param cycles  Time in CPU cycles
 *
 * @return Time in nanoseconds
 */
uint64_t odp_time_cycles_to_ns(uint64_t cycles);


/**
 * Convert nanoseconds to CPU cycles
 *
 * @param ns      Time in nanoseconds
 *
 * @return Time in CPU cycles
 */
uint64_t odp_time_ns_to_cycles(uint64_t ns);

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif