baremetal: stat preparing to make perfect like userland/

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-05-05 00:00:00 +00:00
parent 928a843b16
commit 53620e5d32
9 changed files with 75 additions and 59 deletions

23
baremetal/getchar.c Normal file
View File

@@ -0,0 +1,23 @@
/* Test that input request through serial also works. */
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char c;
char *ptr = NULL;
size_t alloc_size = 1;
while (1) {
printf("enter a character\n");
c = getchar();
printf("got: %c\n", c);
ptr = realloc(ptr, alloc_size);
if (ptr == NULL) {
puts("out of memory");
break;
} else {
printf("new alloc of %d bytes at address 0x%p\n", alloc_size, ptr);
alloc_size <<= 1;
}
}
}