blob: 74f802b8350890b36dbc7fab769ba9e57cb4365b (
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
|
/* Copyright (c) 2013, Linaro Limited
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#define _POSIX_C_SOURCE 200809L
#include <odp/time.h>
#include <odp/hints.h>
#include <odp/system_info.h>
#include <odp/cpu.h>
#include <odp_cpu_internal.h>
#define GIGA 1000000000
uint64_t odp_time_cycles(void)
{
return odp_cpu_cycles();
}
uint64_t odp_time_diff_cycles(uint64_t t1, uint64_t t2)
{
return _odp_cpu_cycles_diff(t1, t2);
}
uint64_t odp_time_cycles_to_ns(uint64_t cycles)
{
uint64_t hz = odp_sys_cpu_hz();
if (cycles > (UINT64_MAX / GIGA))
return (cycles/hz)*GIGA;
return (cycles*GIGA)/hz;
}
uint64_t odp_time_ns_to_cycles(uint64_t ns)
{
uint64_t hz = odp_sys_cpu_hz();
if (ns > (UINT64_MAX / hz))
return (ns/GIGA)*hz;
return (ns*hz)/GIGA;
}
|