xref: /linux/tools/include/nolibc/sys/auxv.h (revision 015a99fa76650e7d6efa3e36f20c0f5b346fe9ce)
19e67941dSThomas Weißschuh /* SPDX-License-Identifier: LGPL-2.1 OR MIT */
29e67941dSThomas Weißschuh /*
39e67941dSThomas Weißschuh  * auxv definitions for NOLIBC
49e67941dSThomas Weißschuh  * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
59e67941dSThomas Weißschuh  */
69e67941dSThomas Weißschuh 
7*3785289fSThomas Weißschuh /* make sure to include all global symbols */
8*3785289fSThomas Weißschuh #include "../nolibc.h"
9*3785289fSThomas Weißschuh 
109e67941dSThomas Weißschuh #ifndef _NOLIBC_SYS_AUXV_H
119e67941dSThomas Weißschuh #define _NOLIBC_SYS_AUXV_H
129e67941dSThomas Weißschuh 
139e67941dSThomas Weißschuh #include "../crt.h"
149e67941dSThomas Weißschuh 
159e67941dSThomas Weißschuh static __attribute__((unused))
getauxval(unsigned long type)169e67941dSThomas Weißschuh unsigned long getauxval(unsigned long type)
179e67941dSThomas Weißschuh {
189e67941dSThomas Weißschuh 	const unsigned long *auxv = _auxv;
199e67941dSThomas Weißschuh 	unsigned long ret;
209e67941dSThomas Weißschuh 
219e67941dSThomas Weißschuh 	if (!auxv)
229e67941dSThomas Weißschuh 		return 0;
239e67941dSThomas Weißschuh 
249e67941dSThomas Weißschuh 	while (1) {
259e67941dSThomas Weißschuh 		if (!auxv[0] && !auxv[1]) {
269e67941dSThomas Weißschuh 			ret = 0;
279e67941dSThomas Weißschuh 			break;
289e67941dSThomas Weißschuh 		}
299e67941dSThomas Weißschuh 
309e67941dSThomas Weißschuh 		if (auxv[0] == type) {
319e67941dSThomas Weißschuh 			ret = auxv[1];
329e67941dSThomas Weißschuh 			break;
339e67941dSThomas Weißschuh 		}
349e67941dSThomas Weißschuh 
359e67941dSThomas Weißschuh 		auxv += 2;
369e67941dSThomas Weißschuh 	}
379e67941dSThomas Weißschuh 
389e67941dSThomas Weißschuh 	return ret;
399e67941dSThomas Weißschuh }
409e67941dSThomas Weißschuh 
419e67941dSThomas Weißschuh #endif /* _NOLIBC_SYS_AUXV_H */
42