tst-tls7.c 714 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <dlfcn.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <link.h>
  5. #define TEST_FUNCTION do_test ()
  6. static int
  7. do_test (void)
  8. {
  9. #ifdef USE_TLS
  10. static const char modname[] = "tst-tlsmod3.so";
  11. int result = 0;
  12. int (*fp) (void);
  13. void *h;
  14. int i;
  15. int modid = -1;
  16. for (i = 0; i < 10; ++i)
  17. {
  18. h = dlopen (modname, RTLD_LAZY);
  19. if (h == NULL)
  20. {
  21. printf ("cannot open '%s': %s\n", modname, dlerror ());
  22. exit (1);
  23. }
  24. fp = dlsym (h, "in_dso2");
  25. if (fp == NULL)
  26. {
  27. printf ("cannot get symbol 'in_dso2': %s\n", dlerror ());
  28. exit (1);
  29. }
  30. result |= fp ();
  31. dlclose (h);
  32. }
  33. return result;
  34. #else
  35. return 0;
  36. #endif
  37. }
  38. #include "../test-skeleton.c"