summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2022-10-01 20:35:29 +0100
committerQi Wang <interwq@gmail.com>2022-10-03 10:42:09 -0700
commit4c95c953e2c4b443d930d3b41abb17eb38f075f5 (patch)
tree0d1711e8b6b43eadb703b2b037a3e726bebf4ac1
parent3de0c24859f4413bf03448249078169bb50bda0f (diff)
downloadjemalloc-4c95c953e2c4b443d930d3b41abb17eb38f075f5.tar.gz
fix build for non linux/BSD platforms.
-rw-r--r--configure.ac9
-rw-r--r--include/jemalloc/internal/jemalloc_internal_defs.h.in3
-rw-r--r--src/background_thread.c6
3 files changed, 15 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 0ae579ee..64c0c847 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2024,6 +2024,15 @@ if test "x$have_sched_setaffinity" = "x1" ; then
AC_DEFINE([JEMALLOC_HAVE_SCHED_SETAFFINITY], [ ], [ ])
fi
+dnl Check if the pthread_setaffinity_np function exists.
+AC_CHECK_FUNC([pthread_setaffinity_np],
+ [have_pthread_setaffinity_np="1"],
+ [have_pthread_setaffinity_np="0"]
+ )
+if test "x$have_pthread_setaffinity_np" = "x1" ; then
+ AC_DEFINE([JEMALLOC_HAVE_PTHREAD_SETAFFINITY_NP], [ ], [ ])
+fi
+
dnl Check if the Solaris/BSD issetugid function exists.
AC_CHECK_FUNC([issetugid],
[have_issetugid="1"],
diff --git a/include/jemalloc/internal/jemalloc_internal_defs.h.in b/include/jemalloc/internal/jemalloc_internal_defs.h.in
index 6dbd8780..f5d94ee7 100644
--- a/include/jemalloc/internal/jemalloc_internal_defs.h.in
+++ b/include/jemalloc/internal/jemalloc_internal_defs.h.in
@@ -391,6 +391,9 @@
/* GNU specific sched_setaffinity support */
#undef JEMALLOC_HAVE_SCHED_SETAFFINITY
+/* pthread_setaffinity_np support */
+#undef JEMALLOC_HAVE_PTHREAD_SETAFFINITY_NP
+
/*
* If defined, all the features necessary for background threads are present.
*/
diff --git a/src/background_thread.c b/src/background_thread.c
index 3171dd31..3c006cec 100644
--- a/src/background_thread.c
+++ b/src/background_thread.c
@@ -113,9 +113,7 @@ background_thread_info_init(tsdn_t *tsdn, background_thread_info_t *info) {
static inline bool
set_current_thread_affinity(int cpu) {
-#ifdef __OpenBSD__
- return false;
-#else
+#if defined(JEMALLOC_HAVE_SCHED_SETAFFINITY) || defined(JEMALLOC_HAVE_PTHREAD_SETAFFINITY_NP)
#if defined(JEMALLOC_HAVE_SCHED_SETAFFINITY)
cpu_set_t cpuset;
#else
@@ -146,6 +144,8 @@ set_current_thread_affinity(int cpu) {
# endif
return ret != 0;
#endif
+#else
+ return false;
#endif
}