summaryrefslogtreecommitdiffhomepage
path: root/src/env/nt32/__copy_tls.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/env/nt32/__copy_tls.c')
-rw-r--r--src/env/nt32/__copy_tls.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/env/nt32/__copy_tls.c b/src/env/nt32/__copy_tls.c
new file mode 100644
index 0000000..b96f4ed
--- /dev/null
+++ b/src/env/nt32/__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;
+}