gcc/testsuite/c-c++-common/tsan/tsan_barrier.h
raw| 1 | /* TSAN-invisible barriers. Link with -ldl. */ |
| 2 | #include <pthread.h> |
| 3 | #include <dlfcn.h> |
| 4 | |
| 5 | static __typeof(pthread_barrier_wait) *barrier_wait; |
| 6 | |
| 7 | static |
| 8 | void barrier_init (pthread_barrier_t *barrier, unsigned count) |
| 9 | { |
| 10 | void *h = dlopen ("libpthread.so.0", RTLD_LAZY); |
| 11 | barrier_wait = (__typeof (pthread_barrier_wait) *) |
| 12 | dlsym (h, "pthread_barrier_wait"); |
| 13 | pthread_barrier_init (barrier, NULL, count); |
| 14 | } |