Fixes for nolibc for v6.2

This series addresses the following bugs:

o	The fd_set structure was incorrectly defined as arrays of u32
	instead of long, which breaks BE64. Fix courtesy of Sven Schnelle.

o	S_ISxxx macros were incorrectly testing the bits after applying
	them instead of bitwise ANDing S_FMT with the value. Fix from
	Warner Losh.

o	The mips code was randomly broken due to an unprotected
	"noreorder" directive in the _start code that could prevent the
	assembler from filling delayed slots.  This in turn resulted
	in random other instructions being placed into those slots.
	Fix courtesy of Willy Tarreau.

o	The current nolibc header layout refrains from including files
	that are not explicitly included by the code using nolibc.
	Unfortunately, this causes build failures when such files
	contain definitions that are used (for example) by libgcc.
	Example definitions include raise() and memset(), which are called
	by some architectures, but only at certain optimization levels.
	Fix courtesy of Willy Tarreau.

o	gcc 11.3 in ARM thumb2 mode at -O2 recognized a memset()
	construction inside the memset() definition.  The compiler
	replaced this construction with a call to... memset().	Userland
	cannot be forced to build with -ffreestanding, so an empty asm()
	statement was introduced into the loop the loop in order to
	prevent the compiler from making this unproductive transformation.
	Fix courtesy of Willy Tarreau.

o	Most of the O_* macros were wrong on RISCV because their
	octal values were coded as hexadecimal.  This resulted in the
	getdents64() selftest failing.	Fix courtesy of Willy Tarreau.

The series was tested on x86_64, i386, armv5, armv7, thumb1, thumb2,
mips and riscv, all at -O0, -Os and -O3.
tools/nolibc: fix the O_* fcntl/open macro definitions for riscv

When RISCV port was imported in 5.2, the O_* macros were taken with
their octal value and written as-is in hex, resulting in the getdents64()
to fail in nolibc-test.

Fixes: 582e84f7b779 ("tool headers nolibc: add RISCV support") #5.2
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 file changed