Small fix

This commit is contained in:
Francisco José García García 2017-04-06 11:47:19 +02:00 committed by GitHub
parent 295cae5a7b
commit 8983af2016

View File

@ -33,7 +33,13 @@ int __vita_delete_thread_reent(int thid)
// We only need to cleanup if reent is allocated, i.e. if it's on our TLS // We only need to cleanup if reent is allocated, i.e. if it's on our TLS
// We also don't need to clean up the global reent // We also don't need to clean up the global reent
struct _reent **on_tls = TLS_REENT_THID_PTR(thid); struct _reent **on_tls = NULL;
if (thid == 0)
on_tls = TLS_REENT_PTR;
else
on_tls = TLS_REENT_THID_PTR(thid);
if (!*on_tls || *on_tls == &_newlib_global_reent) if (!*on_tls || *on_tls == &_newlib_global_reent)
return 0; return 0;
@ -71,7 +77,7 @@ int _exit_thread_common(int exit_status, int (*exit_func)(int)) {
// Lock the list because we'll be modifying it // Lock the list because we'll be modifying it
sceKernelLockMutex(_newlib_reent_mutex, 1, NULL); sceKernelLockMutex(_newlib_reent_mutex, 1, NULL);
res = __vita_delete_thread_reent(thid); res = __vita_delete_thread_reent(0);
ret = exit_func(exit_status); ret = exit_func(exit_status);
@ -145,7 +151,7 @@ struct _reent *__getreent_for_thread(int thid) {
return *on_tls; return *on_tls;
} }
sceKernelLockMutex(_newlib_reent_mutex, 1, 0); sceKernelLockMutex(_newlib_reent_mutex, 1, 0);
// If it's not on the TLS this means the thread doesn't have a reent allocated yet // If it's not on the TLS this means the thread doesn't have a reent allocated yet
// We allocate one and put a pointer to it on the TLS // We allocate one and put a pointer to it on the TLS
@ -171,6 +177,9 @@ struct _reent *__getreent_for_thread(int thid) {
memset(free_reent, 0, sizeof(struct reent_for_thread)); memset(free_reent, 0, sizeof(struct reent_for_thread));
// Set it up // Set it up
if(thid==0){
thid = sceKernelGetThreadId();
}
free_reent->thread_id = thid; free_reent->thread_id = thid;
_REENT_INIT_PTR(&free_reent->reent); _REENT_INIT_PTR(&free_reent->reent);
returned_reent = &free_reent->reent; returned_reent = &free_reent->reent;