aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/powerpc/pmu/lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/powerpc/pmu/lib.c')
-rw-r--r--tools/testing/selftests/powerpc/pmu/lib.c47
1 files changed, 0 insertions, 47 deletions
diff --git a/tools/testing/selftests/powerpc/pmu/lib.c b/tools/testing/selftests/powerpc/pmu/lib.c
index 9768dea37bf3..a07104c2afe6 100644
--- a/tools/testing/selftests/powerpc/pmu/lib.c
+++ b/tools/testing/selftests/powerpc/pmu/lib.c
@@ -5,15 +5,10 @@
5 5
6#define _GNU_SOURCE /* For CPU_ZERO etc. */ 6#define _GNU_SOURCE /* For CPU_ZERO etc. */
7 7
8#include <elf.h>
9#include <errno.h> 8#include <errno.h>
10#include <fcntl.h>
11#include <link.h>
12#include <sched.h> 9#include <sched.h>
13#include <setjmp.h> 10#include <setjmp.h>
14#include <stdlib.h> 11#include <stdlib.h>
15#include <sys/stat.h>
16#include <sys/types.h>
17#include <sys/wait.h> 12#include <sys/wait.h>
18 13
19#include "utils.h" 14#include "utils.h"
@@ -256,45 +251,3 @@ out:
256 return rc; 251 return rc;
257} 252}
258 253
259static char auxv[4096];
260
261void *get_auxv_entry(int type)
262{
263 ElfW(auxv_t) *p;
264 void *result;
265 ssize_t num;
266 int fd;
267
268 fd = open("/proc/self/auxv", O_RDONLY);
269 if (fd == -1) {
270 perror("open");
271 return NULL;
272 }
273
274 result = NULL;
275
276 num = read(fd, auxv, sizeof(auxv));
277 if (num < 0) {
278 perror("read");
279 goto out;
280 }
281
282 if (num > sizeof(auxv)) {
283 printf("Overflowed auxv buffer\n");
284 goto out;
285 }
286
287 p = (ElfW(auxv_t) *)auxv;
288
289 while (p->a_type != AT_NULL) {
290 if (p->a_type == type) {
291 result = (void *)p->a_un.a_val;
292 break;
293 }
294
295 p++;
296 }
297out:
298 close(fd);
299 return result;
300}