Skip to content

Commit d8284c7

Browse files
authored
Merge pull request #160 from neheb/h
Add support for musl libc
2 parents cd8e449 + 153fe40 commit d8284c7

3 files changed

Lines changed: 6 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ target_link_libraries(netconf2 ${CMAKE_THREAD_LIBS_INIT})
176176
set(CMAKE_REQUIRED_LIBRARIES pthread)
177177
check_include_file(stdatomic.h HAVE_STDATOMIC)
178178
check_function_exists(pthread_mutex_timedlock HAVE_PTHREAD_MUTEX_TIMEDLOCK)
179+
check_function_exists(pthread_rwlockattr_setkind_np HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP)
179180

180181
# dependencies - openssl
181182
if(ENABLE_TLS OR ENABLE_DNSSEC OR ENABLE_SSH)

src/config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,7 @@
7373
*/
7474
#define NC_PS_QUEUE_SIZE @MAX_PSPOLL_THREAD_COUNT@
7575

76+
/* Portability feature-check macros. */
77+
#cmakedefine HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP
78+
7679
#endif /* NC_CONFIG_H_ */

src/session_server.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ nc_server_init(struct ly_ctx *ctx)
560560
errno=0;
561561

562562
if (pthread_rwlockattr_init(&attr) == 0) {
563+
#if defined(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP)
563564
if (pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP) == 0) {
564565
if (pthread_rwlock_init(&server_opts.endpt_lock, &attr) != 0) {
565566
ERR("%s: failed to init rwlock(%s).", __FUNCTION__, strerror(errno));
@@ -570,6 +571,7 @@ nc_server_init(struct ly_ctx *ctx)
570571
} else {
571572
ERR("%s: failed set attribute (%s).", __FUNCTION__, strerror(errno));
572573
}
574+
#endif
573575
pthread_rwlockattr_destroy(&attr);
574576
} else {
575577
ERR("%s: failed init attribute (%s).", __FUNCTION__, strerror(errno));

0 commit comments

Comments
 (0)