2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 960416-1.c
blobf7cb056802ceeab88e94c8f061da663b0860f7d3
1 typedef unsigned long int st;
2 typedef unsigned long long dt;
3 typedef union
5 dt d;
6 struct
8 st h, l;
11 } t_be;
13 typedef union
15 dt d;
16 struct
18 st l, h;
21 } t_le;
23 #define df(f, t) \
24 int \
25 f (t afh, t bfh) \
26 { \
27 t hh; \
28 t hp, lp, dp, m; \
29 st ad, bd; \
30 int s; \
31 s = 0; \
32 ad = afh.s.h - afh.s.l; \
33 bd = bfh.s.l - bfh.s.h; \
34 if (bd > bfh.s.l) \
35 { \
36 bd = -bd; \
37 s = ~s; \
38 } \
39 lp.d = (dt) afh.s.l * bfh.s.l; \
40 hp.d = (dt) afh.s.h * bfh.s.h; \
41 dp.d = (dt) ad *bd; \
42 dp.d ^= s; \
43 hh.d = hp.d + hp.s.h + lp.s.h + dp.s.h; \
44 m.d = (dt) lp.s.h + hp.s.l + lp.s.l + dp.s.l; \
45 return hh.s.l + m.s.l; \
48 df(f_le, t_le)
49 df(f_be, t_be)
51 main ()
53 t_be x;
54 x.s.h = 0x10000000U;
55 x.s.l = 0xe0000000U;
56 if (x.d == 0x10000000e0000000ULL
57 && f_be ((t_be) 0x100000000ULL, (t_be) 0x100000000ULL) != -1)
58 abort ();
59 if (x.d == 0xe000000010000000ULL
60 && f_le ((t_le) 0x100000000ULL, (t_le) 0x100000000ULL) != -1)
61 abort ();
62 exit (0);