Files
linux-kernel-module-cheat/baremetal/interactive/prompt.c
Ciro Santilli 六四事件 法轮功 fc9e0c28a5 baremetal: create an assert_fail C helper
Create a test for it under interactive/assert_fail.c

Move prompt under interactive

Create baremetal/arch/aarch64/c_from_as.S as an example of calling C
functions from assembly.
2018-11-09 09:33:44 +00:00

23 lines
496 B
C

#include <stdio.h>
#include <stdlib.h>
void 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;
}
}
}