aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/odp/api/plat/thread_inlines.h
blob: ecab29e5432b7b0e74a56bb995c01d80f81ad1d1 (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
/* Copyright (c) 2018-2018, Linaro Limited
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#ifndef ODP_PLAT_THREAD_INLINES_H_
#define ODP_PLAT_THREAD_INLINES_H_

#ifdef __cplusplus
extern "C" {
#endif

/** @cond _ODP_HIDE_FROM_DOXYGEN_ */

typedef struct {
	int thr;
	int cpu;
	odp_thread_type_t type;

} _odp_thread_state_t;

extern __thread _odp_thread_state_t *_odp_this_thread;

#ifndef _ODP_NO_INLINE
	/* Inline functions by default */
	#define _ODP_INLINE static inline
	#define odp_thread_id __odp_thread_id
	#define odp_thread_type __odp_thread_type
	#define odp_cpu_id __odp_cpu_id
#else
	#define _ODP_INLINE
#endif

_ODP_INLINE int odp_thread_id(void)
{
	return _odp_this_thread->thr;
}

_ODP_INLINE odp_thread_type_t odp_thread_type(void)
{
	return _odp_this_thread->type;
}

_ODP_INLINE int odp_cpu_id(void)
{
	return _odp_this_thread->cpu;
}

/** @endcond */

#ifdef __cplusplus
}
#endif

#endif