summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/ltp/ltp/0008-Check-if-__GLIBC_PREREQ-is-defined-before-using-it.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-extended/ltp/ltp/0008-Check-if-__GLIBC_PREREQ-is-defined-before-using-it.patch')
-rw-r--r--meta/recipes-extended/ltp/ltp/0008-Check-if-__GLIBC_PREREQ-is-defined-before-using-it.patch190
1 files changed, 29 insertions, 161 deletions
diff --git a/meta/recipes-extended/ltp/ltp/0008-Check-if-__GLIBC_PREREQ-is-defined-before-using-it.patch b/meta/recipes-extended/ltp/ltp/0008-Check-if-__GLIBC_PREREQ-is-defined-before-using-it.patch
index 428ac30049..7311ee2e41 100644
--- a/meta/recipes-extended/ltp/ltp/0008-Check-if-__GLIBC_PREREQ-is-defined-before-using-it.patch
+++ b/meta/recipes-extended/ltp/ltp/0008-Check-if-__GLIBC_PREREQ-is-defined-before-using-it.patch
@@ -1,7 +1,7 @@
1From a3cbee31daae2466bc8dcac36b33a01352693346 Mon Sep 17 00:00:00 2001 1From fc2b47ad979a87bfbd11aeea3f67c26e7fb39e30 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 7 Jan 2016 19:40:08 +0000 3Date: Thu, 7 Jan 2016 19:40:08 +0000
4Subject: [PATCH 01/26] Check if __GLIBC_PREREQ is defined before using it 4Subject: [PATCH] Check if __GLIBC_PREREQ is defined before using it
5 5
6__GLIBC_PREREQ is specific to glibc so it should be checked if it is 6__GLIBC_PREREQ is specific to glibc so it should be checked if it is
7defined or not. 7defined or not.
@@ -10,13 +10,12 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
10 10
11Upstream-Status: Pending 11Upstream-Status: Pending
12--- 12---
13 testcases/kernel/syscalls/accept4/accept4_01.c | 9 ++++- 13 .../kernel/syscalls/accept4/accept4_01.c | 9 ++++++-
14 testcases/kernel/syscalls/getcpu/getcpu01.c | 39 +++++++++++++++++++++- 14 .../sched_getaffinity/sched_getaffinity01.c | 26 +++++++++++++++++++
15 .../sched_getaffinity/sched_getaffinity01.c | 26 +++++++++++++++ 15 2 files changed, 34 insertions(+), 1 deletion(-)
16 3 files changed, 72 insertions(+), 2 deletions(-)
17 16
18diff --git a/testcases/kernel/syscalls/accept4/accept4_01.c b/testcases/kernel/syscalls/accept4/accept4_01.c 17diff --git a/testcases/kernel/syscalls/accept4/accept4_01.c b/testcases/kernel/syscalls/accept4/accept4_01.c
19index 6072bfa..2b090cb 100644 18index dec4ef93b..c5d74b07f 100644
20--- a/testcases/kernel/syscalls/accept4/accept4_01.c 19--- a/testcases/kernel/syscalls/accept4/accept4_01.c
21+++ b/testcases/kernel/syscalls/accept4/accept4_01.c 20+++ b/testcases/kernel/syscalls/accept4/accept4_01.c
22@@ -64,6 +64,7 @@ static void cleanup(void) 21@@ -64,6 +64,7 @@ static void cleanup(void)
@@ -59,131 +58,8 @@ index 6072bfa..2b090cb 100644
59 #else 58 #else
60 acceptfd = accept4(lfd, (struct sockaddr *)&claddr, &addrlen, 59 acceptfd = accept4(lfd, (struct sockaddr *)&claddr, &addrlen,
61 closeonexec_flag | nonblock_flag); 60 closeonexec_flag | nonblock_flag);
62diff --git a/testcases/kernel/syscalls/getcpu/getcpu01.c b/testcases/kernel/syscalls/getcpu/getcpu01.c
63index c927512..921b107 100644
64--- a/testcases/kernel/syscalls/getcpu/getcpu01.c
65+++ b/testcases/kernel/syscalls/getcpu/getcpu01.c
66@@ -62,6 +62,7 @@
67 #include <dirent.h>
68
69 #if defined(__i386__) || defined(__x86_64__)
70+#if defined(__GLIBC__)
71 #if __GLIBC_PREREQ(2,6)
72 #if defined(__x86_64__)
73 #include <utmpx.h>
74@@ -75,10 +76,17 @@ int sys_support = 0;
75 #else
76 int sys_support = 0;
77 #endif
78+#else
79+int sys_support = 0;
80+#endif
81
82+#if defined(__GLIBC__)
83 #if !(__GLIBC_PREREQ(2, 7))
84 #define CPU_FREE(ptr) free(ptr)
85 #endif
86+#else
87+#define CPU_FREE(ptr) free(ptr)
88+#endif
89
90 void cleanup(void);
91 void setup(void);
92@@ -164,7 +172,11 @@ static inline int getcpu(unsigned *cpu_id, unsigned *node_id,
93 {
94 #if defined(__i386__)
95 return syscall(318, cpu_id, node_id, cache_struct);
96-#elif __GLIBC_PREREQ(2,6)
97+#elif defined(__GLIBC__)
98+#if __GLIBC_PREREQ(2,6)
99+ *cpu_id = sched_getcpu();
100+#endif
101+#else
102 *cpu_id = sched_getcpu();
103 #endif
104 return 0;
105@@ -191,15 +203,20 @@ unsigned int set_cpu_affinity(void)
106 cpu_set_t *set;
107 size_t size;
108 int nrcpus = 1024;
109+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
110 #if __GLIBC_PREREQ(2, 7)
111 realloc:
112 set = CPU_ALLOC(nrcpus);
113 #else
114 set = malloc(sizeof(cpu_set_t));
115 #endif
116+#else
117+ set = malloc(sizeof(cpu_set_t));
118+#endif
119 if (set == NULL) {
120 tst_brkm(TFAIL, NULL, "CPU_ALLOC:errno:%d", errno);
121 }
122+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
123 #if __GLIBC_PREREQ(2, 7)
124 size = CPU_ALLOC_SIZE(nrcpus);
125 CPU_ZERO_S(size, set);
126@@ -207,8 +224,13 @@ realloc:
127 size = sizeof(cpu_set_t);
128 CPU_ZERO(set);
129 #endif
130+#else
131+ size = sizeof(cpu_set_t);
132+ CPU_ZERO(set);
133+#endif
134 if (sched_getaffinity(0, size, set) < 0) {
135 CPU_FREE(set);
136+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
137 #if __GLIBC_PREREQ(2, 7)
138 if (errno == EINVAL && nrcpus < (1024 << 8)) {
139 nrcpus = nrcpus << 2;
140@@ -220,10 +242,17 @@ realloc:
141 "NR_CPUS of the kernel is more than 1024, so we'd better use a newer glibc(>= 2.7)");
142 else
143 #endif
144+#else
145+ if (errno == EINVAL)
146+ tst_resm(TFAIL,
147+ "NR_CPUS of the kernel is more than 1024, so we'd better use a newer glibc(>= 2.7)");
148+ else
149+#endif
150 tst_resm(TFAIL, "sched_getaffinity:errno:%d", errno);
151 tst_exit();
152 }
153 cpu_max = max_cpuid(size, set);
154+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
155 #if __GLIBC_PREREQ(2, 7)
156 CPU_ZERO_S(size, set);
157 CPU_SET_S(cpu_max, size, set);
158@@ -231,6 +260,10 @@ realloc:
159 CPU_ZERO(set);
160 CPU_SET(cpu_max, set);
161 #endif
162+#else
163+ CPU_ZERO(set);
164+ CPU_SET(cpu_max, set);
165+#endif
166 if (sched_setaffinity(0, size, set) < 0) {
167 CPU_FREE(set);
168 tst_brkm(TFAIL, NULL, "sched_setaffinity:errno:%d", errno);
169@@ -247,11 +280,15 @@ unsigned int max_cpuid(size_t size, cpu_set_t * set)
170 {
171 unsigned int index, max = 0;
172 for (index = 0; index < size * BITS_PER_BYTE; index++)
173+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
174 #if __GLIBC_PREREQ(2, 7)
175 if (CPU_ISSET_S(index, size, set))
176 #else
177 if (CPU_ISSET(index, set))
178 #endif
179+#else
180+ if (CPU_ISSET(index, set))
181+#endif
182 max = index;
183 return max;
184 }
185diff --git a/testcases/kernel/syscalls/sched_getaffinity/sched_getaffinity01.c b/testcases/kernel/syscalls/sched_getaffinity/sched_getaffinity01.c 61diff --git a/testcases/kernel/syscalls/sched_getaffinity/sched_getaffinity01.c b/testcases/kernel/syscalls/sched_getaffinity/sched_getaffinity01.c
186index 9d6a81a..4ed13b2 100644 62index 02f04b909..d906d7e09 100644
187--- a/testcases/kernel/syscalls/sched_getaffinity/sched_getaffinity01.c 63--- a/testcases/kernel/syscalls/sched_getaffinity/sched_getaffinity01.c
188+++ b/testcases/kernel/syscalls/sched_getaffinity/sched_getaffinity01.c 64+++ b/testcases/kernel/syscalls/sched_getaffinity/sched_getaffinity01.c
189@@ -67,9 +67,11 @@ do { \ 65@@ -67,9 +67,11 @@ do { \
@@ -198,7 +74,7 @@ index 9d6a81a..4ed13b2 100644
198 74
199 int main(int ac, char **av) 75 int main(int ac, char **av)
200 { 76 {
201@@ -96,14 +98,19 @@ static void do_test(void) 77@@ -96,17 +98,26 @@ static void do_test(void)
202 pid_t unused_pid; 78 pid_t unused_pid;
203 unsigned len; 79 unsigned len;
204 80
@@ -206,27 +82,26 @@ index 9d6a81a..4ed13b2 100644
206 #if __GLIBC_PREREQ(2, 7) 82 #if __GLIBC_PREREQ(2, 7)
207 realloc: 83 realloc:
208 mask = CPU_ALLOC(nrcpus); 84 mask = CPU_ALLOC(nrcpus);
209 #else
210 mask = malloc(sizeof(cpu_set_t));
211 #endif
212+#else 85+#else
213+ mask = malloc(sizeof(cpu_set_t)); 86+ mask = malloc(sizeof(cpu_set_t));
214+#endif 87+#endif
88 #else
89 mask = malloc(sizeof(cpu_set_t));
90 #endif
215 if (mask == NULL) 91 if (mask == NULL)
216 tst_brkm(TFAIL | TTERRNO, cleanup, "fail to get enough memory"); 92 tst_brkm(TFAIL | TTERRNO, cleanup, "fail to get enough memory");
217+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) 93+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
218 #if __GLIBC_PREREQ(2, 7) 94 #if __GLIBC_PREREQ(2, 7)
219 len = CPU_ALLOC_SIZE(nrcpus); 95 len = CPU_ALLOC_SIZE(nrcpus);
220 CPU_ZERO_S(len, mask); 96 CPU_ZERO_S(len, mask);
221@@ -111,10 +118,15 @@ realloc:
222 len = sizeof(cpu_set_t);
223 CPU_ZERO(mask);
224 #endif
225+#else 97+#else
226+ len = sizeof(cpu_set_t); 98+ len = sizeof(cpu_set_t);
227+ CPU_ZERO(mask); 99+ CPU_ZERO(mask);
228+#endif 100+#endif
229 /* positive test */ 101 #else
102 len = sizeof(cpu_set_t);
103 CPU_ZERO(mask);
104@@ -115,11 +126,18 @@ realloc:
230 TEST(sched_getaffinity(0, len, mask)); 105 TEST(sched_getaffinity(0, len, mask));
231 if (TEST_RETURN == -1) { 106 if (TEST_RETURN == -1) {
232 CPU_FREE(mask); 107 CPU_FREE(mask);
@@ -234,50 +109,43 @@ index 9d6a81a..4ed13b2 100644
234 #if __GLIBC_PREREQ(2, 7) 109 #if __GLIBC_PREREQ(2, 7)
235 if (errno == EINVAL && nrcpus < (1024 << 8)) { 110 if (errno == EINVAL && nrcpus < (1024 << 8)) {
236 nrcpus = nrcpus << 2; 111 nrcpus = nrcpus << 2;
237@@ -126,17 +138,27 @@ realloc: 112 goto realloc;
238 "newer glibc(>= 2.7)"); 113 }
239 else
240 #endif
241+#else 114+#else
242+ if (errno == EINVAL) 115+ if (errno == EINVAL)
243+ tst_resm(TFAIL, "NR_CPUS > 1024, we'd better use a " 116+ tst_resm(TFAIL, "NR_CPUS > 1024, we'd better use a "
244+ "newer glibc(>= 2.7)"); 117+ "newer glibc(>= 2.7)");
245+ else 118+ else
246+#endif 119+#endif
247 tst_resm(TFAIL | TTERRNO, "fail to get cpu affinity"); 120 #else
248 cleanup(); 121 if (errno == EINVAL)
249 } else { 122 tst_resm(TFAIL, "NR_CPUS > 1024, we'd better use a "
123@@ -132,8 +150,12 @@ realloc:
250 tst_resm(TINFO, "cpusetsize is %d", len); 124 tst_resm(TINFO, "cpusetsize is %d", len);
251 tst_resm(TINFO, "mask.__bits[0] = %lu ", mask->__bits[0]); 125 tst_resm(TINFO, "mask.__bits[0] = %lu ", mask->__bits[0]);
252 for (i = 0; i < num; i++) { 126 for (i = 0; i < num; i++) {
253+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) 127+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
254 #if __GLIBC_PREREQ(2, 7) 128 #if __GLIBC_PREREQ(2, 7)
255 TEST(CPU_ISSET_S(i, len, mask)); 129 TEST(CPU_ISSET_S(i, len, mask));
256 #else
257 TEST(CPU_ISSET(i, mask));
258 #endif
259+#else 130+#else
260+ TEST(CPU_ISSET(i, mask)); 131+ TEST(CPU_ISSET(i, mask));
261+#endif 132+#endif
262 if (TEST_RETURN != -1) 133 #else
263 tst_resm(TPASS, "sched_getaffinity() succeed, " 134 TEST(CPU_ISSET(i, mask));
264 "this process %d is running " 135 #endif
265@@ -144,11 +166,15 @@ realloc: 136@@ -144,8 +166,12 @@ realloc:
266 } 137 }
267 } 138 }
268 139
269+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) 140+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
270 #if __GLIBC_PREREQ(2, 7) 141 #if __GLIBC_PREREQ(2, 7)
271 CPU_ZERO_S(len, mask); 142 CPU_ZERO_S(len, mask);
272 #else
273 CPU_ZERO(mask);
274 #endif
275+#else 143+#else
276+ CPU_ZERO(mask); 144+ CPU_ZERO(mask);
277+#endif 145+#endif
278 /* negative tests */ 146 #else
279 QUICK_TEST(sched_getaffinity(0, len, (cpu_set_t *) - 1)); 147 CPU_ZERO(mask);
280 QUICK_TEST(sched_getaffinity(0, 0, mask)); 148 #endif
281-- 149--
2821.9.1 1502.17.1
283 151