tst-tls4.c 900 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include <dlfcn.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <tls.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-tlsmod2.so";
  11. int result = 0;
  12. int *foop;
  13. int (*fp) (int, int *);
  14. void *h;
  15. h = dlopen (modname, RTLD_LAZY);
  16. if (h == NULL)
  17. {
  18. printf ("cannot open '%s': %s\n", modname, dlerror ());
  19. exit (1);
  20. }
  21. fp = dlsym (h, "in_dso");
  22. if (fp == NULL)
  23. {
  24. printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
  25. exit (1);
  26. }
  27. result |= fp (0, NULL);
  28. foop = dlsym (h, "foo");
  29. if (foop == NULL)
  30. {
  31. printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
  32. exit (1);
  33. }
  34. if (*foop != 16)
  35. {
  36. puts ("foo != 16");
  37. result = 1;
  38. }
  39. dlclose (h);
  40. return result;
  41. #else
  42. return 0;
  43. #endif
  44. }
  45. #include "../test-skeleton.c"