tools/nolibc: implement strerror()

strerror() is commonly used.
For example in kselftest which currently needs to do an #ifdef NOLIBC to
handle the lack of strerror().

Keep it simple and reuse the output format of perror() for strerror().

Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
This commit is contained in:
Thomas Weißschuh
2024-04-26 13:08:57 +02:00
parent 582facfa5a
commit d20d0b10f8
2 changed files with 14 additions and 0 deletions

View File

@@ -376,6 +376,16 @@ int setvbuf(FILE *stream __attribute__((unused)),
return 0;
}
static __attribute__((unused))
const char *strerror(int errno)
{
static char buf[18] = "errno=";
i64toa_r(errno, &buf[6]);
return buf;
}
/* make sure to include all global symbols */
#include "nolibc.h"