Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake,common/RWLock: check for libpthread extensions #19202

Merged
merged 1 commit into from
Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sets a cmake variable HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP

to make that visible to the compiler, we also need to add a #cmakedefine for it in src/include/config-h.in.cmake

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbodley ahh, i forgot that! fixed and repushed.

CHECK_FUNCTION_EXISTS(eventfd HAVE_EVENTFD)
CHECK_FUNCTION_EXISTS(getprogname HAVE_GETPROGNAME)

Expand Down
3 changes: 2 additions & 1 deletion src/common/RWLock.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <pthread.h>
#include <string>
#include <include/assert.h>
#include "acconfig.h"
#include "lockdep.h"
#include "common/valgrind.h"

Expand All @@ -42,7 +43,7 @@ class RWLock final
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);
Expand Down
3 changes: 3 additions & 0 deletions src/include/config-h.in.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@
/* 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

Expand Down