On Wed, Jan 07, 2015 at 03:55:11PM +0100, Bernd Edlinger wrote: > cat barrier.h > #include <dlfcn.h> > > static pthread_barrier_t barrier; > > static int (*barrier_wait)(pthread_barrier_t *);
Better static __typeof (pthread_barrier_wait) *barrier_wait; ? > > __attribute__((constructor(101))) I wouldn't use a constructor for it, instead simply call it from the testcase at the start of main. > void barrier_init() > { > pthread_barrier_init (&barrier, NULL, 2); > barrier_wait = (int (*)(pthread_barrier_t *)) > dlsym (dlopen ("pthread.so.0", RTLD_NOW), > "pthread_barrier_wait"); "libpthread.so.0" instead. I'd use: #ifdef RTLD_NOLOAD void *h = dlopen ("libpthread.so.0", RTLD_NOLOAD); #else void *h = dlopen ("libpthread.so.0", RTLD_NOW); #endif barrier_wait = (__typeof (pthread_barrier_wait) *) dlsym (h, "pthread_barrier_wait"); Jakub