From 8b7834d4008d10d8763d18b25580a4607a5e6607 Mon Sep 17 00:00:00 2001 From: Austin Foxley Date: Sat, 17 Oct 2009 12:39:59 -0700 Subject: test/tls/: tests for thread local storage functionality Signed-off-by: Austin Foxley --- test/tls/tst-tlsmod4.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 test/tls/tst-tlsmod4.c (limited to 'test/tls/tst-tlsmod4.c') diff --git a/test/tls/tst-tlsmod4.c b/test/tls/tst-tlsmod4.c new file mode 100644 index 000000000..4893cdae7 --- /dev/null +++ b/test/tls/tst-tlsmod4.c @@ -0,0 +1,38 @@ +#include + +#include + +#ifdef USE_TLS +# include "tls-macros.h" + + +COMMON_INT_DEF(baz); + + +int +in_dso (int n, int *caller_bazp) +{ + int *bazp; + int result = 0; + + puts ("foo"); /* Make sure PLT is used before macros. */ + __asm__ ("" ::: "memory"); + + bazp = TLS_GD (baz); + + if (caller_bazp != NULL && bazp != caller_bazp) + { + printf ("callers address of baz differs: %p vs %p\n", caller_bazp, bazp); + result = 1; + } + else if (*bazp != n) + { + printf ("baz != %d\n", n); + result = 1; + } + + *bazp = 16; + + return result; +} +#endif -- cgit v1.2.3