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