show worst latencies as well
[tridge/junkcode.git] / preload_shmat.c
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <dlfcn.h>
4
5 void *shmat(int shmid, const void *shmaddr, int shmflag)
6 {
7         static void *h;
8         static void *(*shmat_orig)(int , const void *, int );
9         static int count;
10         if (!h) {
11                 h = dlopen("/lib/libc.so.6", RTLD_LAZY);
12                 shmat_orig = dlsym(h, "shmat");
13                 count = atoi(getenv("SHMAT_COUNT"));
14         }
15
16         fprintf(stderr,"shmat(%d, %p, 0x%x)\n", shmid, shmaddr, shmflag);
17
18         if (! count) return NULL;
19
20         count--;
21
22         return shmat_orig(shmid, shmaddr, shmflag);
23 }