From: Loïc Yhuel Date: Wed, 11 Oct 2023 11:07:48 +0000 (+0200) Subject: easy_lock: add a pthread_mutex_t fallback X-Git-Tag: curl-8_5_0~259 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5adb6000;p=thirdparty%2Fcurl.git easy_lock: add a pthread_mutex_t fallback This allows to keep the init threadsafe with gcc < 4.9.0 (no C11 atomics). Closes https://github.com/curl/curl/pull/12090 --- diff --git a/lib/easy_lock.h b/lib/easy_lock.h index d3fffd0d2a..4f6764d427 100644 --- a/lib/easy_lock.h +++ b/lib/easy_lock.h @@ -93,6 +93,15 @@ static inline void curl_simple_lock_unlock(curl_simple_lock *lock) atomic_store_explicit(lock, false, memory_order_release); } +#elif defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) + +#include + +#define curl_simple_lock pthread_mutex_t +#define CURL_SIMPLE_LOCK_INIT PTHREAD_MUTEX_INITIALIZER +#define curl_simple_lock_lock(m) pthread_mutex_lock(m) +#define curl_simple_lock_unlock(m) pthread_mutex_unlock(m) + #else #undef GLOBAL_INIT_IS_THREADSAFE