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