> compile NEMU
221220000 张三 Linux zzy 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux 20:43:23 up 2 days, 10:57, 1 user, load average: 0.55, 0.55, 0.46
This commit is contained in:
@ -29,12 +29,16 @@ int atoi(const char* nptr) {
|
||||
return x;
|
||||
}
|
||||
|
||||
static uint8_t* ptr;
|
||||
void *malloc(size_t size) {
|
||||
// On native, malloc() will be called during initializaion of C runtime.
|
||||
// Therefore do not call panic() here, else it will yield a dead recursion:
|
||||
// panic() -> putchar() -> (glibc) -> malloc() -> panic()
|
||||
#if !(defined(__ISA_NATIVE__) && defined(__NATIVE_USE_KLIB__))
|
||||
panic("Not implemented");
|
||||
if (ptr == NULL) ptr = heap.start;
|
||||
// assert(ptr + size <= heap.end && ptr >= heap.start);
|
||||
ptr += size;
|
||||
return ptr - size;
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user