tst-dlsym1.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Test case by Hui Huang <hui.huang@sun.com>. */
  2. #include <dlfcn.h>
  3. #include <pthread.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. static void *
  7. start_routine (void *args)
  8. {
  9. int i;
  10. void **addrs = (void **) args;
  11. for (i = 0; i < 10000; ++i)
  12. addrs[i % 1024] = dlsym (NULL, "does_not_exist");
  13. return addrs;
  14. }
  15. static int
  16. do_test (void)
  17. {
  18. pthread_t tid1, tid2, tid3;
  19. void *addrs1[1024];
  20. void *addrs2[1024];
  21. void *addrs3[1024];
  22. if (pthread_create (&tid1, NULL, start_routine, addrs1) != 0)
  23. {
  24. puts ("1st create failed");
  25. exit (1);
  26. }
  27. if (pthread_create (&tid2, NULL, start_routine, addrs2) != 0)
  28. {
  29. puts ("2nd create failed");
  30. exit (1);
  31. }
  32. if (pthread_create (&tid3, NULL, start_routine, addrs3) != 0)
  33. {
  34. puts ("3rd create failed");
  35. exit (1);
  36. }
  37. if (pthread_join (tid1, NULL) != 0)
  38. {
  39. puts ("1st join failed");
  40. exit (1);
  41. }
  42. if (pthread_join (tid2, NULL) != 0)
  43. {
  44. puts ("2nd join failed");
  45. exit (1);
  46. }
  47. if (pthread_join (tid3, NULL) != 0)
  48. {
  49. puts ("2rd join failed");
  50. exit (1);
  51. }
  52. return 0;
  53. }
  54. #define TEST_FUNCTION do_test ()
  55. #include "../test-skeleton.c"