summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt15
-rw-r--r--source/kit/thread.posix.c2
2 files changed, 16 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6dacbc3..302b692 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,6 +36,16 @@ include(CheckCSourceRuns)
check_c_source_runs(
"
+ __attribute__((weak)) int foo();
+ int main() { return 0; }
+ "
+ KIT_HAVE_FUNC_ATTRIBUTE_WEAK
+)
+
+set(CMAKE_REQUIRED_LIBRARIES "pthread")
+check_c_source_runs(
+ "
+ #define _GNU_SOURCE
#include <pthread.h>
int main() {
pthread_mutexattr_t attr;
@@ -46,6 +56,7 @@ check_c_source_runs(
"
KIT_HAVE_PTHREAD_MUTEXATTR_SETTYPE
)
+set(CMAKE_REQUIRED_LIBRARIES "")
check_c_source_runs(
"
@@ -87,6 +98,10 @@ if(NOT KIT_HAVE_MALLOC)
set(KIT_DISABLE_SYSTEM_MALLOC ON)
endif()
+if(KIT_HAVE_FUNC_ATTRIBUTE_WEAK)
+ target_compile_definitions(kit PUBLIC KIT_HAVE_FUNC_ATTRIBUTE_WEAK)
+endif()
+
if(KIT_HAVE_PTHREAD_MUTEXATTR_SETTYPE)
target_compile_definitions(kit PUBLIC KIT_HAVE_PTHREAD_MUTEXATTR_SETTYPE)
endif()
diff --git a/source/kit/thread.posix.c b/source/kit/thread.posix.c
index 4d21abb..52f52ad 100644
--- a/source/kit/thread.posix.c
+++ b/source/kit/thread.posix.c
@@ -114,7 +114,7 @@ void mtx_destroy(mtx_t *mtx) {
* Thus the linker will be happy and things don't clash when building
* with -O1 or greater.
*/
-# if defined(HAVE_FUNC_ATTRIBUTE_WEAK) && !defined(__CYGWIN__)
+# if defined(KIT_HAVE_FUNC_ATTRIBUTE_WEAK) && !defined(__CYGWIN__)
__attribute__((weak)) int pthread_mutexattr_init(
pthread_mutexattr_t *attr);