aboutsummaryrefslogtreecommitdiff
path: root/frontend/3ds/semaphore.h
diff options
context:
space:
mode:
authorAutechre2020-10-11 20:15:38 +0200
committerGitHub2020-10-11 20:15:38 +0200
commit19b9695a71f15ef0bf61c7c3cfd6c98ec5ccb028 (patch)
tree14a6d38b403bbcf92f8e8f5f59b664d6ea4bbb34 /frontend/3ds/semaphore.h
parent03f41c38234fece3e1b4efefb9f4efb381e24b46 (diff)
parentc81b3e1533fcfe1529942681121d7b40a663bf85 (diff)
downloadpcsx_rearmed-19b9695a71f15ef0bf61c7c3cfd6c98ec5ccb028.tar.gz
pcsx_rearmed-19b9695a71f15ef0bf61c7c3cfd6c98ec5ccb028.tar.bz2
pcsx_rearmed-19b9695a71f15ef0bf61c7c3cfd6c98ec5ccb028.zip
Merge pull request #456 from justinweiss/3ds-spu-threading
[3DS] Enable threading for the SPU
Diffstat (limited to 'frontend/3ds/semaphore.h')
-rw-r--r--frontend/3ds/semaphore.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/frontend/3ds/semaphore.h b/frontend/3ds/semaphore.h
new file mode 100644
index 0000000..6eddd98
--- /dev/null
+++ b/frontend/3ds/semaphore.h
@@ -0,0 +1,35 @@
+
+#ifndef _3DS_SEMAPHORE_WRAP__
+#define _3DS_SEMAPHORE_WRAP__
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "3ds_utils.h"
+
+typedef uint32_t sem_t;
+
+static inline int sem_init(sem_t *sem, int pshared, unsigned int value)
+{
+ return svcCreateSemaphore(sem, value, INT32_MAX);
+}
+
+static inline int sem_post(sem_t *sem)
+{
+ int32_t count;
+ return svcReleaseSemaphore(&count, *sem, 1);
+}
+
+static inline int sem_wait(sem_t *sem)
+{
+ return svcWaitSynchronization(*sem, INT64_MAX);
+}
+
+static inline int sem_destroy(sem_t *sem)
+{
+ return svcCloseHandle(*sem);
+}
+
+#endif //_3DS_SEMAPHORE_WRAP__
+