mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
Update rthreads
This commit is contained in:
parent
521b978d31
commit
0d699208d3
@ -27,6 +27,7 @@
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <rthreads/rthreads.h>
|
||||
@ -164,6 +165,11 @@ sthread_t *sthread_create(void (*thread_func)(void*), void *userdata)
|
||||
return sthread_create_with_priority(thread_func, userdata, 0);
|
||||
}
|
||||
|
||||
/* TODO/FIXME - this needs to be implemented for Switch */
|
||||
#if !defined(SWITCH) && !defined(USE_WIN32_THREADS)
|
||||
#define HAVE_THREAD_ATTR
|
||||
#endif
|
||||
|
||||
/**
|
||||
* sthread_create_with_priority:
|
||||
* @start_routine : thread entry callback function
|
||||
@ -181,11 +187,11 @@ sthread_t *sthread_create(void (*thread_func)(void*), void *userdata)
|
||||
*/
|
||||
sthread_t *sthread_create_with_priority(void (*thread_func)(void*), void *userdata, int thread_priority)
|
||||
{
|
||||
#ifndef USE_WIN32_THREADS
|
||||
#ifdef HAVE_THREAD_ATTR
|
||||
pthread_attr_t thread_attr;
|
||||
bool thread_attr_needed = false;
|
||||
#endif
|
||||
bool thread_created = false;
|
||||
bool thread_attr_needed = false;
|
||||
struct thread_data *data = NULL;
|
||||
sthread_t *thread = (sthread_t*)calloc(1, sizeof(*thread));
|
||||
|
||||
@ -203,6 +209,8 @@ sthread_t *sthread_create_with_priority(void (*thread_func)(void*), void *userda
|
||||
thread->thread = CreateThread(NULL, 0, thread_wrap, data, 0, &thread->id);
|
||||
thread_created = !!thread->thread;
|
||||
#else
|
||||
|
||||
#ifdef HAVE_THREAD_ATTR
|
||||
pthread_attr_init(&thread_attr);
|
||||
|
||||
if ( (thread_priority >= 1) && (thread_priority <= 100) )
|
||||
@ -215,18 +223,23 @@ sthread_t *sthread_create_with_priority(void (*thread_func)(void*), void *userda
|
||||
|
||||
thread_attr_needed = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(VITA)
|
||||
pthread_attr_setstacksize(&thread_attr , 0x10000 );
|
||||
thread_attr_needed = true;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_THREAD_ATTR
|
||||
if (thread_attr_needed)
|
||||
thread_created = pthread_create(&thread->id, &thread_attr, thread_wrap, data) == 0;
|
||||
else
|
||||
#endif
|
||||
thread_created = pthread_create(&thread->id, NULL, thread_wrap, data) == 0;
|
||||
|
||||
#ifdef HAVE_THREAD_ATTR
|
||||
pthread_attr_destroy(&thread_attr);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (thread_created)
|
||||
|
@ -28,30 +28,29 @@
|
||||
#include <switch.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "../include/retro_inline.h"
|
||||
#include "../../verbosity.h"
|
||||
#include <retro_inline.h>
|
||||
|
||||
#define THREADVARS_MAGIC 0x21545624 // !TV$
|
||||
#define THREADVARS_MAGIC 0x21545624 /* !TV$ */
|
||||
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
|
||||
void pthread_exit(void *retval);
|
||||
|
||||
// This structure is exactly 0x20 bytes, if more is needed modify getThreadVars() below
|
||||
/* This structure is exactly 0x20 bytes, if more is needed modify getThreadVars() below */
|
||||
typedef struct
|
||||
{
|
||||
// Magic value used to check if the struct is initialized
|
||||
/* Magic value used to check if the struct is initialized */
|
||||
u32 magic;
|
||||
|
||||
// Thread handle, for mutexes
|
||||
/* Thread handle, for mutexes */
|
||||
Handle handle;
|
||||
|
||||
// Pointer to the current thread (if exists)
|
||||
/* Pointer to the current thread (if exists) */
|
||||
Thread *thread_ptr;
|
||||
|
||||
// Pointer to this thread's newlib state
|
||||
/* Pointer to this thread's newlib state */
|
||||
struct _reent *reent;
|
||||
|
||||
// Pointer to this thread's thread-local segment
|
||||
void *tls_tp; // !! Offset needs to be TLS+0x1F8 for __aarch64_read_tp !!
|
||||
/* Pointer to this thread's thread-local segment */
|
||||
void *tls_tp; /* !! Offset needs to be TLS+0x1F8 for __aarch64_read_tp !! */
|
||||
} ThreadVars;
|
||||
|
||||
static INLINE ThreadVars *getThreadVars(void)
|
||||
@ -77,9 +76,9 @@ static INLINE int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutex
|
||||
return 0;
|
||||
}
|
||||
|
||||
INLINE int pthread_mutex_destroy(pthread_mutex_t *mutex)
|
||||
static INLINE int pthread_mutex_destroy(pthread_mutex_t *mutex)
|
||||
{
|
||||
// Nothing
|
||||
/* Nothing */
|
||||
*mutex = 0;
|
||||
|
||||
return 0;
|
||||
@ -101,7 +100,7 @@ static INLINE int pthread_mutex_unlock(pthread_mutex_t *mutex)
|
||||
INLINE int pthread_detach(pthread_t thread)
|
||||
{
|
||||
(void)thread;
|
||||
// Nothing for now
|
||||
/* Nothing for now */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -154,7 +153,7 @@ static INLINE int pthread_cond_broadcast(pthread_cond_t *cond)
|
||||
|
||||
INLINE int pthread_cond_destroy(pthread_cond_t *cond)
|
||||
{
|
||||
// Nothing
|
||||
/* Nothing */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user