]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake,common/RWLock: check for libpthread extensions 19269/head
authorKefu Chai <kchai@redhat.com>
Tue, 28 Nov 2017 07:21:55 +0000 (15:21 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 1 Dec 2017 02:36:42 +0000 (10:36 +0800)
pthread_rwlockattr_setkind_np() is a GNU extension of libpthread. and
Tianshan Qu pointed out, we cannot use
ifdef(PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP) to detect the
availability of this function, because it's an enum not a macro. so,
like other *_np() extensions, we check this one also using cmake at
the configure phase.

Reported-by: Tianshan Qu <tianshan@xsky.com>
Signed-off-by: Kefu Chai <kchai@redhat.com>
CMakeLists.txt
src/common/RWLock.h
src/include/config-h.in.cmake

index c358e3e97482aecbf4cee7f2474aef43c1349911..cbd729bf32ac6e19613932a528044d1a2ed56bd6 100644 (file)
@@ -112,6 +112,7 @@ CHECK_FUNCTION_EXISTS(pthread_spin_init HAVE_PTHREAD_SPINLOCK)
 CHECK_FUNCTION_EXISTS(pthread_set_name_np HAVE_PTHREAD_SET_NAME_NP)
 CHECK_FUNCTION_EXISTS(pthread_setname_np HAVE_PTHREAD_SETNAME_NP)
 CHECK_FUNCTION_EXISTS(pthread_getname_np HAVE_PTHREAD_GETNAME_NP)
+CHECK_FUNCTION_EXISTS(pthread_rwlockattr_setkind_np HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP)
 CHECK_FUNCTION_EXISTS(eventfd HAVE_EVENTFD)
 CHECK_FUNCTION_EXISTS(getprogname HAVE_GETPROGNAME)
 
index fd8a2665ef18f657d4c9b4d2939e5ea908068cbe..a1d8c88a30a4c8d4686ac90c82e0f2cc08b112b6 100644 (file)
@@ -20,6 +20,7 @@
 #include <pthread.h>
 #include <string>
 #include <include/assert.h>
+#include "acconfig.h"
 #include "lockdep.h"
 #include "common/valgrind.h"
 
@@ -42,7 +43,7 @@ public:
   RWLock(const std::string &n, bool track_lock=true, bool ld=true, bool prioritize_write=false)
     : name(n), id(-1), track(track_lock),
       lockdep(ld) {
-#if defined(PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP)
+#if defined(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP)
     if (prioritize_write) {
       pthread_rwlockattr_t attr;
       pthread_rwlockattr_init(&attr);
index 2847ceea2a8e2a21190a2572eb1b755b249f0bd5..71ad9e6386f1ef3f6bc63fc15530826183f7ac06 100644 (file)
 /* Defined if pthread_setname_np() is available */
 #cmakedefine HAVE_PTHREAD_SETNAME_NP 1
 
+/* Defined if pthread_rwlockattr_setkind_np() is available */
+#cmakedefine HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP
+
 /* Defined if blkin enabled */
 #cmakedefine WITH_BLKIN