Back to index

glibc  2.9
tst-tls4.c
Go to the documentation of this file.
00001 #include <dlfcn.h>
00002 #include <stdio.h>
00003 #include <stdlib.h>
00004 
00005 #include <tls.h>
00006 
00007 
00008 #define TEST_FUNCTION do_test ()
00009 static int
00010 do_test (void)
00011 {
00012   static const char modname[] = "tst-tlsmod2.so";
00013   int result = 0;
00014   int *foop;
00015   int (*fp) (int, int *);
00016   void *h;
00017 
00018   h = dlopen (modname, RTLD_LAZY);
00019   if (h == NULL)
00020     {
00021       printf ("cannot open '%s': %s\n", modname, dlerror ());
00022       exit (1);
00023     }
00024 
00025   fp = dlsym (h, "in_dso");
00026   if (fp == NULL)
00027     {
00028       printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
00029       exit (1);
00030     }
00031 
00032   result |= fp (0, NULL);
00033 
00034   foop = dlsym (h, "foo");
00035   if (foop == NULL)
00036     {
00037       printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
00038       exit (1);
00039     }
00040   if (*foop != 16)
00041     {
00042       puts ("foo != 16");
00043       result = 1;
00044     }
00045 
00046   dlclose (h);
00047 
00048   return result;
00049 }
00050 
00051 
00052 #include "../test-skeleton.c"