| 1 | #include <stdio.h> |
|---|---|
| 2 | |
| 3 | #ifndef N |
| 4 | #define N 0 |
| 5 | #endif |
| 6 | #define CONCAT1(s, n) s##n |
| 7 | #define CONCAT(s, n) CONCAT1(s, n) |
| 8 | |
| 9 | __thread int CONCAT (v, N) = 4; |
| 10 | |
| 11 | int |
| 12 | CONCAT (tlsmod17a, N) (void) |
| 13 | { |
| 14 | int *p = &CONCAT (v, N); |
| 15 | /* GCC assumes &var is never NULL, add optimization barrier. */ |
| 16 | asm volatile ("": "+r"(p)); |
| 17 | if (p == NULL || *p != 4) |
| 18 | { |
| 19 | printf (format: "fail %d %p\n", N, p); |
| 20 | return 1; |
| 21 | } |
| 22 | return 0; |
| 23 | } |
| 24 |
