summaryrefslogtreecommitdiff
path: root/tools/include
diff options
context:
space:
mode:
authorThomas Weißschuh <linux@weissschuh.net>2026-04-09 17:55:28 +0200
committerThomas Weißschuh <linux@weissschuh.net>2026-04-27 09:00:50 +0200
commit80e5de852e3a619ff83e0347a5766b34fdc8aa78 (patch)
treec6b0256b5bece75913c0968d158165e83341473f /tools/include
parentf94da2b42bc84bbcdb5d1f41551295fc946c7f7e (diff)
downloadlwn-80e5de852e3a619ff83e0347a5766b34fdc8aa78.tar.gz
lwn-80e5de852e3a619ff83e0347a5766b34fdc8aa78.zip
tools/nolibc: add alloca()
Add the wide-used alloca() function. As it is highly machine and compiler dependent, just defer to the compiler builtin. This has been available since GCC 4 and clang 3. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://patch.msgid.link/20260409-nolibc-alloca-v1-1-ed02f68dfaf9@weissschuh.net
Diffstat (limited to 'tools/include')
-rw-r--r--tools/include/nolibc/Makefile1
-rw-r--r--tools/include/nolibc/alloca.h15
-rw-r--r--tools/include/nolibc/nolibc.h1
3 files changed, 17 insertions, 0 deletions
diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index f0e6e71e8335..872c318f50d4 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -20,6 +20,7 @@ OUTPUT ?= $(CURDIR)/
architectures := arm arm64 loongarch m68k mips powerpc riscv s390 sh sparc x86
arch_files := arch.h $(addsuffix .h, $(addprefix arch-, $(architectures)))
all_files := \
+ alloca.h \
assert.h \
byteswap.h \
compiler.h \
diff --git a/tools/include/nolibc/alloca.h b/tools/include/nolibc/alloca.h
new file mode 100644
index 000000000000..448233a79e6e
--- /dev/null
+++ b/tools/include/nolibc/alloca.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * alloca() for NOLIBC
+ * Copyright (C) 2026 Thomas Weißschuh <linux@weissschuh.net>
+ */
+
+/* make sure to include all global symbols */
+#include "nolibc.h"
+
+#ifndef _NOLIBC_ALLOCA_H
+#define _NOLIBC_ALLOCA_H
+
+#define alloca(size) __builtin_alloca(size)
+
+#endif /* _NOLIBC_ALLOCA_H */
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index 4b99795d7a65..faa94f247281 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -134,6 +134,7 @@
#include "byteswap.h"
#include "endian.h"
#include "assert.h"
+#include "alloca.h"
/* Used by programs to avoid std includes */
#define NOLIBC