summaryrefslogtreecommitdiff
path: root/targets/libc.c
diff options
context:
space:
mode:
Diffstat (limited to 'targets/libc.c')
-rw-r--r--targets/libc.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/targets/libc.c b/targets/libc.c
new file mode 100644
index 0000000..2dad81b
--- /dev/null
+++ b/targets/libc.c
@@ -0,0 +1,19 @@
+// The same C under two C libraries (glibc linked dynamically, musl
+// statically): what startup, malloc and stdio turn into, seen as syscalls.
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+// Volatile, or the compiler proves the allocations away.
+static char *volatile small, *volatile big;
+
+int main(void) {
+ small = malloc(64);
+ big = malloc(1 << 20);
+ strcpy(small, "small");
+ memset(big, 'b', 1 << 20);
+ printf("%s %c\n", small, big[4096]);
+ free(big);
+ free(small);
+ return 0;
+}