diff options
| author | spicyjpeg <thatspicyjpeg@gmail.com> | 2024-01-08 18:33:11 +0100 |
|---|---|---|
| committer | spicyjpeg <thatspicyjpeg@gmail.com> | 2024-01-08 18:33:11 +0100 |
| commit | dd85f9f993427ae69ab905486f8ef372d3960664 (patch) | |
| tree | 605e6aec308795ee466fa12b090067c6517ea2d7 /libpsn00b/libc | |
| parent | 06e65bea3a778b2dae5af77a7935ae3868ddd4d3 (diff) | |
| download | psn00bsdk-dd85f9f993427ae69ab905486f8ef372d3960664.tar.gz | |
Fix bugs in libc, psxgpu, psxpress, clean up headers
Diffstat (limited to 'libpsn00b/libc')
| -rw-r--r-- | libpsn00b/libc/malloc.c | 2 | ||||
| -rw-r--r-- | libpsn00b/libc/start.c | 17 |
2 files changed, 8 insertions, 11 deletions
diff --git a/libpsn00b/libc/malloc.c b/libpsn00b/libc/malloc.c index e9fd6f4..d3425d0 100644 --- a/libpsn00b/libc/malloc.c +++ b/libpsn00b/libc/malloc.c @@ -224,7 +224,7 @@ __attribute__((weak)) void *realloc(void *ptr, size_t size) { } // No luck. - void *new = malloc(_size); + void *new = malloc(size); if (!new) return 0; diff --git a/libpsn00b/libc/start.c b/libpsn00b/libc/start.c index dcbad2d..fe6dedd 100644 --- a/libpsn00b/libc/start.c +++ b/libpsn00b/libc/start.c @@ -65,17 +65,13 @@ extern uint8_t _end[]; extern void (*__CTOR_LIST__[])(void); extern void (*__DTOR_LIST__[])(void); -extern int main(int argc, const char* argv[]); +extern int main(int argc, const char **argv); // Even though _start() usually takes no arguments, this implementation allows // parent executables to pass args directly to child executables without having // to overwrite the arg strings in kernel RAM. -void _start_inner(int argc, const char **argv) { - //__asm__ volatile("la $gp, _gp;"); - - // BSS is always aligned to 4 bytes by the linker script. - for (uint32_t *i = (uint32_t *) __bss_start; i < (uint32_t *) _end; i++) - *i = 0; +int _start_inner(int argc, const char **argv) { + __builtin_memset(__bss_start, 0, (void *) _end - (void *) __bss_start); // Initialize the heap and place it after the executable, assuming 2 MB of // RAM. Note that InitHeap() can be called again in main(). @@ -91,11 +87,12 @@ void _start_inner(int argc, const char **argv) { for (int i = (int) __CTOR_LIST__[0]; i >= 1; i--) __CTOR_LIST__[i](); - // Store main()'s return value into the kernel return value area (for child - // executables). - *KERNEL_RETURN_VALUE = main(__argc, __argv); + int value = main(argc, argv); // Call global destructors (in forward order). for (int i = 0; i < (int) __DTOR_LIST__[0]; i++) __DTOR_LIST__[i + 1](); + + //*KERNEL_RETURN_VALUE = value; + return value; } |
