user: implement mlibc as the libc, finally.

It's finally done..

Signed-off-by: kaguya <vpshinomiya@protonmail.com>
This commit is contained in:
kaguya
2026-05-02 03:31:49 -04:00
parent 2fa39ad85a
commit 9a9b91c940
2387 changed files with 152741 additions and 315 deletions
+41
View File
@@ -0,0 +1,41 @@
#include <assert.h>
#include <stdio.h>
#include <string.h>
#ifdef USE_HOST_LIBC
#define TEST_FILE "fputs-host-libc.tmp"
#else
#define TEST_FILE "fputs.tmp"
#endif
int main() {
FILE *file;
char str[] = "mlibc fputs test";
char buffer[100];
// Clear the buffer to zero.
memset(buffer, 0, sizeof(buffer));
// Open the file for writing.
file = fopen(TEST_FILE, "w");
assert(file);
// Verify that we can write an empty string.
assert(fputs("", file) != EOF);
// Write string, flush and close.
assert(fputs(str, file) != EOF);
fflush(file);
fclose(file);
// Open the file for reading.
file = fopen(TEST_FILE, "r");
assert(file);
// Verify that we read back the written string and close.
assert(fread(buffer, 1, sizeof(str) - 1, file));
assert(!strcmp(buffer, str));
fclose(file);
return 0;
}