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 __cplusplus 22 extern "C" { 23 #endif 24 25 #include <pthread.h> 26 27 /** 28 * Macro to define a per lcore variable "var" of type "type", don't 29 * use keywords like "static" or "volatile" in type, just prefix the 30 * whole macro. 31 */ 32 #define RTE_DEFINE_PER_LCORE(type, name) \ 33 __thread __typeof__(type) per_lcore_##name 34 35 /** 36 * Macro to declare an extern per lcore variable "var" of type "type" 37 */ 38 #define RTE_DECLARE_PER_LCORE(type, name) \ 39 extern __thread __typeof__(type) per_lcore_##name 40 41 /** 42 * Read/write the per-lcore variable value 43 */ 44 #define RTE_PER_LCORE(name) (per_lcore_##name) 45 46 #ifdef __cplusplus 47 } 48 #endif 49 50 #endif /* _RTE_PER_LCORE_H_ */ 51