tst-tlsmod14a.c 575 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <stdint.h>
  2. #include <stdio.h>
  3. #include <tls.h>
  4. #if USE_TLS && HAVE___THREAD
  5. #define AL 4096
  6. struct foo
  7. {
  8. int i;
  9. } __attribute ((aligned (AL)));
  10. static __thread struct foo f;
  11. static struct foo g;
  12. #ifndef FCT
  13. # define FCT in_dso1
  14. #endif
  15. int
  16. FCT (void)
  17. {
  18. puts (__func__);
  19. int result = 0;
  20. int fail = (((uintptr_t) &f) & (AL - 1)) != 0;
  21. printf ("&f = %p %s\n", &f, fail ? "FAIL" : "OK");
  22. result |= fail;
  23. fail = (((uintptr_t) &g) & (AL - 1)) != 0;
  24. printf ("&g = %p %s\n", &g, fail ? "FAIL" : "OK");
  25. result |= fail;
  26. return result;
  27. }
  28. #endif