Cleaned and slightly refactored stdio.h and file I/O syscalls

This commit is contained in:
2024-08-16 11:48:54 +02:00
parent 823cd1761f
commit a40490d6a8
7 changed files with 49 additions and 42 deletions
+2 -6
View File
@@ -5,15 +5,11 @@
#include <syscall.h>
void* malloc(const uint32_t size) {
void* ptr = 0;
__asm__ volatile ("int $0x80" : : "a"(SYS_MALLOC), "b"(size));
__asm__ volatile ("movl %%eax, %0" : "=r"(ptr));
return ptr;
return (void*)syscall(SYS_MALLOC, size, 0, 0);
}
void free(const void* ptr) {
__asm__ volatile ("int $0x80" : : "a"(SYS_FREE), "b"(ptr));
syscall(SYS_FREE, (int)ptr, 0, 0);
}
#endif