Browse Source

Implement alloca.h

Tibor Nagy 6 years ago
parent
commit
55eb8f2779
5 changed files with 20 additions and 0 deletions
  1. 6 0
      include/alloca.h
  2. 1 0
      tests/Makefile
  3. 12 0
      tests/alloca.c
  4. 0 0
      tests/expected/alloca.stderr
  5. 1 0
      tests/expected/alloca.stdout

+ 6 - 0
include/alloca.h

@@ -0,0 +1,6 @@
+#ifndef _ALLOCA_H
+#define _ALLOCA_H
+
+#define alloca(size) __builtin_alloca (size)
+
+#endif /* _ALLOCA_H */

+ 1 - 0
tests/Makefile

@@ -1,5 +1,6 @@
 # Binaries that should generate the same output every time
 EXPECT_BINS=\
+	alloca \
 	args \
 	arpainet \
 	assert \

+ 12 - 0
tests/alloca.c

@@ -0,0 +1,12 @@
+#include <alloca.h>
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char ** argv) {
+    char *str = (char *) alloca(17);
+
+    memset(str, 'A', 16);
+    str[16] = '\0';
+
+    printf("%s\n", str);
+}

+ 0 - 0
tests/expected/alloca.stderr


+ 1 - 0
tests/expected/alloca.stdout

@@ -0,0 +1 @@
+AAAAAAAAAAAAAAAA