aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/odp/api/plat/cpu_inlines.h
blob: 0a1627b795ad438dcb9532f0a576acc83a08d2d7 (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
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright (c) 2018 Linaro Limited
 * Copyright (c) 2021-2023 Nokia
 */

#ifndef ODP_PLAT_CPU_INLINES_H_
#define ODP_PLAT_CPU_INLINES_H_

#include <odp/api/hints.h>

#include <odp/api/abi/cpu_inlines.h>

#include <stdint.h>

/** @cond _ODP_HIDE_FROM_DOXYGEN_ */

#ifndef _ODP_NO_INLINE
	/* Inline functions by default */
	#define _ODP_INLINE static inline
	#define odp_cpu_pause             __odp_cpu_pause
	#define odp_cpu_cycles            __odp_cpu_cycles
	#define odp_cpu_cycles_max        __odp_cpu_cycles_max
	#define odp_cpu_cycles_resolution __odp_cpu_cycles_resolution
	#define odp_cpu_cycles_diff       __odp_cpu_cycles_diff
#else
	#define _ODP_INLINE
#endif

_ODP_INLINE void odp_cpu_pause(void)
{
	_odp_cpu_pause();
}

_ODP_INLINE uint64_t odp_cpu_cycles_max(void)
{
	return _odp_cpu_cycles_max();
}

_ODP_INLINE uint64_t odp_cpu_cycles_resolution(void)
{
	return _odp_cpu_cycles_resolution();
}

_ODP_INLINE uint64_t odp_cpu_cycles(void)
{
	return _odp_cpu_cycles();
}

_ODP_INLINE uint64_t odp_cpu_cycles_diff(uint64_t c2, uint64_t c1)
{
	if (odp_likely(c2 >= c1))
		return c2 - c1;

	return c2 + (odp_cpu_cycles_max() - c1) + _odp_cpu_cycles_resolution();
}

/** @endcond */

#endif