diff options
Diffstat (limited to 'test/tls')
-rw-r--r-- | test/tls/Makefile | 6 | ||||
-rw-r--r-- | test/tls/tst-tls16.c | 21 | ||||
-rw-r--r-- | test/tls/tst-tlsmod16.c | 25 |
3 files changed, 51 insertions, 1 deletions
diff --git a/test/tls/Makefile b/test/tls/Makefile index 00fcb0064..223ad7a87 100644 --- a/test/tls/Makefile +++ b/test/tls/Makefile @@ -3,7 +3,7 @@ TESTS := tst-tls1 tst-tls2 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 \ tst-tls8 tst-tls9 tst-tls10 tst-tls11 tst-tls12 tst-tls13 \ - tst-tls14 tst-tls15 tst-tls1-static tst-tls2-static \ + tst-tls14 tst-tls15 tst-tls16 tst-tls1-static tst-tls2-static \ tst-tls9-static TESTS_DISABLED := tst-tls1-static tst-tls2-static tst-tls9-static @@ -42,6 +42,7 @@ CFLAGS_tst-tlsmod14a.so := -fPIC -DSHARED -shared CFLAGS_tst-tlsmod14b.so := -fPIC -DSHARED -shared CFLAGS_tst-tlsmod15a.so := -fPIC -DSHARED -shared CFLAGS_tst-tlsmod15b.so := -fPIC -DSHARED -shared +CFLAGS_tst-tlsmod16.so := -fPIC -DSHARED -shared LDFLAGS_tst-tlsmod1.so := -shared -static-libgcc -L$(top_builddir)lib LDFLAGS_tst-tlsmod2.so := -shared -static-libgcc -L$(top_builddir)lib @@ -66,6 +67,7 @@ LDFLAGS_tst-tlsmod14a.so := -shared -static-libgcc -L$(top_builddir)lib LDFLAGS_tst-tlsmod14b.so := -shared -static-libgcc -L$(top_builddir)lib LDFLAGS_tst-tlsmod15a.so := -shared -static-libgcc -L$(top_builddir)lib LDFLAGS_tst-tlsmod15b.so := -shared -static-libgcc -L$(top_builddir)lib +LDFLAGS_tst-tlsmod16.so := -shared -static-libgcc -L$(top_builddir)lib LDFLAGS_tst-tls3 := tst-tlsmod1.so LDFLAGS_tst-tls4 := -ldl @@ -80,6 +82,7 @@ LDFLAGS_tst-tls12 := -Wl,-rpath-link=. tst-tlsmod12.so LDFLAGS_tst-tls13 := -ldl -Wl,-rpath-link=. LDFLAGS_tst-tls14 := -ldl -Wl,-rpath-link=. tst-tlsmod14a.so LDFLAGS_tst-tls15 := -ldl -Wl,-rpath-link=. +LDFLAGS_tst-tls16 := tst-tlsmod16.so tst-tls3: tst-tlsmod1.so tst-tls4: tst-tlsmod2.so @@ -94,6 +97,7 @@ tst-tls12: tst-tlsmod11.so tst-tlsmod12.so tst-tls13: tst-tlsmod13.so tst-tlsmod13a.so tst-tls14: tst-tlsmod14a.so tst-tlsmod14b.so tst-tls15: tst-tlsmod15a.so tst-tlsmod15b.so +tst-tls16: tst-tlsmod16.so RET_tst-tls13 := 1 ifeq ($(TARGET_ARCH),mips) diff --git a/test/tls/tst-tls16.c b/test/tls/tst-tls16.c new file mode 100644 index 000000000..53aece181 --- /dev/null +++ b/test/tls/tst-tls16.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <stdlib.h> +#include <tls.h> + +#define TLS_VAR_INIT_VALUE 99 + +#ifdef USE_TLS +extern __thread int tls_var; +#endif + +int main(void) +{ + int ret = EXIT_SUCCESS; +#ifdef USE_TLS + if (tls_var != TLS_VAR_INIT_VALUE) { + printf("tls_var = %d - Expected value = %d\n", tls_var, TLS_VAR_INIT_VALUE); + ret = EXIT_FAILURE; + } +#endif + return ret; +} diff --git a/test/tls/tst-tlsmod16.c b/test/tls/tst-tlsmod16.c new file mode 100644 index 000000000..bd04b5081 --- /dev/null +++ b/test/tls/tst-tlsmod16.c @@ -0,0 +1,25 @@ +#include <stdio.h> +#include <tls.h> + +#define TLS_VAR_INIT_VALUE 99 + +#ifdef USE_TLS +__thread int tls_var __attribute__((tls_model("global-dynamic"))); +static __thread int local_tls_var __attribute__((tls_model("local-dynamic"))); +#endif + +void __attribute__((constructor)) libtls_ctor(void); +void libtls_ctor(void) +{ + printf("libtls: constructor!\n"); +#ifdef USE_TLS + local_tls_var = TLS_VAR_INIT_VALUE; + tls_var = local_tls_var; +#endif +} + +void __attribute__((destructor)) libtls_dtor(void); +void libtls_dtor(void) +{ + printf("libtls: destructor!\n"); +} |