xref: /dpdk/lib/eal/include/rte_per_lcore.h (revision 719834a6849e1daf4a70ff7742bbcc3ae7e25607)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2010-2014 Intel Corporation
399a2dd95SBruce Richardson  */
499a2dd95SBruce Richardson 
599a2dd95SBruce Richardson #ifndef _RTE_PER_LCORE_H_
699a2dd95SBruce Richardson #define _RTE_PER_LCORE_H_
799a2dd95SBruce Richardson 
899a2dd95SBruce Richardson /**
999a2dd95SBruce Richardson  * @file
1099a2dd95SBruce Richardson  *
1199a2dd95SBruce Richardson  * Per-lcore variables in RTE
1299a2dd95SBruce Richardson  *
1399a2dd95SBruce Richardson  * This file defines an API for instantiating per-lcore "global
1499a2dd95SBruce Richardson  * variables" that are environment-specific. Note that in all
1599a2dd95SBruce Richardson  * environments, a "shared variable" is the default when you use a
1699a2dd95SBruce Richardson  * global variable.
1799a2dd95SBruce Richardson  *
1899a2dd95SBruce Richardson  * Parts of this are execution environment specific.
1999a2dd95SBruce Richardson  */
2099a2dd95SBruce Richardson 
21b2f967dcSTyler Retzlaff #ifdef RTE_TOOLCHAIN_MSVC
22a4b74fc6STyler Retzlaff #define RTE_DEFINE_PER_LCORE(type, name)			\
23*e578789dSTyler Retzlaff 	__declspec(thread) type per_lcore_##name
24a4b74fc6STyler Retzlaff 
25a4b74fc6STyler Retzlaff #define RTE_DECLARE_PER_LCORE(type, name)			\
26*e578789dSTyler Retzlaff 	extern __declspec(thread) type per_lcore_##name
27a4b74fc6STyler Retzlaff #else
2899a2dd95SBruce Richardson /**
2999a2dd95SBruce Richardson  * Macro to define a per lcore variable "var" of type "type", don't
3099a2dd95SBruce Richardson  * use keywords like "static" or "volatile" in type, just prefix the
3199a2dd95SBruce Richardson  * whole macro.
3299a2dd95SBruce Richardson  */
3399a2dd95SBruce Richardson #define RTE_DEFINE_PER_LCORE(type, name)			\
34*e578789dSTyler Retzlaff 	__thread type per_lcore_##name
3599a2dd95SBruce Richardson 
3699a2dd95SBruce Richardson /**
3799a2dd95SBruce Richardson  * Macro to declare an extern per lcore variable "var" of type "type"
3899a2dd95SBruce Richardson  */
3999a2dd95SBruce Richardson #define RTE_DECLARE_PER_LCORE(type, name)			\
40*e578789dSTyler Retzlaff 	extern __thread type per_lcore_##name
41b2f967dcSTyler Retzlaff #endif
4299a2dd95SBruce Richardson 
4399a2dd95SBruce Richardson /**
4499a2dd95SBruce Richardson  * Read/write the per-lcore variable value
4599a2dd95SBruce Richardson  */
4699a2dd95SBruce Richardson #define RTE_PER_LCORE(name) (per_lcore_##name)
4799a2dd95SBruce Richardson 
4899a2dd95SBruce Richardson #endif /* _RTE_PER_LCORE_H_ */
49