xref: /linux/tools/include/nolibc/sys/auxv.h (revision 7fc2cd2e4b398c57c9cf961cfea05eadbf34c05c)
1 /* SPDX-License-Identifier: LGPL-2.1 OR MIT */
2 /*
3  * auxv definitions for NOLIBC
4  * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
5  */
6 
7 /* make sure to include all global symbols */
8 #include "../nolibc.h"
9 
10 #ifndef _NOLIBC_SYS_AUXV_H
11 #define _NOLIBC_SYS_AUXV_H
12 
13 #ifndef NOLIBC_NO_RUNTIME
14 
15 #include "../crt.h"
16 
17 static __attribute__((unused))
18 unsigned long getauxval(unsigned long type)
19 {
20 	const unsigned long *auxv = _auxv;
21 	unsigned long ret;
22 
23 	if (!auxv)
24 		return 0;
25 
26 	while (1) {
27 		if (!auxv[0] && !auxv[1]) {
28 			ret = 0;
29 			break;
30 		}
31 
32 		if (auxv[0] == type) {
33 			ret = auxv[1];
34 			break;
35 		}
36 
37 		auxv += 2;
38 	}
39 
40 	return ret;
41 }
42 
43 #endif /* NOLIBC_NO_RUNTIME */
44 #endif /* _NOLIBC_SYS_AUXV_H */
45