tst-tlsmod4.c 578 B

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