aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/odp/api/plat/timer_inlines.h
blob: 648459c788c67ab034561889ae3f3b4b21db29fa (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
81
82
83
84
85
/* Copyright (c) 2022, Nokia
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#ifndef ODP_PLAT_TIMER_INLINES_H_
#define ODP_PLAT_TIMER_INLINES_H_

#include <odp/api/event.h>
#include <odp/api/timer_types.h>

#include <odp/api/plat/debug_inlines.h>
#include <odp/api/plat/timer_inline_types.h>

#include <stdint.h>

/** @cond _ODP_HIDE_FROM_DOXYGEN_ */

#ifndef _ODP_NO_INLINE
	/* Inline functions by default */
	#define _ODP_INLINE static inline
	#define odp_timeout_timer __odp_timeout_timer
	#define odp_timeout_tick __odp_timeout_tick
	#define odp_timeout_user_ptr __odp_timeout_user_ptr
	#define odp_timeout_user_area __odp_timeout_user_area
	#define odp_timer_tick_to_ns __odp_timer_tick_to_ns
	#define odp_timer_ns_to_tick __odp_timer_ns_to_tick
	#define odp_timeout_from_event __odp_timeout_from_event
	#define odp_timeout_to_event __odp_timeout_to_event
#else
	#define _ODP_INLINE
#endif

_ODP_INLINE odp_timer_t odp_timeout_timer(odp_timeout_t tmo)
{
	return _odp_timeout_hdr_field(tmo, odp_timer_t, timer);
}

_ODP_INLINE uint64_t odp_timeout_tick(odp_timeout_t tmo)
{
	return _odp_timeout_hdr_field(tmo, uint64_t, expiration);
}

_ODP_INLINE void *odp_timeout_user_ptr(odp_timeout_t tmo)
{
	return _odp_timeout_hdr_field(tmo, void *, user_ptr);
}

_ODP_INLINE void *odp_timeout_user_area(odp_timeout_t tmo)
{
	return _odp_timeout_hdr_field(tmo, void *, uarea_addr);
}

_ODP_INLINE uint64_t odp_timer_tick_to_ns(odp_timer_pool_t tp, uint64_t ticks)
{
	(void)tp;

	/* Timer ticks in API are nsec */
	return ticks;
}

_ODP_INLINE uint64_t odp_timer_ns_to_tick(odp_timer_pool_t tp, uint64_t ns)
{
	(void)tp;

	/* Timer ticks in API are nsec */
	return ns;
}

_ODP_INLINE odp_timeout_t odp_timeout_from_event(odp_event_t ev)
{
	_ODP_ASSERT(odp_event_type(ev) == ODP_EVENT_TIMEOUT);

	return (odp_timeout_t)ev;
}

_ODP_INLINE odp_event_t odp_timeout_to_event(odp_timeout_t tmo)
{
	return (odp_event_t)tmo;
}

/** @endcond */

#endif