@@ -238,7 +238,9 @@ typedef SSIZE_T ssize_t;
238
238
#define MDB_OWNERDEAD EOWNERDEAD /**< #LOCK_MUTEX0() result if dead owner */
239
239
#endif
240
240
241
-
241
+ #ifdef __GLIBC__
242
+ #define GLIBC_VER ((__GLIBC__ << 16 )| __GLIBC_MINOR__)
243
+ #endif
242
244
/** Some platforms define the EOWNERDEAD error code
243
245
* even though they don't support Robust Mutexes.
244
246
* Compile with -DMDB_USE_ROBUST=0, or use some other
@@ -248,12 +250,19 @@ typedef SSIZE_T ssize_t;
248
250
* either.)
249
251
*/
250
252
#ifndef MDB_USE_ROBUST
251
- /* Android currently lacks Robust Mutex support */
252
- #if defined(ANDROID ) && defined(MDB_USE_POSIX_MUTEX ) && !defined(MDB_USE_ROBUST )
253
- #define MDB_USE_ROBUST 0
254
- #else
255
- #define MDB_USE_ROBUST 1
256
- #endif
253
+ /* Android currently lacks Robust Mutex support. So does glibc < 2.4. */
254
+ # if defined(MDB_USE_POSIX_MUTEX ) && (defined(ANDROID ) || \
255
+ (defined(__GLIBC__ ) && GLIBC_VER < 0x020004 ))
256
+ # define MDB_USE_ROBUST 0
257
+ # else
258
+ # define MDB_USE_ROBUST 1
259
+ /* glibc < 2.10 only provided _np API */
260
+ # if defined(__GLIBC__ ) && GLIBC_VER < 0x02000a
261
+ # define PTHREAD_MUTEX_ROBUST PTHREAD_MUTEX_ROBUST_NP
262
+ # define pthread_mutexattr_setrobust (attr , flag ) pthread_mutexattr_setrobust_np(attr, flag)
263
+ # define pthread_mutex_consistent (mutex ) pthread_mutex_consistent_np(mutex)
264
+ # endif
265
+ # endif
257
266
#endif /* MDB_USE_ROBUST */
258
267
259
268
#if defined(MDB_OWNERDEAD ) && MDB_USE_ROBUST
0 commit comments