1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 Red Hat, Inc.
10 #if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
11 #if __GLIBC_PREREQ(2, 16)
17 #include <rte_cpuflags.h>
21 getauxval(unsigned long type __rte_unused)
29 typedef Elf64_auxv_t Internal_Elfx_auxv_t;
31 typedef Elf32_auxv_t Internal_Elfx_auxv_t;
35 * Provides a method for retrieving values from the auxiliary vector and
36 * possibly running a string comparison.
38 * @return Always returns a result. When the result is 0, check errno
39 * to see if an error occurred during processing.
42 _rte_cpu_getauxval(unsigned long type, const char *str)
47 val = getauxval(type);
49 if (!val && (errno == ENOTSUP || errno == ENOENT)) {
50 int auxv_fd = open("/proc/self/auxv", O_RDONLY);
51 Internal_Elfx_auxv_t auxv;
57 while (read(auxv_fd, &auxv, sizeof(auxv)) == sizeof(auxv)) {
58 if (auxv.a_type == type) {
60 val = auxv.a_un.a_val;
62 val = strcmp((const char *)val, str);
73 rte_cpu_getauxval(unsigned long type)
75 return _rte_cpu_getauxval(type, NULL);
79 rte_cpu_strcmp_auxval(unsigned long type, const char *str)
81 return _rte_cpu_getauxval(type, str);