Clear BSS space using memset(3)

This commit is contained in:
Xavier Del Campo Romero 2021-10-24 02:17:02 +02:00
parent 15e2ff6bb6
commit 17832b2bed
1 changed files with 6 additions and 5 deletions

View File

@ -1,5 +1,7 @@
#include <psx.h> #include <psx.h>
#include <stdio.h> #include <stdio.h>
#include <stddef.h>
#include <string.h>
extern int __bss_start[]; extern int __bss_start[];
extern int __bss_end[]; extern int __bss_end[];
@ -26,15 +28,14 @@ static void call_ctors(void)
void psxsdk_setup() void psxsdk_setup()
{ {
unsigned int x;
printf("Initializing PSXSDK... \n"); printf("Initializing PSXSDK... \n");
dprintf("Clearing BSS space...\n"); dprintf("Clearing BSS space...\n");
// Clear BSS space // Clear BSS space
for(x = (unsigned int)__bss_start; x < (unsigned int)__bss_end; x++) memset(__bss_start, 0, (ptrdiff_t)__bss_end - (ptrdiff_t)__bss_start);
*((unsigned char*)x) = 0;
dprintf("BSS space cleared.\n"); dprintf("BSS space cleared.\n");