Back to index

glibc  2.9
tst-tls18.c
Go to the documentation of this file.
00001 #include <dlfcn.h>
00002 #include <stdio.h>
00003 
00004 static int
00005 do_test (void)
00006 {
00007   char modname[sizeof "tst-tlsmod18aXX.so"];
00008   void *h[20];
00009   for (int i = 0; i < 20; i++)
00010     {
00011       snprintf (modname, sizeof modname, "tst-tlsmod18a%d.so", i);
00012       h[i] = dlopen (modname, RTLD_LAZY);
00013       if (h[i] == NULL)
00014        {
00015          printf ("unexpectedly failed to open %s", modname);
00016          exit (1);
00017        }
00018     }
00019 
00020   for (int i = 0; i < 20; i++)
00021     {
00022       int (*fp) (void) = (int (*) (void)) dlsym (h[i], "test");
00023       if (fp == NULL)
00024        {
00025          printf ("cannot find test in tst-tlsmod18a%d.so", i);
00026          exit (1);
00027        }
00028 
00029       if (fp ())
00030        exit (1);
00031     }
00032 
00033   return 0;
00034 }
00035 
00036 #define TEST_FUNCTION do_test ()
00037 #include "../test-skeleton.c"