diff options
Diffstat (limited to 'meta/recipes-support/rng-tools/rng-tools/0002-Allow-for-use-of-either-pthread-affinity-set-methods.patch')
-rw-r--r-- | meta/recipes-support/rng-tools/rng-tools/0002-Allow-for-use-of-either-pthread-affinity-set-methods.patch | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/meta/recipes-support/rng-tools/rng-tools/0002-Allow-for-use-of-either-pthread-affinity-set-methods.patch b/meta/recipes-support/rng-tools/rng-tools/0002-Allow-for-use-of-either-pthread-affinity-set-methods.patch new file mode 100644 index 0000000000..f7470d04bf --- /dev/null +++ b/meta/recipes-support/rng-tools/rng-tools/0002-Allow-for-use-of-either-pthread-affinity-set-methods.patch | |||
@@ -0,0 +1,47 @@ | |||
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 | ||
5 | |||
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. | ||
9 | |||
10 | Upstream-Status: Backport | ||
11 | Signed-off-by: Neil Horman <nhorman@tuxdriver.com> | ||
12 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> | ||
13 | --- | ||
14 | rngd_jitter.c | 15 ++++++++++++++- | ||
15 | 1 file changed, 14 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/rngd_jitter.c b/rngd_jitter.c | ||
18 | index 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 | } | ||