From 34cf1d213ec0261af41ef6a16f5b37e5015c614b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 12 Jun 2015 11:01:21 +0200 Subject: [PATCH] lib/replace: fix PTHREAD_MUTEX_ROBUST fallback to PTHREAD_MUTEX_ROBUST_NP on solaris 11 Without this we got the following defines in config.h: #define HAVE_DECL_PTHREAD_MUTEXATTR_SETROBUST_NP 1 #define HAVE_DECL_PTHREAD_MUTEX_CONSISTENT_NP 1 #define HAVE_PTHREAD_MUTEXATTR_SETROBUST 1 #define HAVE_PTHREAD_MUTEX_CONSISTENT 1 #define HAVE_ROBUST_MUTEXES 1 #define USE_TDB_MUTEX_LOCKING 1 And the build failed with PTHREAD_MUTEX_ROBUST being unknown. Note that PTHREAD_MUTEX_ROBUST and PTHREAD_MUTEX_ROBUST_NP are enum values while they're defines on solaris 11 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11319 Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam --- lib/replace/system/threads.h | 9 +++------ lib/replace/wscript | 6 ++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/replace/system/threads.h b/lib/replace/system/threads.h index 25d3502aa64..fe6d0fbac54 100644 --- a/lib/replace/system/threads.h +++ b/lib/replace/system/threads.h @@ -29,15 +29,12 @@ #if defined(HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP) && \ !defined(HAVE_PTHREAD_MUTEXATTR_SETROBUST) - #define pthread_mutexattr_setrobust pthread_mutexattr_setrobust_np +#endif -/* - * We assume that PTHREAD_MUTEX_ROBUST_NP goes along with - * pthread_mutexattr_setrobust_np() - */ +#if defined(HAVE_DECL_PTHREAD_MUTEX_ROBUST_NP) && \ + !defined(HAVE_DECL_PTHREAD_MUTEX_ROBUST) #define PTHREAD_MUTEX_ROBUST PTHREAD_MUTEX_ROBUST_NP - #endif #if defined(HAVE_PTHREAD_MUTEX_CONSISTENT_NP) && \ diff --git a/lib/replace/wscript b/lib/replace/wscript index 788877cf1e2..01b5067c036 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -459,6 +459,10 @@ removeea setea conf.CHECK_FUNCS_IN('pthread_mutexattr_setrobust_np', 'pthread', checklibc=True, headers='pthread.h') + conf.CHECK_DECLS('PTHREAD_MUTEX_ROBUST', headers='pthread.h') + if not conf.CONFIG_SET('HAVE_DECL_PTHREAD_MUTEX_ROBUST'): + conf.CHECK_DECLS('PTHREAD_MUTEX_ROBUST_NP', headers='pthread.h') + conf.CHECK_DECLS('pthread_mutex_consistent', headers='pthread.h') if not conf.CONFIG_SET('HAVE_DECL_PTHREAD_MUTEX_CONSISTENT'): conf.CHECK_DECLS('pthread_mutex_consistent_np', @@ -472,6 +476,8 @@ removeea setea if ((conf.CONFIG_SET('HAVE_PTHREAD_MUTEXATTR_SETROBUST') or conf.CONFIG_SET('HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP')) and + (conf.CONFIG_SET('HAVE_DECL_PTHREAD_MUTEX_ROBUST') or + conf.CONFIG_SET('HAVE_DECL_PTHREAD_MUTEX_ROBUST_NP')) and (conf.CONFIG_SET('HAVE_PTHREAD_MUTEX_CONSISTENT') or conf.CONFIG_SET('HAVE_PTHREAD_MUTEX_CONSISTENT_NP'))): conf.DEFINE('HAVE_ROBUST_MUTEXES', 1)