tst-tlsmod17a.c 417 B

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