tst-tlsmod4.c 560 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <stdio.h>
  2. #ifdef USE_TLS
  3. # include "tls-macros.h"
  4. COMMON_INT_DEF(baz);
  5. int
  6. in_dso (int n, int *caller_bazp)
  7. {
  8. int *bazp;
  9. int result = 0;
  10. puts ("foo"); /* Make sure PLT is used before macros. */
  11. __asm__ ("" ::: "memory");
  12. bazp = TLS_GD (baz);
  13. if (caller_bazp != NULL && bazp != caller_bazp)
  14. {
  15. printf ("callers address of baz differs: %p vs %p\n", caller_bazp, bazp);
  16. result = 1;
  17. }
  18. else if (*bazp != n)
  19. {
  20. printf ("baz != %d\n", n);
  21. result = 1;
  22. }
  23. *bazp = 16;
  24. return result;
  25. }
  26. #endif