2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Prefer the pthread_barrier implementation over uv_barrier

Prefer the pthread_barrier implementation on platforms where it is
available over uv_barrier implementation.  This also solves the problem
with thread sanitizer builds on macOS that doesn't have pthread barrier.
This commit is contained in:
Ondřej Surý
2023-01-11 09:28:10 +01:00
committed by Ondřej Surý
parent 5139b04e27
commit d07c4a98da
2 changed files with 39 additions and 24 deletions

View File

@@ -508,7 +508,7 @@ LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"
AC_CHECK_FUNCS([pthread_attr_getstacksize pthread_attr_setstacksize])
AC_CHECK_FUNCS([pthread_attr_getstacksize pthread_attr_setstacksize pthread_barrier_init])
# [pairwise: --with-locktype=adaptive, --with-locktype=standard]
AC_ARG_WITH([locktype],

View File

@@ -15,24 +15,53 @@
#include <isc/util.h>
#if __SANITIZE_THREAD__
#if HAVE_PTHREAD_BARRIER_INIT
#include <pthread.h>
#define isc_barrier_t pthread_barrier_t
#if ISC_TRACK_PTHREADS_OBJECTS
typedef pthread_barrier_t *isc_barrier_t;
#else
typedef pthread_barrier_t isc_barrier_t;
#endif
#define isc_barrier_init(barrier, count) \
pthread_barrier_init(barrier, NULL, count)
#define isc_barrier_destroy(barrier) pthread_barrier_destroy(barrier)
#define isc_barrier_wait(barrier) pthread_barrier_wait(barrier)
#define isc__barrier_init(bp, count) \
{ \
int _ret = pthread_barrier_init(bp, NULL, count); \
PTHREADS_RUNTIME_CHECK(pthread_barrier_init, _ret); \
}
#else /* __SANITIZE_THREAD__ */
#define isc__barrier_wait(bp) pthread_barrier_wait(bp)
#include <isc/uv.h>
#define isc__barrier_destroy(bp) \
{ \
int _ret = pthread_barrier_destroy(bp); \
PTHREADS_RUNTIME_CHECK(pthread_barrier_destroy, _ret); \
}
#else
#include <uv.h>
#if ISC_TRACK_PTHREADS_OBJECTS
typedef uv_barrier_t *isc_barrier_t;
#else
typedef uv_barrier_t isc_barrier_t;
#endif
#define isc__barrier_init(bp, count) \
{ \
int _ret = uv_barrier_init(bp, count); \
UV_RUNTIME_CHECK(uv_barrier_init, _ret); \
}
#define isc__barrier_wait(bp) uv_barrier_wait(bp)
#define isc__barrier_destroy(bp) uv_barrier_destroy(bp)
#endif
#if ISC_TRACK_PTHREADS_OBJECTS
#define isc_barrier_init(bp, count) \
{ \
@@ -48,22 +77,8 @@ typedef uv_barrier_t *isc_barrier_t;
#else /* ISC_TRACK_PTHREADS_OBJECTS */
typedef uv_barrier_t isc_barrier_t;
#define isc_barrier_init(bp, count) isc__barrier_init(bp, count)
#define isc_barrier_wait(bp) isc__barrier_wait(bp)
#define isc_barrier_destroy(bp) isc__barrier_destroy(bp)
#endif /* ISC_TRACK_PTHREADS_OBJECTS */
#define isc__barrier_init(bp, count) \
{ \
int _ret = uv_barrier_init(bp, count); \
UV_RUNTIME_CHECK(uv_barrier_init, _ret); \
}
#define isc__barrier_wait(bp) uv_barrier_wait(bp)
#define isc__barrier_destroy(bp) uv_barrier_destroy(bp)
#endif /* __SANITIZE_THREAD__ */