blob: f7470d04bff3a69891ac56004d62510ba3337471 [file] [log] [blame]
Andrew Geisslerd159c7f2021-09-02 21:05:58 -05001From e4909f329245db52415102e96fc7c99ca1445d05 Mon Sep 17 00:00:00 2001
2From: Neil Horman <nhorman@gmail.com>
3Date: Thu, 15 Jul 2021 08:48:10 -0400
4Subject: [PATCH] Allow for use of either pthread affinity set methods
5
6musl has support for pthread_setaffinity_np, but not
7pthread_attr_setaffinity_np. so check for hte existence of either
8function in configure, and use the appropriate one.
9
10Upstream-Status: Backport
11Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
12Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
13---
14 rngd_jitter.c | 15 ++++++++++++++-
15 1 file changed, 14 insertions(+), 1 deletion(-)
16
17diff --git a/rngd_jitter.c b/rngd_jitter.c
18index ea29436..5c7e09e 100644
19--- a/rngd_jitter.c
20+++ b/rngd_jitter.c
21@@ -67,12 +67,25 @@ static int rngd_notime_start(void *ctx,
22 for(i=i-1;i>=0;i--) {
23 CPU_SET(i,cpus);
24 }
25- pthread_attr_setaffinity_np(&thread_ctx->notime_pthread_attr, cpusize, cpus);
26
27+ /*
28+ * Note that only one of:
29+ * HAVE_PTHREAD_ATTR_SETAFFINITY
30+ * and
31+ * HAVE_PTHREAD_SETAFFINITY
32+ * Will ever be set, as per the configure.ac logic
33+ */
34+#ifdef HAVE_PTHREAD_ATTR_SETAFFINITY
35+ pthread_attr_setaffinity_np(&thread_ctx->notime_pthread_attr, cpusize, cpus);
36+#endif
37 ret = -pthread_create(&thread_ctx->notime_thread_id,
38 &thread_ctx->notime_pthread_attr,
39 start_routine, arg);
40
41+#ifdef HAVE_PTHREAD_SETAFFINITY
42+ pthread_setaffinity_np(&thread_ctx->notime_thread_id, cpusize, cpus);
43+#endif
44+
45 CPU_FREE(cpus);
46 return ret;
47 }