mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Inclusion of any nolibc header file should also bring all other headers. On the other hand it should also be possible to include any nolibc header files in any order. Currently this is implemented by including the catch-all nolibc.h after the headers own definitions. This is problematic if one nolibc header depends on another one. The first header has to include the other one before defining any symbols. That in turn will include the rest of nolibc while the current header has not defined anything yet. If any other part of nolibc depends on definitions from the current header, errors are encountered. This is already the case today. Effectively nolibc can only be included in the order of nolibc.h. Restructure the way "nolibc.h" is included. Move it to the beginning of the header files and before the include guards. Now any header will behave exactly like "nolibc.h" while the include guards prevent any duplicate definitions. Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250424-nolibc-header-check-v1-2-011576b6ed6f@linutronix.de
41 lines
636 B
C
41 lines
636 B
C
/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
|
|
/*
|
|
* auxv definitions for NOLIBC
|
|
* Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
|
|
*/
|
|
|
|
/* make sure to include all global symbols */
|
|
#include "../nolibc.h"
|
|
|
|
#ifndef _NOLIBC_SYS_AUXV_H
|
|
#define _NOLIBC_SYS_AUXV_H
|
|
|
|
#include "../crt.h"
|
|
|
|
static __attribute__((unused))
|
|
unsigned long getauxval(unsigned long type)
|
|
{
|
|
const unsigned long *auxv = _auxv;
|
|
unsigned long ret;
|
|
|
|
if (!auxv)
|
|
return 0;
|
|
|
|
while (1) {
|
|
if (!auxv[0] && !auxv[1]) {
|
|
ret = 0;
|
|
break;
|
|
}
|
|
|
|
if (auxv[0] == type) {
|
|
ret = auxv[1];
|
|
break;
|
|
}
|
|
|
|
auxv += 2;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
#endif /* _NOLIBC_SYS_AUXV_H */
|