kumquat-buildroot/package/rng-tools/0002-Allow-for-use-of-either-pthread-affinity-set-methods.patch
Fabrice Fontaine d94e2b6dd4 package/rng-tools: fix musl build
Fix the following musl build failure raised since bump to version 6.14
in commit 5292d1cf9a:

/home/buildroot/autobuild/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/i586-buildroot-linux-musl/9.3.0/../../../../i586-buildroot-linux-musl/bin/ld: rngd-rngd_jitter.o: in function `rngd_notime_start':
rngd_jitter.c:(.text+0xdc2): undefined reference to `pthread_attr_setaffinity_np'

Fixes:
 - http://autobuild.buildroot.org/results/3ec7df86856aa9bee2f18a8faa44fd58bc8a6657

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2021-12-28 21:47:23 +01:00

50 lines
1.5 KiB
Diff

From 5caa086dc14cecf68d1a5c31e87ba1efb2c00893 Mon Sep 17 00:00:00 2001
From: Neil Horman <nhorman@gmail.com>
Date: Thu, 15 Jul 2021 08:48:10 -0400
Subject: [PATCH] Allow for use of either pthread affinity set methods
musl has support for pthread_setaffinity_np, but not
pthread_attr_setaffinity_np. so check for hte existence of either
function in configure, and use the appropriate one.
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
[Retrieved from:
https://github.com/nhorman/rng-tools/commit/5caa086dc14cecf68d1a5c31e87ba1efb2c00893]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
rngd_jitter.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/rngd_jitter.c b/rngd_jitter.c
index ea29436..5c7e09e 100644
--- a/rngd_jitter.c
+++ b/rngd_jitter.c
@@ -67,12 +67,25 @@ static int rngd_notime_start(void *ctx,
for(i=i-1;i>=0;i--) {
CPU_SET(i,cpus);
}
- pthread_attr_setaffinity_np(&thread_ctx->notime_pthread_attr, cpusize, cpus);
+ /*
+ * Note that only one of:
+ * HAVE_PTHREAD_ATTR_SETAFFINITY
+ * and
+ * HAVE_PTHREAD_SETAFFINITY
+ * Will ever be set, as per the configure.ac logic
+ */
+#ifdef HAVE_PTHREAD_ATTR_SETAFFINITY
+ pthread_attr_setaffinity_np(&thread_ctx->notime_pthread_attr, cpusize, cpus);
+#endif
ret = -pthread_create(&thread_ctx->notime_thread_id,
&thread_ctx->notime_pthread_attr,
start_routine, arg);
+#ifdef HAVE_PTHREAD_SETAFFINITY
+ pthread_setaffinity_np(&thread_ctx->notime_thread_id, cpusize, cpus);
+#endif
+
CPU_FREE(cpus);
return ret;
}