X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=linux%2Fpreempt.c;h=72eceed32bcefa187e931c371c888dfb91fd9b7a;hb=42cf74fd1d0ef58927967e6236988e86cfc0d086;hp=aa092c1d0afc09d70ba5a3c76e4c43be111ff62e;hpb=ff4d082246ed542c28c90f3f30b9b964d67591d3;p=bcachefs-tools-debian diff --git a/linux/preempt.c b/linux/preempt.c index aa092c1..72eceed 100644 --- a/linux/preempt.c +++ b/linux/preempt.c @@ -15,7 +15,16 @@ * correct to instead guarantee mutual exclusion for the critical sections. */ -static pthread_mutex_t preempt_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +static pthread_mutex_t preempt_lock; + +__attribute__((constructor)) +static void preempt_init(void) { + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&preempt_lock, &attr); + pthread_mutexattr_destroy(&attr); +} void preempt_disable(void) {