mirror of https://gitee.com/Nocallback/glibc.git
Browse Source
* elf/tst-tls17.c: New test. * elf/tst-tlsmod17a.c: New file. * elf/tst-tlsmod17b.c: Likewise.cvs/glibc-2_9-branch cvs/fedora-glibc-20081019T1815
6 changed files with 86 additions and 1 deletions
@ -0,0 +1,28 @@ |
|||
#include <dlfcn.h> |
|||
#include <stdio.h> |
|||
|
|||
static int |
|||
do_test (void) |
|||
{ |
|||
void *h = dlopen ("tst-tlsmod17b.so", RTLD_LAZY); |
|||
if (h == NULL) |
|||
{ |
|||
puts ("unexpectedly failed to open tst-tlsmod17b.so"); |
|||
exit (1); |
|||
} |
|||
|
|||
int (*fp) (void) = (int (*) (void)) dlsym (h, "tlsmod17b"); |
|||
if (fp == NULL) |
|||
{ |
|||
puts ("cannot find tlsmod17b"); |
|||
exit (1); |
|||
} |
|||
|
|||
if (fp ()) |
|||
exit (1); |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
#define TEST_FUNCTION do_test () |
|||
#include "../test-skeleton.c" |
|||
@ -0,0 +1,23 @@ |
|||
#include <stdio.h> |
|||
|
|||
#ifndef N |
|||
#define N 0 |
|||
#endif |
|||
#define CONCAT1(s, n) s##n |
|||
#define CONCAT(s, n) CONCAT1(s, n) |
|||
|
|||
__thread int CONCAT (v, N) = 4; |
|||
|
|||
int |
|||
CONCAT (tlsmod17a, N) (void) |
|||
{ |
|||
int *p = &CONCAT (v, N); |
|||
/* GCC assumes &var is never NULL, add optimization barrier. */ |
|||
asm volatile ("" : "+r" (p)); |
|||
if (p == NULL || *p != 4) |
|||
{ |
|||
printf ("fail %d %p\n", N, p); |
|||
return 1; |
|||
} |
|||
return 0; |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
#define P(N) extern int tlsmod17a##N (void); |
|||
#define PS P(0) P(1) P(2) P(3) P(4) P(5) P(6) P(7) P(8) P(9) \ |
|||
P(10) P(12) P(13) P(14) P(15) P(16) P(17) P(18) P(19) |
|||
PS |
|||
#undef P |
|||
|
|||
int |
|||
tlsmod17b (void) |
|||
{ |
|||
int res = 0; |
|||
#define P(N) res |= tlsmod17a##N (); |
|||
PS |
|||
#undef P |
|||
return res; |
|||
} |
|||
Loading…
Reference in new issue