xref: /dpdk/lib/eal/include/rte_per_lcore.h (revision 719834a6849e1daf4a70ff7742bbcc3ae7e25607)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 
5 #ifndef _RTE_PER_LCORE_H_
6 #define _RTE_PER_LCORE_H_
7 
8 /**
9  * @file
10  *
11  * Per-lcore variables in RTE
12  *
13  * This file defines an API for instantiating per-lcore "global
14  * variables" that are environment-specific. Note that in all
15  * environments, a "shared variable" is the default when you use a
16  * global variable.
17  *
18  * Parts of this are execution environment specific.
19  */
20 
21 #ifdef RTE_TOOLCHAIN_MSVC
22 #define RTE_DEFINE_PER_LCORE(type, name)			\
23 	__declspec(thread) type per_lcore_##name
24 
25 #define RTE_DECLARE_PER_LCORE(type, name)			\
26 	extern __declspec(thread) type per_lcore_##name
27 #else
28 /**
29  * Macro to define a per lcore variable "var" of type "type", don't
30  * use keywords like "static" or "volatile" in type, just prefix the
31  * whole macro.
32  */
33 #define RTE_DEFINE_PER_LCORE(type, name)			\
34 	__thread type per_lcore_##name
35 
36 /**
37  * Macro to declare an extern per lcore variable "var" of type "type"
38  */
39 #define RTE_DECLARE_PER_LCORE(type, name)			\
40 	extern __thread type per_lcore_##name
41 #endif
42 
43 /**
44  * Read/write the per-lcore variable value
45  */
46 #define RTE_PER_LCORE(name) (per_lcore_##name)
47 
48 #endif /* _RTE_PER_LCORE_H_ */
49