From 55eb8f2779269cc7084669c6ee238792c975e829 Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Fri, 23 Nov 2018 21:31:09 +0100 Subject: [PATCH] Implement alloca.h --- include/alloca.h | 6 ++++++ tests/Makefile | 1 + tests/alloca.c | 12 ++++++++++++ tests/expected/alloca.stderr | 0 tests/expected/alloca.stdout | 1 + 5 files changed, 20 insertions(+) create mode 100644 include/alloca.h create mode 100644 tests/alloca.c create mode 100644 tests/expected/alloca.stderr create mode 100644 tests/expected/alloca.stdout diff --git a/include/alloca.h b/include/alloca.h new file mode 100644 index 0000000000..047153c476 --- /dev/null +++ b/include/alloca.h @@ -0,0 +1,6 @@ +#ifndef _ALLOCA_H +#define _ALLOCA_H + +#define alloca(size) __builtin_alloca (size) + +#endif /* _ALLOCA_H */ diff --git a/tests/Makefile b/tests/Makefile index 2a8cb5aefc..5a96c99b84 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,5 +1,6 @@ # Binaries that should generate the same output every time EXPECT_BINS=\ + alloca \ args \ arpainet \ assert \ diff --git a/tests/alloca.c b/tests/alloca.c new file mode 100644 index 0000000000..990bd49b35 --- /dev/null +++ b/tests/alloca.c @@ -0,0 +1,12 @@ +#include +#include +#include + +int main(int argc, char ** argv) { + char *str = (char *) alloca(17); + + memset(str, 'A', 16); + str[16] = '\0'; + + printf("%s\n", str); +} diff --git a/tests/expected/alloca.stderr b/tests/expected/alloca.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/expected/alloca.stdout b/tests/expected/alloca.stdout new file mode 100644 index 0000000000..d0a7d827f2 --- /dev/null +++ b/tests/expected/alloca.stdout @@ -0,0 +1 @@ +AAAAAAAAAAAAAAAA