* Provides a method for retrieving values from the auxiliary vector and * possibly running a string comparison. * * @return Always returns a result. When the result is 0, check errno * to see if an error occurred during processing. */
| 39 | * to see if an error occurred during processing. |
| 40 | */ |
| 41 | static unsigned long |
| 42 | _rte_cpu_getauxval(unsigned long type, const char *str) |
| 43 | { |
| 44 | unsigned long val; |
| 45 | |
| 46 | errno = 0; |
| 47 | val = getauxval(type); |
| 48 | |
| 49 | if (!val && (errno == ENOTSUP || errno == ENOENT)) { |
| 50 | int auxv_fd = open("/proc/self/auxv", O_RDONLY); |
| 51 | Internal_Elfx_auxv_t auxv; |
| 52 | |
| 53 | if (auxv_fd == -1) |
| 54 | return 0; |
| 55 | |
| 56 | errno = ENOENT; |
| 57 | while (read(auxv_fd, &auxv, sizeof(auxv)) == sizeof(auxv)) { |
| 58 | if (auxv.a_type == type) { |
| 59 | errno = 0; |
| 60 | val = auxv.a_un.a_val; |
| 61 | if (str) |
| 62 | val = strcmp((const char *)val, str); |
| 63 | break; |
| 64 | } |
| 65 | } |
| 66 | close(auxv_fd); |
| 67 | } |
| 68 | |
| 69 | return val; |
| 70 | } |
| 71 | |
| 72 | unsigned long |
| 73 | rte_cpu_getauxval(unsigned long type) |
no test coverage detected