Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* elf/Makefile: Add rules to build and run tst-tls17.
* elf/tst-tls17.c: New test. * elf/tst-tlsmod17a.c: New file. * elf/tst-tlsmod17b.c: Likewise.
- Loading branch information
Ulrich Drepper
committed
Oct 17, 2008
1 parent
292eb81
commit 60a23f5
Showing
6 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters