1From 51a092ebb36dcc6180ceb93a9777258e826d9990 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 26 Sep 2018 18:11:10 -0700
4Subject: [PATCH] netlib.c: Move including sched.h out og function
5
6The shutdown_control() has this code where system headers are being
7included inside function body and this results in compile errors on musl
8especially when sched.h is included because sched.h defines a macro
9which defines a static function. This means it ends up being a static
10function inside another function and compiler calls it out
11
12In function 'bind_to_specific_processor':
13|
14/mnt/a/yoe/build/tmp/work/i586-yoe-linux-musl/netperf/2.7.0+git999-r0/recipe-sysroot/usr/include/sched.h:102:1:
15error: invalid storage class for function '__CPU_AND_S'
16|  __CPU_op_func_S(AND, &)
17|  ^~~~~~~~~~~~~~~
18
19Moving the definition out of function definition fixes the problem
20
21Upstream-Status: Pending
22
23Signed-off-by: Khem Raj <raj.khem@gmail.com>
24---
25 src/netlib.c | 5 ++++-
26 1 file changed, 4 insertions(+), 1 deletion(-)
27
28diff --git a/src/netlib.c b/src/netlib.c
29index 9258424..60b032d 100644
30--- a/src/netlib.c
31+++ b/src/netlib.c
32@@ -2262,6 +2262,10 @@ shutdown_control()
33
34 }
35
36+#if HAVE_SCHED_SETAFFINITY
37+#include <sched.h>
38+#endif
39+
40 /*
41   bind_to_specific_processor will bind the calling process to the
42   processor in "processor"  It has lots of ugly ifdefs to deal with
43@@ -2308,7 +2312,6 @@ bind_to_specific_processor(int processor_affinity, int use_cpu_map)
44      value will not tell you if you are bound vs unbound. */
45   bindprocessor(BINDPROCESS,getpid(),(cpu_t)mapped_affinity);
46 #elif HAVE_SCHED_SETAFFINITY
47-#include <sched.h>
48   /* in theory this should cover systems with more CPUs than bits in a
49      long, without having to specify __USE_GNU.  we "cheat" by taking
50      defines from /usr/include/bits/sched.h, which we ass-u-me is
51