From 8c6fc0c15415b32080a848bbde640e104098cf13 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Thu, 10 Jul 2025 22:18:39 +0200 Subject: Initial drop Add some riscv code Signed-off-by: Carlos Maiolino --- riscv/riscv-probe/examples/alloca/main.c | 17 +++++++++++++++++ riscv/riscv-probe/examples/alloca/rules.mk | 1 + 2 files changed, 18 insertions(+) create mode 100644 riscv/riscv-probe/examples/alloca/main.c create mode 100644 riscv/riscv-probe/examples/alloca/rules.mk (limited to 'riscv/riscv-probe/examples/alloca') diff --git a/riscv/riscv-probe/examples/alloca/main.c b/riscv/riscv-probe/examples/alloca/main.c new file mode 100644 index 0000000..af9696a --- /dev/null +++ b/riscv/riscv-probe/examples/alloca/main.c @@ -0,0 +1,17 @@ +#include +#include +#include + +int main(int argc, char **argv) +{ + const size_t nelems = 4; + const size_t elemsize = 128; + char *alloc[nelems]; + + for (size_t i = 0; i < nelems; i++) { + if (alloc[i] = alloca(elemsize)) { + memset(alloc[i], 0, elemsize); + } + printf("alloca[%d]=0x%x\n", i, alloc[i]); + } +} diff --git a/riscv/riscv-probe/examples/alloca/rules.mk b/riscv/riscv-probe/examples/alloca/rules.mk new file mode 100644 index 0000000..198ef24 --- /dev/null +++ b/riscv/riscv-probe/examples/alloca/rules.mk @@ -0,0 +1 @@ +alloca_objs = main.o -- cgit v1.2.3