1 /*
2  * Copyright (C) 2017 Hangzhou C-SKY Microsystems co.,ltd.
3  *
4  * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB
5  * in this tarball.
6  */
7 
8 #include <sysdeps/generic/libc-tls.c>
9 #include <dl-tls.h>
10 
11 #if defined(USE_TLS) && USE_TLS
12 
13 /* On CSKY, linker optimizations are not required, so __tls_get_addr
14    can be called even in statically linked binaries.  In this case module
15    must be always 1 and PT_TLS segment exist in the binary, otherwise it
16    would not link.  */
17 
18 void *
__tls_get_addr(tls_index * ti)19 __tls_get_addr (tls_index *ti)
20 {
21 	dtv_t *dtv = THREAD_DTV ();
22 	return (char *) dtv[1].pointer.val + ti->ti_offset;
23 }
24 
25 #endif
26