mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-14 14:28:47 +00:00
Make thread local storage optional
This commit is contained in:
parent
dd36cff174
commit
330a8d7594
@ -575,6 +575,10 @@ ifeq ($(HAVE_THREADS), 1)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_THREAD_STORAGE), 1)
|
||||
DEFINES += -DHAVE_THREAD_STORAGE
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_WAYLAND), 1)
|
||||
OBJ += gfx/drivers_context/wayland_ctx.o
|
||||
DEFINES += $(WAYLAND_CFLAGS)
|
||||
@ -1064,7 +1068,7 @@ OBJ += $(ZLIB_OBJS)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Video4Linux 2
|
||||
# Video4Linux 2
|
||||
|
||||
ifeq ($(HAVE_V4L2),1)
|
||||
OBJ += camera/drivers/video4linux2.o
|
||||
|
@ -35,7 +35,10 @@ RETRO_BEGIN_DECLS
|
||||
typedef struct sthread sthread_t;
|
||||
typedef struct slock slock_t;
|
||||
typedef struct scond scond_t;
|
||||
|
||||
#ifdef HAVE_THREAD_STORAGE
|
||||
typedef unsigned sthread_tls_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* sthread_create:
|
||||
@ -179,6 +182,7 @@ int scond_broadcast(scond_t *cond);
|
||||
**/
|
||||
void scond_signal(scond_t *cond);
|
||||
|
||||
#ifdef HAVE_THREAD_STORAGE
|
||||
/**
|
||||
* @brief Creates a thread local storage key
|
||||
*
|
||||
@ -218,6 +222,7 @@ void *sthread_tls_get(sthread_tls_t *tls);
|
||||
* @return whether the operation suceeded or not
|
||||
*/
|
||||
bool sthread_tls_set(sthread_tls_t *tls, const void *data);
|
||||
#endif
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
|
@ -475,6 +475,7 @@ bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_THREAD_STORAGE
|
||||
bool sthread_tls_create(sthread_tls_t *tls)
|
||||
{
|
||||
#ifdef USE_WIN32_THREADS
|
||||
@ -510,3 +511,4 @@ bool sthread_tls_set(sthread_tls_t *tls, const void *data)
|
||||
return pthread_setspecific(*tls, data) == 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -150,9 +150,17 @@ fi
|
||||
|
||||
if [ "$OS" = 'Win32' ]; then
|
||||
HAVE_THREADS=yes
|
||||
HAVE_THREAD_STORAGE=yes
|
||||
HAVE_DYLIB=yes
|
||||
else
|
||||
check_lib THREADS "$PTHREADLIB" pthread_create
|
||||
|
||||
if [ "$HAVE_THREADS" = 'yes' ]; then
|
||||
check_lib THREAD_STORAGE "$PTHREADLIB" pthread_key_create
|
||||
else
|
||||
HAVE_THREAD_STORAGE=no
|
||||
fi
|
||||
|
||||
check_lib DYLIB "$DYLIB" dlopen
|
||||
fi
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
HAVE_LIBRETRODB=yes # Libretrodb support
|
||||
HAVE_RGUI=yes # RGUI menu
|
||||
HAVE_MATERIALUI=auto # MaterialUI menu
|
||||
HAVE_MATERIALUI=auto # MaterialUI menu
|
||||
HAVE_XMB=auto # XMB menu
|
||||
HAVE_ZARCH=no # Zarch menu
|
||||
HAVE_NUKLEAR=no # Nuklear menu
|
||||
@ -20,6 +20,7 @@ HAVE_MAN_DIR= # Manpage install directory
|
||||
HAVE_OPENGLES_LIBS= # Link flags for custom GLES library
|
||||
HAVE_OPENGLES_CFLAGS= # C-flags for custom GLES library
|
||||
HAVE_THREADS=auto # Threading support
|
||||
HAVE_THREAD_STORAGE=auto # Thread Local Storage support
|
||||
HAVE_FFMPEG=auto # FFmpeg recording support
|
||||
C89_FFMPEG=no
|
||||
HAVE_SSA=auto # SSA/ASS for FFmpeg subtitle support
|
||||
|
@ -1108,7 +1108,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
||||
static bool rarch_ips_pref = false;
|
||||
static bool rarch_patch_blocked = false;
|
||||
settings_t *settings = config_get_ptr();
|
||||
#ifdef HAVE_THREADS
|
||||
#ifdef HAVE_THREAD_STORAGE
|
||||
static sthread_tls_t rarch_tls;
|
||||
const void *MAGIC_POINTER = (void*)0xB16B00B5;
|
||||
#endif
|
||||
@ -1223,13 +1223,13 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
||||
|
||||
rarch_ctl(RARCH_CTL_UNSET_INITED, NULL);
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
#ifdef HAVE_THREAD_STORAGE
|
||||
sthread_tls_delete(&rarch_tls);
|
||||
#endif
|
||||
break;
|
||||
case RARCH_CTL_INIT:
|
||||
rarch_ctl(RARCH_CTL_DEINIT, NULL);
|
||||
#ifdef HAVE_THREADS
|
||||
#ifdef HAVE_THREAD_STORAGE
|
||||
sthread_tls_create(&rarch_tls);
|
||||
sthread_tls_set(&rarch_tls, MAGIC_POINTER);
|
||||
#endif
|
||||
@ -1319,7 +1319,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
||||
#endif
|
||||
break;
|
||||
case RARCH_CTL_IS_MAIN_THREAD:
|
||||
#ifdef HAVE_THREADS
|
||||
#ifdef HAVE_THREAD_STORAGE
|
||||
return sthread_tls_get(&rarch_tls) == MAGIC_POINTER;
|
||||
#else
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user