tst-tlsmod3.c 539 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <stdio.h>
  2. #ifdef USE_TLS
  3. # include "tls-macros.h"
  4. extern int in_dso (int n, int *caller_foop);
  5. COMMON_INT_DEF(comm_n);
  6. int
  7. in_dso2 (void)
  8. {
  9. int *foop;
  10. int result = 0;
  11. static int n;
  12. int *np;
  13. puts ("foo"); /* Make sure PLT is used before macros. */
  14. __asm__ ("" ::: "memory");
  15. foop = TLS_GD (foo);
  16. np = TLS_GD (comm_n);
  17. if (n != *np)
  18. {
  19. printf ("n = %d != comm_n = %d\n", n, *np);
  20. result = 1;
  21. }
  22. result |= in_dso (*foop = 42 + n++, foop);
  23. *foop = 16;
  24. return result;
  25. }
  26. #endif