diff options
author | koverstreet <kent.overstreet@gmail.com> | 2020-05-05 16:25:43 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-05 16:25:43 -0400 |
commit | 06c81e31b58164248c75fb1f16631daa3e10db2f (patch) | |
tree | 10d75608bf415e37810e7846c80193218e35b4e5 /linux/preempt.c | |
parent | 6e9f4602408e9bcdb33bce6ab3a2d8562613d6ce (diff) | |
parent | 5bc48bd428303aabe19c196a47d1d89a605397be (diff) |
Merge pull request #27 from yshui/master
Fix building on musl
Diffstat (limited to 'linux/preempt.c')
-rw-r--r-- | linux/preempt.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/linux/preempt.c b/linux/preempt.c index aa092c1d..72eceed3 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) { |