1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 Red Hat, Inc.
12 #if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
13 #if __GLIBC_PREREQ(2, 16)
19 #include <rte_cpuflags.h>
23 getauxval(unsigned long type __rte_unused)
31 typedef Elf64_auxv_t Internal_Elfx_auxv_t;
33 typedef Elf32_auxv_t Internal_Elfx_auxv_t;
37 * Provides a method for retrieving values from the auxiliary vector and
38 * possibly running a string comparison.
40 * @return Always returns a result. When the result is 0, check errno
41 * to see if an error occurred during processing.
44 _rte_cpu_getauxval(unsigned long type, const char *str)
49 val = getauxval(type);
51 if (!val && (errno == ENOTSUP || errno == ENOENT)) {
52 int auxv_fd = open("/proc/self/auxv", O_RDONLY);
53 Internal_Elfx_auxv_t auxv;
59 while (read(auxv_fd, &auxv, sizeof(auxv)) == sizeof(auxv)) {
60 if (auxv.a_type == type) {
62 val = auxv.a_un.a_val;
64 val = strcmp((const char *)val, str);
75 rte_cpu_getauxval(unsigned long type)
77 return _rte_cpu_getauxval(type, NULL);
81 rte_cpu_strcmp_auxval(unsigned long type, const char *str)
83 return _rte_cpu_getauxval(type, str);