summaryrefslogtreecommitdiffhomepage
path: root/src/env/nt64
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-01-31 19:56:08 +0000
committermidipix <writeonce@midipix.org>2019-02-19 14:47:45 -0500
commit07b6814a07b3c94bf8b4ba2e2a906175fbf89ffd (patch)
treefb774568c51f184786ea100e58cd9d765b82bcf5 /src/env/nt64
parentca29c23790ef87220b2f74cb6c77d4f40f9cd5b8 (diff)
downloadmmglue-07b6814a07b3c94bf8b4ba2e2a906175fbf89ffd.tar.bz2
mmglue-07b6814a07b3c94bf8b4ba2e2a906175fbf89ffd.tar.xz
psxglue.h: update struct __ldso_vtbl (psxscl) to match member names in psxscl.
tls: place __copy_tls() and __reset_tls() in designated translation units.
Diffstat (limited to 'src/env/nt64')
-rw-r--r--src/env/nt64/__copy_tls.c30
-rw-r--r--src/env/nt64/__reset_tls.c13
-rw-r--r--src/env/nt64/__reset_tls.s0
3 files changed, 43 insertions, 0 deletions
diff --git a/src/env/nt64/__copy_tls.c b/src/env/nt64/__copy_tls.c
new file mode 100644
index 0000000..b96f4ed
--- /dev/null
+++ b/src/env/nt64/__copy_tls.c
@@ -0,0 +1,30 @@
+#define _BSD_SOURCE
+
+#include <unistd.h>
+#include "psxglue.h"
+#include "pthread_impl.h"
+
+extern const struct __ldso_vtbl * __ldso_vtbl;
+extern const struct __psx_vtbl * __psx_vtbl;
+
+void *__copy_tls(unsigned char * mem)
+{
+ /**
+ * this is always the simple case, since:
+ * emutls is based on PE named sections; and
+ * tls allocation and initialization are handled by clone(2)
+ **/
+
+ pthread_t td;
+ uintptr_t addr;
+
+ addr = (uintptr_t)mem;
+ addr += 0xf;
+ addr |= 0xf;
+ addr ^= 0xf;
+
+ td = (struct __pthread *)addr;
+ td->dtv = 0;
+
+ return td;
+}
diff --git a/src/env/nt64/__reset_tls.c b/src/env/nt64/__reset_tls.c
new file mode 100644
index 0000000..7b6b6a5
--- /dev/null
+++ b/src/env/nt64/__reset_tls.c
@@ -0,0 +1,13 @@
+#define _BSD_SOURCE
+
+#include <unistd.h>
+#include "psxglue.h"
+#include "pthread_impl.h"
+
+extern const struct __ldso_vtbl * __ldso_vtbl;
+extern const struct __psx_vtbl * __psx_vtbl;
+
+void __reset_tls(void)
+{
+ __ldso_vtbl->tlsreset();
+}
diff --git a/src/env/nt64/__reset_tls.s b/src/env/nt64/__reset_tls.s
deleted file mode 100644
index e69de29..0000000
--- a/src/env/nt64/__reset_tls.s
+++ /dev/null