aboutsummaryrefslogtreecommitdiff
path: root/tools/include/nolibc
diff options
context:
space:
mode:
authorThomas Weißschuh <linux@weissschuh.net>2024-04-26 13:08:57 +0200
committerThomas Weißschuh <linux@weissschuh.net>2024-06-29 09:44:57 +0200
commitd20d0b10f883085a44afd1a3af1bbd77ed53acf7 (patch)
treece3b6539dc00258926e15d48ccec772b63ede5b9 /tools/include/nolibc
parent582facfa5a71c8211714ffe74f5167d403b968a7 (diff)
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>
Diffstat (limited to 'tools/include/nolibc')
-rw-r--r--tools/include/nolibc/stdio.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h
index 16cd4d807251..c968dbbc4ef8 100644
--- a/tools/include/nolibc/stdio.h
+++ b/tools/include/nolibc/stdio.h
@@ -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"