1 |
689 |
jeremybenn |
/* { dg-options "-std=gnu99 -D_GNU_SOURCE -pthread" } */
|
2 |
|
|
/* { dg-do run { target i?86-*-linux* x86_64-*-linux* } } */
|
3 |
|
|
|
4 |
|
|
/* N1150 5.2: Conversions among decimal floating types and between
|
5 |
|
|
decimal floating types and generic floating types.
|
6 |
|
|
C99 6.3.1.5(3) New.
|
7 |
|
|
|
8 |
|
|
Perform conversions between DFP types in which the assigned value
|
9 |
|
|
cannot be represented exactly in the result and must be rounded
|
10 |
|
|
correctly according to the current rounding mode.
|
11 |
|
|
|
12 |
|
|
Normally this would not be part of compiler testing, but conversions
|
13 |
|
|
are currently handled in libgcc via decNumber. */
|
14 |
|
|
|
15 |
|
|
#include <pthread.h>
|
16 |
|
|
#include <error.h>
|
17 |
|
|
#include <stdlib.h>
|
18 |
|
|
#include <stdio.h>
|
19 |
|
|
#include <stddef.h>
|
20 |
|
|
#include "dfp-round.h"
|
21 |
|
|
|
22 |
|
|
extern void abort (void);
|
23 |
|
|
static __thread int failcnt = 0;
|
24 |
|
|
|
25 |
|
|
/* Support compiling the test to report individual failures; default is
|
26 |
|
|
to abort as soon as a check fails. */
|
27 |
|
|
#ifdef DBG
|
28 |
|
|
#include <stdio.h>
|
29 |
|
|
#define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
|
30 |
|
|
#else
|
31 |
|
|
#define FAILURE abort ();
|
32 |
|
|
#endif
|
33 |
|
|
|
34 |
|
|
pthread_mutex_t mut1 = PTHREAD_MUTEX_INITIALIZER;
|
35 |
|
|
pthread_mutex_t mut2 = PTHREAD_MUTEX_INITIALIZER;
|
36 |
|
|
pthread_mutex_t mut3 = PTHREAD_MUTEX_INITIALIZER;
|
37 |
|
|
pthread_mutex_t mut4 = PTHREAD_MUTEX_INITIALIZER;
|
38 |
|
|
pthread_mutex_t mut5 = PTHREAD_MUTEX_INITIALIZER;
|
39 |
|
|
pthread_cond_t cond1 = PTHREAD_COND_INITIALIZER;
|
40 |
|
|
pthread_cond_t cond2 = PTHREAD_COND_INITIALIZER;
|
41 |
|
|
pthread_cond_t cond3 = PTHREAD_COND_INITIALIZER;
|
42 |
|
|
pthread_cond_t cond4 = PTHREAD_COND_INITIALIZER;
|
43 |
|
|
pthread_cond_t cond5 = PTHREAD_COND_INITIALIZER;
|
44 |
|
|
pthread_barrier_t bar1;
|
45 |
|
|
pthread_barrier_t bar2;
|
46 |
|
|
pthread_barrier_t bar3;
|
47 |
|
|
pthread_barrier_t bar4;
|
48 |
|
|
pthread_barrier_t bar5;
|
49 |
|
|
|
50 |
|
|
__thread _Decimal32 d32;
|
51 |
|
|
__thread _Decimal64 d64;
|
52 |
|
|
__thread _Decimal128 d128;
|
53 |
|
|
|
54 |
|
|
_Decimal32 d64_to_d32 (_Decimal64 d) { return d; }
|
55 |
|
|
_Decimal64 d128_to_d64 (_Decimal128 d) { return d; }
|
56 |
|
|
_Decimal32 d128_to_d32 (_Decimal128 d) { return d; }
|
57 |
|
|
|
58 |
|
|
int
|
59 |
|
|
do_d64_to_d32 (_Decimal64 orig, _Decimal32 exp)
|
60 |
|
|
{
|
61 |
|
|
d64 = orig;
|
62 |
|
|
d32 = d64_to_d32 (d64);
|
63 |
|
|
return (d32 == exp);
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
int
|
67 |
|
|
do_d128_to_d32 (_Decimal128 orig, _Decimal32 exp)
|
68 |
|
|
{
|
69 |
|
|
d128 = orig;
|
70 |
|
|
d32 = d128_to_d32 (d128);
|
71 |
|
|
return (d32 == exp);
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
int
|
75 |
|
|
do_d128_to_d64 (_Decimal128 orig, _Decimal64 exp)
|
76 |
|
|
{
|
77 |
|
|
d128 = orig;
|
78 |
|
|
d64 = d128_to_d64 (d128);
|
79 |
|
|
return (d64 == exp);
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
void *
|
83 |
|
|
downward (void *arg)
|
84 |
|
|
{
|
85 |
|
|
int err;
|
86 |
|
|
|
87 |
|
|
DFP_SETROUND (FE_DEC_DOWNWARD);
|
88 |
|
|
|
89 |
|
|
err = pthread_mutex_lock (&mut1);
|
90 |
|
|
if (err != 0)
|
91 |
|
|
error (EXIT_FAILURE, err, "downward: failed to lock");
|
92 |
|
|
|
93 |
|
|
err = pthread_barrier_wait (&bar1);
|
94 |
|
|
if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
|
95 |
|
|
{
|
96 |
|
|
puts ("downward: barrier_wait failed");
|
97 |
|
|
exit (1);
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
err = pthread_cond_wait (&cond1, &mut1);
|
101 |
|
|
if (err != 0)
|
102 |
|
|
error (EXIT_FAILURE, err, "downward: failed to wait");
|
103 |
|
|
|
104 |
|
|
err = pthread_mutex_unlock (&mut1);
|
105 |
|
|
if (err != 0)
|
106 |
|
|
error (EXIT_FAILURE, err, "downward: failed to unlock");
|
107 |
|
|
|
108 |
|
|
if (!do_d64_to_d32 (1.1111125dd, 1.111112df)) FAILURE
|
109 |
|
|
if (!do_d64_to_d32 (1.1111135dd, 1.111113df)) FAILURE
|
110 |
|
|
if (!do_d64_to_d32 (-1.1111125dd, -1.111113df)) FAILURE
|
111 |
|
|
if (!do_d64_to_d32 (-1.1111135dd, -1.111114df)) FAILURE
|
112 |
|
|
if (!do_d128_to_d32 (1.1111125dl, 1.111112df)) FAILURE
|
113 |
|
|
if (!do_d128_to_d32 (1.1111135dl, 1.111113df)) FAILURE
|
114 |
|
|
if (!do_d128_to_d32 (-1.1111125dl, -1.111113df)) FAILURE
|
115 |
|
|
if (!do_d128_to_d32 (-1.1111135dl, -1.111114df)) FAILURE
|
116 |
|
|
if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111112dd)) FAILURE
|
117 |
|
|
if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111113dd)) FAILURE
|
118 |
|
|
if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111113dd)) FAILURE
|
119 |
|
|
if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111114dd)) FAILURE
|
120 |
|
|
|
121 |
|
|
#ifdef DBG
|
122 |
|
|
if (failcnt)
|
123 |
|
|
printf ("downward: %d fails\n", failcnt);
|
124 |
|
|
#endif
|
125 |
|
|
return (void *) (ptrdiff_t) failcnt;
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
void *
|
129 |
|
|
tonearest (void *arg)
|
130 |
|
|
{
|
131 |
|
|
int err;
|
132 |
|
|
DFP_SETROUND (FE_DEC_TONEAREST);
|
133 |
|
|
|
134 |
|
|
err = pthread_mutex_lock (&mut2);
|
135 |
|
|
if (err != 0)
|
136 |
|
|
error (EXIT_FAILURE, err, "tonearest: failed to lock");
|
137 |
|
|
|
138 |
|
|
err = pthread_barrier_wait (&bar2);
|
139 |
|
|
if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
|
140 |
|
|
{
|
141 |
|
|
puts ("tonearest: barrier_wait failed");
|
142 |
|
|
exit (1);
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
err = pthread_cond_wait (&cond2, &mut2);
|
146 |
|
|
if (err != 0)
|
147 |
|
|
error (EXIT_FAILURE, err, "tonearest: failed to wait");
|
148 |
|
|
|
149 |
|
|
err = pthread_mutex_unlock (&mut2);
|
150 |
|
|
if (err != 0)
|
151 |
|
|
error (EXIT_FAILURE, err, "tonearest: failed to unlock");
|
152 |
|
|
|
153 |
|
|
if (!do_d64_to_d32 (1.1111125dd, 1.111112df)) FAILURE
|
154 |
|
|
if (!do_d64_to_d32 (1.1111135dd, 1.111114df)) FAILURE
|
155 |
|
|
if (!do_d64_to_d32 (-1.1111125dd, -1.111112df)) FAILURE
|
156 |
|
|
if (!do_d64_to_d32 (-1.1111135dd, -1.111114df)) FAILURE
|
157 |
|
|
if (!do_d128_to_d32 (1.1111125dl, 1.111112df)) FAILURE
|
158 |
|
|
if (!do_d128_to_d32 (1.1111135dl, 1.111114df)) FAILURE
|
159 |
|
|
if (!do_d128_to_d32 (-1.1111125dl, -1.111112df)) FAILURE
|
160 |
|
|
if (!do_d128_to_d32 (-1.1111135dl, -1.111114df)) FAILURE
|
161 |
|
|
if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111112dd)) FAILURE
|
162 |
|
|
if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111114dd)) FAILURE
|
163 |
|
|
if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111112dd)) FAILURE
|
164 |
|
|
if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111114dd)) FAILURE
|
165 |
|
|
|
166 |
|
|
#ifdef DBG
|
167 |
|
|
if (failcnt)
|
168 |
|
|
printf ("tonearest: %d fails\n", failcnt);
|
169 |
|
|
#endif
|
170 |
|
|
return (void *) (ptrdiff_t) failcnt;
|
171 |
|
|
}
|
172 |
|
|
|
173 |
|
|
void *
|
174 |
|
|
toneareastfromzero (void *arg)
|
175 |
|
|
{
|
176 |
|
|
int err;
|
177 |
|
|
DFP_SETROUND (FE_DEC_TONEARESTFROMZERO);
|
178 |
|
|
|
179 |
|
|
err = pthread_mutex_lock (&mut3);
|
180 |
|
|
if (err != 0)
|
181 |
|
|
error (EXIT_FAILURE, err, "toneareastfromzero: failed to lock");
|
182 |
|
|
|
183 |
|
|
err = pthread_barrier_wait (&bar3);
|
184 |
|
|
if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
|
185 |
|
|
{
|
186 |
|
|
puts ("toneareastfromzero: barrier_wait failed");
|
187 |
|
|
exit (1);
|
188 |
|
|
}
|
189 |
|
|
|
190 |
|
|
err = pthread_cond_wait (&cond3, &mut3);
|
191 |
|
|
if (err != 0)
|
192 |
|
|
error (EXIT_FAILURE, err, "toneareastfromzero: failed to wait");
|
193 |
|
|
|
194 |
|
|
err = pthread_mutex_unlock (&mut3);
|
195 |
|
|
if (err != 0)
|
196 |
|
|
error (EXIT_FAILURE, err, "toneareastfromzero: failed to unlock");
|
197 |
|
|
|
198 |
|
|
if (!do_d64_to_d32 (1.1111125dd, 1.111113df)) FAILURE
|
199 |
|
|
if (!do_d64_to_d32 (1.1111135dd, 1.111114df)) FAILURE
|
200 |
|
|
if (!do_d64_to_d32 (-1.1111125dd, -1.111113df)) FAILURE
|
201 |
|
|
if (!do_d64_to_d32 (-1.1111135dd, -1.111114df)) FAILURE
|
202 |
|
|
if (!do_d128_to_d32 (1.1111125dl, 1.111113df)) FAILURE
|
203 |
|
|
if (!do_d128_to_d32 (1.1111135dl, 1.111114df)) FAILURE
|
204 |
|
|
if (!do_d128_to_d32 (-1.1111125dl, -1.111113df)) FAILURE
|
205 |
|
|
if (!do_d128_to_d32 (-1.1111135dl, -1.111114df)) FAILURE
|
206 |
|
|
if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111113dd)) FAILURE
|
207 |
|
|
if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111114dd)) FAILURE
|
208 |
|
|
if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111113dd)) FAILURE
|
209 |
|
|
if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111114dd)) FAILURE
|
210 |
|
|
|
211 |
|
|
#ifdef DBG
|
212 |
|
|
if (failcnt)
|
213 |
|
|
printf ("toneareastfromzero: %d fails\n", failcnt);
|
214 |
|
|
#endif
|
215 |
|
|
return (void *) (ptrdiff_t) failcnt;
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
void *
|
219 |
|
|
towardzero (void *arg)
|
220 |
|
|
{
|
221 |
|
|
int err;
|
222 |
|
|
DFP_SETROUND (FE_DEC_TOWARDZERO);
|
223 |
|
|
|
224 |
|
|
err = pthread_mutex_lock (&mut4);
|
225 |
|
|
if (err != 0)
|
226 |
|
|
error (EXIT_FAILURE, err, "towardzero: failed to lock");
|
227 |
|
|
|
228 |
|
|
err = pthread_barrier_wait (&bar4);
|
229 |
|
|
if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
|
230 |
|
|
{
|
231 |
|
|
puts ("towardzero: barrier_wait failed");
|
232 |
|
|
exit (1);
|
233 |
|
|
}
|
234 |
|
|
|
235 |
|
|
err = pthread_cond_wait (&cond4, &mut4);
|
236 |
|
|
if (err != 0)
|
237 |
|
|
error (EXIT_FAILURE, err, "towardzero: failed to wait");
|
238 |
|
|
|
239 |
|
|
err = pthread_mutex_unlock (&mut4);
|
240 |
|
|
if (err != 0)
|
241 |
|
|
error (EXIT_FAILURE, err, "towardzero: failed to unlock");
|
242 |
|
|
|
243 |
|
|
if (!do_d64_to_d32 (1.1111125dd, 1.111112df)) FAILURE
|
244 |
|
|
if (!do_d64_to_d32 (1.1111135dd, 1.111113df)) FAILURE
|
245 |
|
|
if (!do_d64_to_d32 (-1.1111125dd, -1.111112df)) FAILURE
|
246 |
|
|
if (!do_d64_to_d32 (-1.1111135dd, -1.111113df)) FAILURE
|
247 |
|
|
if (!do_d128_to_d32 (1.1111125dl, 1.111112df)) FAILURE
|
248 |
|
|
if (!do_d128_to_d32 (1.1111135dl, 1.111113df)) FAILURE
|
249 |
|
|
if (!do_d128_to_d32 (-1.1111125dl, -1.111112df)) FAILURE
|
250 |
|
|
if (!do_d128_to_d32 (-1.1111135dl, -1.111113df)) FAILURE
|
251 |
|
|
if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111112dd)) FAILURE
|
252 |
|
|
if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111113dd)) FAILURE
|
253 |
|
|
if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111112dd)) FAILURE
|
254 |
|
|
if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111113dd)) FAILURE
|
255 |
|
|
|
256 |
|
|
#ifdef DBG
|
257 |
|
|
if (failcnt)
|
258 |
|
|
printf ("towardzero: %d fails\n", failcnt);
|
259 |
|
|
#endif
|
260 |
|
|
return (void *) (ptrdiff_t) failcnt;
|
261 |
|
|
}
|
262 |
|
|
|
263 |
|
|
void *
|
264 |
|
|
upward (void *arg)
|
265 |
|
|
{
|
266 |
|
|
int err;
|
267 |
|
|
DFP_SETROUND (FE_DEC_UPWARD);
|
268 |
|
|
|
269 |
|
|
err = pthread_mutex_lock (&mut5);
|
270 |
|
|
if (err != 0)
|
271 |
|
|
error (EXIT_FAILURE, err, "upward: failed to lock");
|
272 |
|
|
|
273 |
|
|
err = pthread_barrier_wait (&bar5);
|
274 |
|
|
if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
|
275 |
|
|
{
|
276 |
|
|
puts ("upward: barrier_wait failed");
|
277 |
|
|
exit (1);
|
278 |
|
|
}
|
279 |
|
|
|
280 |
|
|
err = pthread_cond_wait (&cond5, &mut5);
|
281 |
|
|
if (err != 0)
|
282 |
|
|
error (EXIT_FAILURE, err, "upward: failed to wait");
|
283 |
|
|
|
284 |
|
|
err = pthread_mutex_unlock (&mut5);
|
285 |
|
|
if (err != 0)
|
286 |
|
|
error (EXIT_FAILURE, err, "upward: failed to unlock");
|
287 |
|
|
|
288 |
|
|
if (!do_d64_to_d32 (1.1111125dd, 1.111113df)) FAILURE
|
289 |
|
|
if (!do_d64_to_d32 (1.1111135dd, 1.111114df)) FAILURE
|
290 |
|
|
if (!do_d64_to_d32 (-1.1111125dd, -1.111112df)) FAILURE
|
291 |
|
|
if (!do_d64_to_d32 (-1.1111135dd, -1.111113df)) FAILURE
|
292 |
|
|
if (!do_d128_to_d32 (1.1111125dl, 1.111113df)) FAILURE
|
293 |
|
|
if (!do_d128_to_d32 (1.1111135dl, 1.111114df)) FAILURE
|
294 |
|
|
if (!do_d128_to_d32 (-1.1111125dl, -1.111112df)) FAILURE
|
295 |
|
|
if (!do_d128_to_d32 (-1.1111135dl, -1.111113df)) FAILURE
|
296 |
|
|
if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111113dd)) FAILURE
|
297 |
|
|
if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111114dd)) FAILURE
|
298 |
|
|
if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111112dd)) FAILURE
|
299 |
|
|
if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111113dd)) FAILURE
|
300 |
|
|
|
301 |
|
|
#ifdef DBG
|
302 |
|
|
if (failcnt)
|
303 |
|
|
printf ("upward: %d fails\n", failcnt);
|
304 |
|
|
#endif
|
305 |
|
|
return (void *) (ptrdiff_t) failcnt;
|
306 |
|
|
}
|
307 |
|
|
|
308 |
|
|
int
|
309 |
|
|
main (void)
|
310 |
|
|
{
|
311 |
|
|
int err;
|
312 |
|
|
int count = 0;
|
313 |
|
|
void *ret;
|
314 |
|
|
pthread_t down, up, tozero, fromzero, nearest;
|
315 |
|
|
|
316 |
|
|
if (pthread_barrier_init (&bar1, NULL, 2) != 0
|
317 |
|
|
|| pthread_barrier_init (&bar2, NULL, 2) != 0
|
318 |
|
|
|| pthread_barrier_init (&bar3, NULL, 2) != 0
|
319 |
|
|
|| pthread_barrier_init (&bar4, NULL, 2) != 0
|
320 |
|
|
|| pthread_barrier_init (&bar5, NULL, 2) != 0)
|
321 |
|
|
{
|
322 |
|
|
puts ("parent: failed to init barrier");
|
323 |
|
|
return 1;
|
324 |
|
|
}
|
325 |
|
|
|
326 |
|
|
if (pthread_create (&down, NULL, downward, NULL) != 0)
|
327 |
|
|
{
|
328 |
|
|
puts ("parent: failed to create");
|
329 |
|
|
return 1;
|
330 |
|
|
}
|
331 |
|
|
|
332 |
|
|
if (pthread_create (&nearest, NULL, tonearest, NULL) != 0)
|
333 |
|
|
{
|
334 |
|
|
puts ("create failed");
|
335 |
|
|
return 1;
|
336 |
|
|
}
|
337 |
|
|
|
338 |
|
|
if (pthread_create (&fromzero, NULL, toneareastfromzero, NULL) != 0)
|
339 |
|
|
{
|
340 |
|
|
puts ("create failed");
|
341 |
|
|
return 1;
|
342 |
|
|
}
|
343 |
|
|
|
344 |
|
|
if (pthread_create (&up, NULL, upward, NULL) != 0)
|
345 |
|
|
{
|
346 |
|
|
puts ("create failed");
|
347 |
|
|
return 1;
|
348 |
|
|
}
|
349 |
|
|
|
350 |
|
|
if (pthread_create (&tozero, NULL, towardzero, NULL) != 0)
|
351 |
|
|
{
|
352 |
|
|
puts ("create failed");
|
353 |
|
|
return 1;
|
354 |
|
|
}
|
355 |
|
|
|
356 |
|
|
err = pthread_barrier_wait (&bar1);
|
357 |
|
|
if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
|
358 |
|
|
{
|
359 |
|
|
puts ("parent: failed to wait barrier 1");
|
360 |
|
|
return 1;
|
361 |
|
|
}
|
362 |
|
|
err = pthread_barrier_wait (&bar2);
|
363 |
|
|
if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
|
364 |
|
|
{
|
365 |
|
|
puts ("parent: failed to wait barrier 2");
|
366 |
|
|
return 1;
|
367 |
|
|
}
|
368 |
|
|
err = pthread_barrier_wait (&bar3);
|
369 |
|
|
if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
|
370 |
|
|
{
|
371 |
|
|
puts ("parent: failed to wait barrier 3");
|
372 |
|
|
return 1;
|
373 |
|
|
}
|
374 |
|
|
err = pthread_barrier_wait (&bar4);
|
375 |
|
|
if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
|
376 |
|
|
{
|
377 |
|
|
puts ("parent: failed to wait barrier 4");
|
378 |
|
|
return 1;
|
379 |
|
|
}
|
380 |
|
|
err = pthread_barrier_wait (&bar5);
|
381 |
|
|
if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
|
382 |
|
|
{
|
383 |
|
|
puts ("parent: failed to wait barrier 5");
|
384 |
|
|
return 1;
|
385 |
|
|
}
|
386 |
|
|
|
387 |
|
|
err = pthread_mutex_lock (&mut1);
|
388 |
|
|
if (err != 0)
|
389 |
|
|
error (EXIT_FAILURE, err, "parent: lock failed");
|
390 |
|
|
err = pthread_mutex_lock (&mut2);
|
391 |
|
|
if (err != 0)
|
392 |
|
|
error (EXIT_FAILURE, err, "parent: lock failed");
|
393 |
|
|
err = pthread_mutex_lock (&mut3);
|
394 |
|
|
if (err != 0)
|
395 |
|
|
error (EXIT_FAILURE, err, "parent: lock failed");
|
396 |
|
|
err = pthread_mutex_lock (&mut4);
|
397 |
|
|
if (err != 0)
|
398 |
|
|
error (EXIT_FAILURE, err, "parent: lock failed");
|
399 |
|
|
err = pthread_mutex_lock (&mut5);
|
400 |
|
|
if (err != 0)
|
401 |
|
|
error (EXIT_FAILURE, err, "parent: lock failed");
|
402 |
|
|
|
403 |
|
|
err = pthread_cond_signal(&cond1);
|
404 |
|
|
if (err != 0)
|
405 |
|
|
error (EXIT_FAILURE, err, "parent: broadcast failed");
|
406 |
|
|
err = pthread_cond_signal(&cond2);
|
407 |
|
|
if (err != 0)
|
408 |
|
|
error (EXIT_FAILURE, err, "parent: broadcast failed");
|
409 |
|
|
err = pthread_cond_signal(&cond3);
|
410 |
|
|
if (err != 0)
|
411 |
|
|
error (EXIT_FAILURE, err, "parent: broadcast failed");
|
412 |
|
|
err = pthread_cond_signal(&cond4);
|
413 |
|
|
if (err != 0)
|
414 |
|
|
error (EXIT_FAILURE, err, "parent: broadcast failed");
|
415 |
|
|
err = pthread_cond_signal(&cond5);
|
416 |
|
|
if (err != 0)
|
417 |
|
|
error (EXIT_FAILURE, err, "parent: broadcast failed");
|
418 |
|
|
|
419 |
|
|
err = pthread_mutex_unlock (&mut1);
|
420 |
|
|
if (err != 0)
|
421 |
|
|
{
|
422 |
|
|
puts ("parent: failed to unlock");
|
423 |
|
|
return 1;
|
424 |
|
|
}
|
425 |
|
|
err = pthread_mutex_unlock (&mut2);
|
426 |
|
|
if (err != 0)
|
427 |
|
|
{
|
428 |
|
|
puts ("parent: failed to unlock");
|
429 |
|
|
return 1;
|
430 |
|
|
}
|
431 |
|
|
err = pthread_mutex_unlock (&mut3);
|
432 |
|
|
if (err != 0)
|
433 |
|
|
{
|
434 |
|
|
puts ("parent: failed to unlock");
|
435 |
|
|
return 1;
|
436 |
|
|
}
|
437 |
|
|
err = pthread_mutex_unlock (&mut4);
|
438 |
|
|
if (err != 0)
|
439 |
|
|
{
|
440 |
|
|
puts ("parent: failed to unlock");
|
441 |
|
|
return 1;
|
442 |
|
|
}
|
443 |
|
|
err = pthread_mutex_unlock (&mut5);
|
444 |
|
|
if (err != 0)
|
445 |
|
|
{
|
446 |
|
|
puts ("parent: failed to unlock");
|
447 |
|
|
return 1;
|
448 |
|
|
}
|
449 |
|
|
|
450 |
|
|
if (pthread_join (down, &ret) != 0)
|
451 |
|
|
{
|
452 |
|
|
puts ("pthread_join failed");
|
453 |
|
|
return 1;
|
454 |
|
|
}
|
455 |
|
|
count += (int) (ptrdiff_t) ret;
|
456 |
|
|
|
457 |
|
|
if (pthread_join (up, &ret) != 0)
|
458 |
|
|
{
|
459 |
|
|
puts ("pthread_join failed");
|
460 |
|
|
return 1;
|
461 |
|
|
}
|
462 |
|
|
count += (int) (ptrdiff_t) ret;
|
463 |
|
|
|
464 |
|
|
if (pthread_join (tozero, &ret) != 0)
|
465 |
|
|
{
|
466 |
|
|
puts ("pthread_join failed");
|
467 |
|
|
return 1;
|
468 |
|
|
}
|
469 |
|
|
count += (int) (ptrdiff_t) ret;
|
470 |
|
|
|
471 |
|
|
if (pthread_join (fromzero, &ret) != 0)
|
472 |
|
|
{
|
473 |
|
|
puts ("pthread_join failed");
|
474 |
|
|
return 1;
|
475 |
|
|
}
|
476 |
|
|
count += (int) (ptrdiff_t) ret;
|
477 |
|
|
|
478 |
|
|
if (pthread_join (nearest, &ret) != 0)
|
479 |
|
|
{
|
480 |
|
|
puts ("pthread_join failed");
|
481 |
|
|
return 1;
|
482 |
|
|
}
|
483 |
|
|
count += (int) (ptrdiff_t) ret;
|
484 |
|
|
|
485 |
|
|
if (count)
|
486 |
|
|
{
|
487 |
|
|
#ifdef DBG
|
488 |
|
|
printf ("Total: %d fails\n", count);
|
489 |
|
|
#endif
|
490 |
|
|
abort ();
|
491 |
|
|
}
|
492 |
|
|
|
493 |
|
|
return 0;
|
494 |
|
|
}
|