tst-tlsmod2.c 577 B

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