summaryrefslogtreecommitdiff
path: root/src/regress/lib/libc/elf_aux_info/elf_aux_info.c
blob: 14870e253c0675ad9cc816f63c338f16df9bc4f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <sys/auxv.h>

#include <errno.h>
#include <stdio.h>

int
main(void)
{
	int ret = 0;
	int a;
	unsigned long b;

	/* Should always succeed */
	if (elf_aux_info(AT_PAGESZ, &a, sizeof(a)))
		ret |= 1;
	else
		fprintf(stderr, "AT_PAGESZ %d\n", a);

	/* Wrong size */
	if (elf_aux_info(AT_PAGESZ, &b, sizeof(b)) != EINVAL)
		ret |= 2;

	/* Invalid request */
	if (elf_aux_info(-1, &a, sizeof(a)) != EINVAL)
		ret |= 4;

	/* Should either succeed or fail with ENOENT if not supported */
	switch (elf_aux_info(AT_HWCAP, &b, sizeof(b))) {
	case 0:
		fprintf(stderr, "AT_HWCAP %lx\n", b);
		break;
	case ENOENT:
		break;
	default:
		ret |= 8;
	}

	/* Should either succeed or fail with ENOENT if not supported */
	switch (elf_aux_info(AT_HWCAP2, &b, sizeof(b))) {
	case 0:
		fprintf(stderr, "AT_HWCAP2 %lx\n", b);
		break;
	case ENOENT:
		break;
	default:
		ret |= 16;
	}

	if (ret)
		fprintf(stderr, "FAILED (status %x)\n", ret);

	return ret;
}