tst-tlsmod18a.c 326 B

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