1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
10 #include <sys/types.h>
13 #if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
14 #if __GLIBC_PREREQ(2, 16)
20 #include <rte_common.h>
21 #include <rte_cpuflags.h>
25 getauxval(unsigned long type)
33 typedef Elf64_auxv_t Internal_Elfx_auxv_t;
35 typedef Elf32_auxv_t Internal_Elfx_auxv_t;
40 * Provides a method for retrieving values from the auxiliary vector and
41 * possibly running a string comparison.
43 * @return Always returns a result. When the result is 0, check errno
44 * to see if an error occurred during processing.
47 _rte_cpu_getauxval(unsigned long type, const char *str)
52 val = getauxval(type);
54 if (!val && (errno == ENOTSUP || errno == ENOENT)) {
55 int auxv_fd = open("/proc/self/auxv", O_RDONLY);
56 Internal_Elfx_auxv_t auxv;
62 while (read(auxv_fd, &auxv, sizeof(auxv)) == sizeof(auxv)) {
63 if (auxv.a_type == type) {
65 val = auxv.a_un.a_val;
67 val = strcmp((const char *)val, str);
78 rte_cpu_getauxval(unsigned long type)
80 return _rte_cpu_getauxval(type, NULL);
84 rte_cpu_strcmp_auxval(unsigned long type, const char *str)
86 return _rte_cpu_getauxval(type, str);
90 * Checks if the machine is adequate for running the binary. If it is not, the
91 * program exits with status 1.
94 rte_cpu_check_supported(void)
96 if (!rte_cpu_is_supported())
101 rte_cpu_is_supported(void)
103 /* This is generated at compile-time by the build system */
104 static const enum rte_cpu_flag_t compile_time_flags[] = {
105 RTE_COMPILE_TIME_CPUFLAGS
107 unsigned count = RTE_DIM(compile_time_flags), i;
110 for (i = 0; i < count; i++) {
111 ret = rte_cpu_get_flag_enabled(compile_time_flags[i]);
115 "ERROR: CPU feature flag lookup failed with error %d\n",
121 "ERROR: This system does not support \"%s\".\n"
122 "Please check that RTE_MACHINE is set correctly.\n",
123 rte_cpu_get_flag_name(compile_time_flags[i]));