Updated to fedora-glibc-20090424T1908
[glibc/history.git] / elf / restest2.c
blobf959f030a088e56c5f0989ab911d70575204f323
1 #include <sys/types.h>
2 #include <dlfcn.h>
3 #include <error.h>
4 #include <mcheck.h>
5 #include <stdlib.h>
6 #include <unistd.h>
8 pid_t pid, pid2;
10 pid_t getpid(void)
12 pid_t (*f)(void);
13 f = (pid_t (*)(void)) dlsym (RTLD_NEXT, "getpid");
14 if (f == NULL)
15 error (EXIT_FAILURE, 0, "dlsym (RTLD_NEXT, \"getpid\"): %s", dlerror ());
16 return (pid2 = f()) + 26;
19 int
20 main (void)
22 pid_t (*f)(void);
24 mtrace ();
26 f = (pid_t (*)(void)) dlsym (RTLD_DEFAULT, "getpid");
27 if (f == NULL)
28 error (EXIT_FAILURE, 0, "dlsym (RTLD_DEFAULT, \"getpid\"): %s", dlerror ());
29 pid = f();
30 if (pid != pid2 + 26)
31 error (EXIT_FAILURE, 0, "main getpid() not called");
32 return 0;