Back to index

glibc  2.9
tst-dlsym1.c
Go to the documentation of this file.
00001 /* Test case by Hui Huang <hui.huang@sun.com>.  */
00002 #include <dlfcn.h>
00003 #include <pthread.h>
00004 #include <stdio.h>
00005 #include <stdlib.h>
00006 
00007 
00008 static void *
00009 start_routine (void *args)
00010 {
00011   int i;
00012   void **addrs = (void **) args;
00013   for (i = 0; i < 10000; ++i)
00014     addrs[i % 1024] = dlsym (NULL, "does_not_exist");
00015 
00016   return addrs;
00017 }
00018 
00019 
00020 static int
00021 do_test (void)
00022 {
00023   pthread_t tid1, tid2, tid3;
00024 
00025   void *addrs1[1024];
00026   void *addrs2[1024];
00027   void *addrs3[1024];
00028 
00029   if (pthread_create (&tid1, NULL, start_routine, addrs1) != 0)
00030     {
00031       puts ("1st create failed");
00032       exit (1);
00033     }
00034   if (pthread_create (&tid2, NULL, start_routine, addrs2) != 0)
00035     {
00036       puts ("2nd create failed");
00037       exit (1);
00038     }
00039   if (pthread_create (&tid3, NULL, start_routine, addrs3) != 0)
00040     {
00041       puts ("3rd create failed");
00042       exit (1);
00043     }
00044 
00045   if (pthread_join (tid1, NULL) != 0)
00046     {
00047       puts ("1st join failed");
00048       exit (1);
00049     }
00050   if (pthread_join (tid2, NULL) != 0)
00051     {
00052       puts ("2nd join failed");
00053       exit (1);
00054     }
00055   if (pthread_join (tid3, NULL) != 0)
00056     {
00057       puts ("2rd join failed");
00058       exit (1);
00059     }
00060 
00061   return 0;
00062 }
00063 
00064 
00065 #define TEST_FUNCTION do_test ()
00066 #include "../test-skeleton.c"