]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake,common/RWLock: check for libpthread extensions 19202/head
authorKefu Chai <kchai@redhat.com>
Tue, 28 Nov 2017 07:21:55 +0000 (15:21 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 28 Nov 2017 15:50:36 +0000 (23:50 +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 9d8fe0058d8aac7158d6eacde80b5c221f23bcc3..2f4289117448d7990baf4e7b0b0791398684edfd 100644 (file)
@@ -101,6 +101,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 137e70e5bf8487837a855cc9053374750f6ef59d..da4baefb83df88ff5735daf2b0f72686a28ad0ca 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 ed082088057404bf2a332a276bd4e0a7d662d880..46beb891ed6d8ff89d45e3959faa48f3215a077d 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