diff --git a/lib/librte_eal/common/eal_common_cpuflags.c b/lib/librte_eal/common/eal_common_cpuflags.c index 6fd360c..07c1e7b 100644 --- a/lib/librte_eal/common/eal_common_cpuflags.c +++ b/lib/librte_eal/common/eal_common_cpuflags.c @@ -30,6 +30,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define RTE_INSTANTIATE_CPU_FEATURES 1 #include /* @@ -78,7 +79,7 @@ rte_cpu_check_supported(void) fprintf(stderr, "ERROR: This system does not support \"%s\".\n" "Please check that RTE_MACHINE is set correctly.\n", - cpu_feature_table[compile_time_flags[i]].name); + rte_cpu_feature_table[compile_time_flags[i]].name); exit(1); } } diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_cpuflags.h b/lib/librte_eal/common/include/arch/ppc_64/rte_cpuflags.h index df45047..3dfa6d2 100644 --- a/lib/librte_eal/common/include/arch/ppc_64/rte_cpuflags.h +++ b/lib/librte_eal/common/include/arch/ppc_64/rte_cpuflags.h @@ -42,8 +42,6 @@ extern "C" { #include #include -#include "generic/rte_cpuflags.h" - /* Symbolic values for the entries in the auxiliary table */ #define AT_HWCAP 16 #define AT_HWCAP2 26 @@ -96,7 +94,10 @@ enum rte_cpu_flag_t { RTE_CPUFLAG_NUMFLAGS,/**< This should always be the last! */ }; -static const struct feature_entry cpu_feature_table[] = { +#include "generic/rte_cpuflags.h" + +#ifdef RTE_INSTANTIATE_CPU_FEATURES +const struct feature_entry rte_cpu_feature_table[] = { FEAT_DEF(PPC_LE, 0x00000001, 0, REG_HWCAP, 0) FEAT_DEF(TRUE_LE, 0x00000001, 0, REG_HWCAP, 1) FEAT_DEF(PSERIES_PERFMON_COMPAT, 0x00000001, 0, REG_HWCAP, 6) @@ -132,6 +133,7 @@ static const struct feature_entry cpu_feature_table[] = { FEAT_DEF(HTM, 0x00000001, 0, REG_HWCAP2, 30) FEAT_DEF(ARCH_2_07, 0x00000001, 0, REG_HWCAP2, 31) }; +#endif /* * Read AUXV software register and get cpu features for Power @@ -167,7 +169,7 @@ rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) /* Flag does not match anything in the feature tables */ return -ENOENT; - feat = &cpu_feature_table[feature]; + feat = &rte_cpu_feature_table[feature]; if (!feat->leaf) /* This entry in the table wasn't filled out! */ diff --git a/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h b/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h index dd56553..a4a8d19 100644 --- a/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h +++ b/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h @@ -43,8 +43,6 @@ extern "C" { #include #include -#include "generic/rte_cpuflags.h" - enum rte_cpu_flag_t { /* (EAX 01h) ECX features*/ RTE_CPUFLAG_SSE3 = 0, /**< SSE3 */ @@ -157,7 +155,10 @@ enum cpu_register_t { RTE_REG_EDX, }; -static const struct feature_entry cpu_feature_table[] = { +#include "generic/rte_cpuflags.h" + +#ifdef RTE_INSTANTIATE_CPU_FEATURES +const struct feature_entry rte_cpu_feature_table[] = { FEAT_DEF(SSE3, 0x00000001, 0, RTE_REG_ECX, 0) FEAT_DEF(PCLMULQDQ, 0x00000001, 0, RTE_REG_ECX, 1) FEAT_DEF(DTES64, 0x00000001, 0, RTE_REG_ECX, 2) @@ -250,6 +251,7 @@ static const struct feature_entry cpu_feature_table[] = { FEAT_DEF(INVTSC, 0x80000007, 0, RTE_REG_EDX, 8) }; +#endif static inline void rte_cpu_get_features(uint32_t leaf, uint32_t subleaf, cpuid_registers_t out) @@ -285,7 +287,7 @@ rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) /* Flag does not match anything in the feature tables */ return -ENOENT; - feat = &cpu_feature_table[feature]; + feat = &rte_cpu_feature_table[feature]; if (!feat->leaf) /* This entry in the table wasn't filled out! */ diff --git a/lib/librte_eal/common/include/generic/rte_cpuflags.h b/lib/librte_eal/common/include/generic/rte_cpuflags.h index a04e021..760539f 100644 --- a/lib/librte_eal/common/include/generic/rte_cpuflags.h +++ b/lib/librte_eal/common/include/generic/rte_cpuflags.h @@ -39,6 +39,10 @@ * Architecture specific API to determine available CPU features at runtime. */ +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -75,7 +79,7 @@ struct feature_entry { /** * An array that holds feature entries */ -static const struct feature_entry cpu_feature_table[]; +extern const struct feature_entry rte_cpu_feature_table[]; /** * Execute CPUID instruction and get contents of a specific register @@ -107,4 +111,8 @@ rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature); void rte_cpu_check_supported(void); +#ifdef __cplusplus +} +#endif + #endif /* _RTE_CPUFLAGS_H_ */