~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/dlcompat/test/dlsymtest.c

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <unistd.h>
 
2
#include <stdio.h>
 
3
#include <dlfcn.h>
 
4
int foo(int number);
 
5
typedef int (*testFNPtr)(int number);
 
6
 
 
7
int main (int argv, const char * argc[])
 
8
{
 
9
  int retCode=0;
 
10
  testFNPtr foofunc,foosym;
 
11
  foosym = (testFNPtr)dlsym(RTLD_NEXT,"foo");
 
12
  if (!foosym) printf("foosym RTLD_NEXT %s\n",dlerror());
 
13
  foofunc = (testFNPtr)dlfunc(RTLD_NEXT,"foo");
 
14
  if (!foofunc) printf("foofunc RTLD_NEXT %s\n",dlerror());
 
15
  if ((void*)foosym != (void*)foofunc)
 
16
  {
 
17
    retCode++;
 
18
    printf("RTLD_NEXT dlsym %x dlfunc %x\n",foosym,foofunc);
 
19
  }
 
20
#ifdef RTLD_DEFAULT  
 
21
  foosym = (testFNPtr)dlsym(RTLD_DEFAULT,"foo");
 
22
  if (!foosym) printf("foosym RTLD_DEFAULT %s\n",dlerror());
 
23
  foofunc = (testFNPtr)dlfunc(RTLD_DEFAULT,"foo");
 
24
  if (!foofunc) printf("foofunc RTLD_DEFAULT %s\n",dlerror());
 
25
  if ((void*)foosym != (void*)foofunc)
 
26
  {
 
27
    retCode++;
 
28
    printf("RTLD_DEFAULT dlsym %x dlfunc %x\n",foosym,foofunc);
 
29
  }
 
30
#endif  
 
31
#ifdef RTLD_SELF
 
32
  foosym = (testFNPtr)dlsym(RTLD_SELF,"foo");
 
33
  if (!foosym) printf("foosym RTLD_SELF %s\n",dlerror());
 
34
  foofunc = (testFNPtr)dlfunc(RTLD_SELF,"foo");
 
35
  if (!foofunc) printf("foofunc RTLD_SELF %s\n",dlerror());
 
36
  if ((void*)foosym != (void*)foofunc)
 
37
  {
 
38
    retCode++;
 
39
    printf("RTLD_SELF dlsym %x dlfunc %x\n",foosym,foofunc);
 
40
  }
 
41
#endif
 
42
  if (!retCode) printf("Okay, this actually works, cool, I am happy\n");
 
43
  else printf("Well, confirms a bug, makes me happy I was not wrong\n");
 
44
  return retCode;
 
45
}
 
46
 
 
47
int foo(int number)
 
48
{
 
49
printf("foo %s %s",__FILE__,__LINE__);
 
50
}
 
 
b'\\ No newline at end of file'