1 /* This is a small test case for returning a complex number. Written by
7 #define BUILD_F_COMPLEX(real, imag) \
8 ({ __complex__ float __retval; \
9 __real__ __retval = (real); \
10 __imag__ __retval = (imag); \
13 #define BUILD_D_COMPLEX(real, imag) \
14 ({ __complex__ double __retval; \
15 __real__ __retval = (real); \
16 __imag__ __retval = (imag); \
19 #define BUILD_LD_COMPLEX(real, imag) \
20 ({ __complex__ long double __retval; \
21 __real__ __retval = (real); \
22 __imag__ __retval = (imag); \
26 aj_f_times2 (__complex__
float x
)
28 __complex__
float res
;
30 __real__ res
= (2.0 * __real__ x
);
31 __imag__ res
= (2.0 * __imag__ x
);
37 aj_d_times2 (__complex__
double x
)
39 __complex__
double res
;
41 __real__ res
= (2.0 * __real__ x
);
42 __imag__ res
= (2.0 * __imag__ x
);
47 __complex__
long double
48 aj_ld_times2 (__complex__
long double x
)
50 __complex__
long double res
;
52 __real__ res
= (2.0 * __real__ x
);
53 __imag__ res
= (2.0 * __imag__ x
);
62 _Complex
float fc
, fd
;
63 _Complex
double dc
, dd
;
64 _Complex
long double ldc
, ldd
;
66 fc
= BUILD_LD_COMPLEX (2.0f
, 3.0f
);
67 fd
= aj_f_times2 (fc
);
69 assert (__real__ fd
== 4.0f
&& __imag__ fd
== 6.0f
);
71 dc
= BUILD_LD_COMPLEX (2.0, 3.0);
72 dd
= aj_ld_times2 (dc
);
74 assert (__real__ dd
== 4.0 && __imag__ dd
== 6.0);
76 ldc
= BUILD_LD_COMPLEX (2.0L, 3.0L);
77 ldd
= aj_ld_times2 (ldc
);
79 assert (__real__ ldd
== 4.0L && __imag__ ldd
== 6.0L);