summaryrefslogtreecommitdiffhomepage
path: root/arch/nt64/src/crt_tls.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-03-08 13:23:20 -0400
committermidipix <writeonce@midipix.org>2015-03-08 13:23:20 -0400
commit86062740f1e8eeb4c554055cf304dc1e0e87ea43 (patch)
tree35d8309221f4fd2050fefbc1b3b3957a1099ce8a /arch/nt64/src/crt_tls.c
parent41058bd82ed2ae880c463d61e5702aef07681bf0 (diff)
downloadmmglue-86062740f1e8eeb4c554055cf304dc1e0e87ea43.tar.bz2
mmglue-86062740f1e8eeb4c554055cf304dc1e0e87ea43.tar.xz
initial commit of core port files.
signed-off by Z. Gilboa; see copying.midipix (9cd0746c) for additional information.
Diffstat (limited to 'arch/nt64/src/crt_tls.c')
-rw-r--r--arch/nt64/src/crt_tls.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/nt64/src/crt_tls.c b/arch/nt64/src/crt_tls.c
new file mode 100644
index 0000000..15183d3
--- /dev/null
+++ b/arch/nt64/src/crt_tls.c
@@ -0,0 +1,27 @@
+#include <stdint.h>
+#include <stddef.h>
+#include "psxglue.h"
+#include "pthread_arch.h"
+
+typedef unsigned int __tls_word __attribute__((mode(word)));
+typedef unsigned int __tls_ptr __attribute__((mode(pointer)));
+
+struct __emutls_object
+{
+ __tls_word size;
+ __tls_word align;
+ ptrdiff_t offset;
+ void * defval;
+};
+
+void * __emutls_get_address (struct __emutls_object * obj)
+{
+ int dsoidx = obj->align & 0xFFFF0000;
+ struct __tlca * tlca = (struct __tlca *)__psx_tlca();
+
+ if (dsoidx)
+ return (*tlca->pthread_dtls)[dsoidx >> 16] + obj->offset;
+ else
+ return tlca->pthread_tls + obj->offset;
+}
+