endif # $(PLATFORM) == "libretro"
ifeq "$(USE_RTHREADS)" "1"
-OBJS += frontend/libretro-rthreads.o
+OBJS += frontend/pcsxr-threads.o
OBJS += deps/libretro-common/features/features_cpu.o
frontend/main.o: CFLAGS += -DHAVE_RTHREADS
INC_LIBRETRO_COMMON := 1
+++ /dev/null
-#ifndef __LIBRETRO_PCSXR_RTHREADS_H__
-#define __LIBRETRO_PCSXR_RTHREADS_H__
-
-#include "rthreads/rthreads.h"
-
-enum pcsxr_thread_type
-{
- PCSXRT_CDR = 0,
- PCSXRT_DRC,
- PCSXRT_GPU,
- PCSXRT_SPU,
- PCSXRT_COUNT // must be last
-};
-
-void pcsxr_sthread_init(void);
-sthread_t *pcsxr_sthread_create(void (*thread_func)(void*),
- enum pcsxr_thread_type type);
-
-#endif // __LIBRETRO_PCSXR_RTHREADS_H__
#include <dlfcn.h>
#endif
#ifdef HAVE_RTHREADS
-#include "../frontend/libretro-rthreads.h"
+#include "../frontend/pcsxr-threads.h"
#endif
#include "main.h"
#include "../deps/libretro-common/rthreads/rthreads.c"
#include "features/features_cpu.h"
-#include "libretro-rthreads.h"
+#include "pcsxr-threads.h"
// pcsxr "extensions"
extern void SysPrintf(const char *fmt, ...);
--- /dev/null
+#ifndef __PCSXR_THREADS_H__
+#define __PCSXR_THREADS_H__
+
+enum pcsxr_thread_type
+{
+ PCSXRT_CDR = 0,
+ PCSXRT_DRC,
+ PCSXRT_GPU,
+ PCSXRT_SPU,
+ PCSXRT_COUNT // must be last
+};
+
+#ifndef USE_C11_THREADS
+
+/* use libretro-common rthreads */
+#include "rthreads/rthreads.h"
+
+#define STRHEAD_RET_TYPE void
+#define STRHEAD_RETURN()
+
+void pcsxr_sthread_init(void);
+sthread_t *pcsxr_sthread_create(void (*thread_func)(void*),
+ enum pcsxr_thread_type type);
+
+#else
+
+/* C11 concurrency support */
+#include <threads.h>
+
+#define STRHEAD_RET_TYPE int
+#define STRHEAD_RETURN() return 0
+
+#define pcsxr_sthread_init()
+
+#define slock_new() ({ \
+ mtx_t *lock = malloc(sizeof(*lock)); \
+ if (lock) mtx_init(lock, mtx_plain); \
+ lock; \
+})
+
+#define scond_new() ({ \
+ cnd_t *cnd = malloc(sizeof(*cnd)); \
+ if (cnd) cnd_init(cnd); \
+ cnd; \
+})
+
+#define pcsxr_sthread_create(cb, unused) ({ \
+ thrd_t *thd = malloc(sizeof(*thd)); \
+ if (thd) \
+ thrd_create(thd, cb, NULL); \
+ thd; \
+})
+
+#define sthread_join(thrd) { \
+ if (thrd) { \
+ thrd_join(*thrd, NULL); \
+ free(thrd); \
+ } \
+}
+
+#define slock_free(lock) free(lock)
+#define slock_lock(lock) mtx_lock(lock)
+#define slock_unlock(lock) mtx_unlock(lock)
+#define scond_free(cond) free(cond)
+#define scond_wait(cond, lock) cnd_wait(cond, lock)
+#define scond_signal(cond) cnd_signal(cond)
+#define slock_t mtx_t
+#define scond_t cnd_t
+#define sthread_t thrd_t
+
+#endif // USE_C11_THREADS
+
+#endif // __PCSXR_THREADS_H__
endif
ifeq ($(USE_RTHREADS),1)
SOURCES_C += \
- $(FRONTEND_DIR)/libretro-rthreads.c \
+ $(FRONTEND_DIR)/pcsxr-threads.c \
$(LIBRETRO_COMMON)/features/features_cpu.c
COREFLAGS += -DHAVE_RTHREADS
endif
#endif
-#ifdef USE_C11_THREADS
-#include <threads.h>
-
-static int c11_threads_cb_wrapper(void *cb)
-{
- ((void (*)(void *))cb)(NULL);
-
- return 0;
-}
-
-#define slock_new() ({ \
- mtx_t *lock = malloc(sizeof(*lock)); \
- if (lock) mtx_init(lock, mtx_plain); \
- lock; \
-})
-
-#define scond_new() ({ \
- cnd_t *cnd = malloc(sizeof(*cnd)); \
- if (cnd) cnd_init(cnd); \
- cnd; \
-})
-
-#define pcsxr_sthread_create(cb, unused) ({ \
- thrd_t *thd = malloc(sizeof(*thd)); \
- if (thd) \
- thrd_create(thd, c11_threads_cb_wrapper, cb); \
- thd; \
-})
-
-#define sthread_join(thrd) ({ \
- thrd_join(*thrd, NULL); \
- free(thrd); \
-})
-
-#define slock_free(lock) free(lock)
-#define slock_lock(lock) mtx_lock(lock)
-#define slock_unlock(lock) mtx_unlock(lock)
-#define scond_free(cond) free(cond)
-#define scond_wait(cond, lock) cnd_wait(cond, lock)
-#define scond_signal(cond) cnd_signal(cond)
-#define slock_t mtx_t
-#define scond_t cnd_t
-#define sthread_t thrd_t
-#else
-#include "../frontend/libretro-rthreads.h"
-#endif
-
+#include "../frontend/pcsxr-threads.h"
#ifdef HAVE_LIBRETRO
#include "retro_timers.h"
#endif
// note: This has races on some vars but that's ok, main thread can deal
// with it. Only unsafe buffer accesses and simultaneous reads are prevented.
-static void cdra_prefetch_thread(void *unused)
+static STRHEAD_RET_TYPE cdra_prefetch_thread(void *unused)
{
u32 buf_cnt, lba, lba_to;
slock_lock(acdrom.buf_lock);
}
slock_unlock(acdrom.buf_lock);
+ STRHEAD_RETURN();
}
void cdra_stop_thread(void)
#define FLAGLESS
#include "../gte.h"
#if defined(NDRC_THREAD) && !defined(DRC_DISABLE) && !defined(LIGHTREC)
-#include "../../frontend/libretro-rthreads.h"
+#include "../../frontend/pcsxr-threads.h"
#include "features/features_cpu.h"
#include "retro_timers.h"
#endif
return 1;
}
-static void ari64_compile_thread(void *unused)
+static STRHEAD_RET_TYPE ari64_compile_thread(void *unused)
{
struct ht_entry *hash_table =
*(void **)((char *)dynarec_local + LO_hash_table_ptr);
}
slock_unlock(ndrc_g.thread.lock);
(void)target;
+ STRHEAD_RETURN();
}
static void ari64_thread_shutdown(void)