1 From e4909f329245db52415102e96fc7c99ca1445d05 Mon Sep 17 00:00:00 2001
2 From: Neil Horman <nhorman@gmail.com>
3 Date: Thu, 15 Jul 2021 08:48:10 -0400
4 Subject: [PATCH] Allow for use of either pthread affinity set methods
6 musl has support for pthread_setaffinity_np, but not
7 pthread_attr_setaffinity_np. so check for hte existence of either
8 function in configure, and use the appropriate one.
10 Upstream-Status: Backport
11 Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
12 Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
14 rngd_jitter.c | 15 ++++++++++++++-
15 1 file changed, 14 insertions(+), 1 deletion(-)
17 diff --git a/rngd_jitter.c b/rngd_jitter.c
18 index ea29436..5c7e09e 100644
21 @@ -67,12 +67,25 @@ static int rngd_notime_start(void *ctx,
25 - pthread_attr_setaffinity_np(&thread_ctx->notime_pthread_attr, cpusize, cpus);
28 + * Note that only one of:
29 + * HAVE_PTHREAD_ATTR_SETAFFINITY
31 + * HAVE_PTHREAD_SETAFFINITY
32 + * Will ever be set, as per the configure.ac logic
34 +#ifdef HAVE_PTHREAD_ATTR_SETAFFINITY
35 + pthread_attr_setaffinity_np(&thread_ctx->notime_pthread_attr, cpusize, cpus);
37 ret = -pthread_create(&thread_ctx->notime_thread_id,
38 &thread_ctx->notime_pthread_attr,
41 +#ifdef HAVE_PTHREAD_SETAFFINITY
42 + pthread_setaffinity_np(&thread_ctx->notime_thread_id, cpusize, cpus);