Deinit mutexs

This commit is contained in:
Francisco Javier Trujillo Mata
2021-11-25 11:10:47 +01:00
parent 976707e8a0
commit af5e24ef06
3 changed files with 14 additions and 1 deletions

View File

@@ -32,7 +32,7 @@ GLUE_OBJS = __fill_stat.o __psp_heap_blockid.o __psp_free_heap.o _fork.o _wait.o
INIT_OBJS = __libcglue_init.o
MUTEXMAN_OBJS = __malloc_mutex.o __sbrk_mutex.o __fdman_mutex.o __init_mutex.o
MUTEXMAN_OBJS = __malloc_mutex.o __sbrk_mutex.o __fdman_mutex.o __init_mutex.o __deinit_mutex.o
NETDB_OBJS = h_errno.o gethostbyaddr.o gethostbyname.o

View File

@@ -42,4 +42,14 @@ void __init_mutex()
sceKernelCreateLwMutex(&__sbrk_mutex, "sbrk mutex", 0, 0, 0);
sceKernelCreateLwMutex(&__fdman_mutex, "fdman mutex", 0, 0, 0);
}
#endif
#ifdef F___deinit_mutex
/* Create mutex used for making thread safe mallock and get fd */
void __deinit_mutex()
{
sceKernelDeleteLwMutex(&__malloc_mutex);
sceKernelDeleteLwMutex(&__sbrk_mutex);
sceKernelDeleteLwMutex(&__fdman_mutex);
}
#endif

View File

@@ -18,18 +18,21 @@
extern int sce_newlib_nocreate_thread_in_start __attribute__((weak));
int __psp_free_heap(void);
void __deinit_mutex(void);
void _exit(int status)
{
if (&sce_newlib_nocreate_thread_in_start != NULL) {
/* Free the heap created by _sbrk(). */
__psp_free_heap();
__deinit_mutex();
sceKernelSelfStopUnloadModule(1, 0, NULL);
} else {
if (status == 0) {
/* Free the heap created by _sbrk(). */
__psp_free_heap();
__deinit_mutex();
}
sceKernelExitThread(status);