summaryrefslogtreecommitdiff
path: root/libpthread/nptl/sysdeps/kvx/libc-tls.c
diff options
context:
space:
mode:
Diffstat (limited to 'libpthread/nptl/sysdeps/kvx/libc-tls.c')
-rw-r--r--libpthread/nptl/sysdeps/kvx/libc-tls.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/libpthread/nptl/sysdeps/kvx/libc-tls.c b/libpthread/nptl/sysdeps/kvx/libc-tls.c
new file mode 100644
index 000000000..5fd9e7e70
--- /dev/null
+++ b/libpthread/nptl/sysdeps/kvx/libc-tls.c
@@ -0,0 +1,26 @@
+/*
+ * This file is subject to the terms and conditions of the LGPL V2.1
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2020 Kalray Inc.
+ */
+
+#include <sysdeps/generic/libc-tls.c>
+#include <dl-tls.h>
+
+#if defined(USE_TLS) && USE_TLS
+
+/* On kvx, linker optimizations are not required, so __tls_get_addr
+ can be called even in statically linked binaries. In this case module
+ must be always 1 and PT_TLS segment exist in the binary, otherwise it
+ would not link. */
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
+
+#endif