diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/c-c++-common/torture/complex-sign.h | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/c-c++-common/torture/complex-sign.h')
-rw-r--r-- | gcc/testsuite/c-c++-common/torture/complex-sign.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/torture/complex-sign.h b/gcc/testsuite/c-c++-common/torture/complex-sign.h new file mode 100644 index 000000000..96261101c --- /dev/null +++ b/gcc/testsuite/c-c++-common/torture/complex-sign.h @@ -0,0 +1,80 @@ +/* Common header for complex arithmetic sign tests. */ + +#ifdef __cplusplus +extern "C" { +#endif +extern void abort (void); +extern void exit (int); +#ifdef __cplusplus +} +#endif + +#define CHECK_RES(VALUE, COPY, SIGN_REAL, SIGN_IMAG) \ + do { \ + if ((VALUE) != 0 \ + || COPY (1.0, __real__ (VALUE)) != SIGN_REAL 1.0 \ + || COPY (1.0, __imag__ (VALUE)) != SIGN_IMAG 1.0) \ + abort (); \ + } while (0) + +/* This definition is intended to work with or without imaginary + types, as long as mixed real/complex arithmetic is handled + correctly. */ +#define ENCODE(ZERO, ZEROI, SA, SB) \ + (SA 1 == 1 \ + ? SB 1 == 1 ? ZERO + ZEROI : ZERO - ZEROI \ + : SB 1 == 1 ? -(ZERO - ZEROI) : -(ZERO + ZEROI)) + +#define CHECK_ARITH(TYPE, COPY, ZERO, ZEROI, OP, S1, S2, S3, S4, SR, SI) \ + do { \ + _Complex TYPE a1, b1, c1; \ + volatile _Complex TYPE a2, b2, c2; \ + a1 = ENCODE(ZERO, ZEROI, S1, S2); \ + CHECK_RES (a1, COPY, S1, S2); \ + b1 = ENCODE(ZERO, ZEROI, S3, S4); \ + CHECK_RES (b1, COPY, S3, S4); \ + c1 = a1 OP b1; \ + CHECK_RES (c1, COPY, SR, SI); \ + a2 = ENCODE(ZERO, ZEROI, S1, S2); \ + CHECK_RES (a2, COPY, S1, S2); \ + b2 = ENCODE(ZERO, ZEROI, S3, S4); \ + CHECK_RES (b2, COPY, S3, S4); \ + c2 = a2 OP b2; \ + CHECK_RES (c2, COPY, SR, SI); \ + } while (0) + +#define CHECK_ARITH_RC(TYPE, COPY, ZERO, ZEROI, OP, S1, S3, S4, SR, SI) \ + do { \ + TYPE a1; \ + _Complex TYPE b1, c1; \ + volatile TYPE a2; \ + volatile _Complex TYPE b2, c2; \ + a1 = S1 ZERO; \ + b1 = ENCODE(ZERO, ZEROI, S3, S4); \ + CHECK_RES (b1, COPY, S3, S4); \ + c1 = a1 OP b1; \ + CHECK_RES (c1, COPY, SR, SI); \ + a2 = S1 ZERO; \ + b2 = ENCODE(ZERO, ZEROI, S3, S4); \ + CHECK_RES (b2, COPY, S3, S4); \ + c2 = a2 OP b2; \ + CHECK_RES (c2, COPY, SR, SI); \ + } while (0) + +#define CHECK_ARITH_CR(TYPE, COPY, ZERO, ZEROI, OP, S1, S2, S3, V3, SR, SI) \ + do { \ + _Complex TYPE a1, c1; \ + TYPE b1; \ + volatile _Complex TYPE a2, c2; \ + volatile TYPE b2; \ + a1 = ENCODE(ZERO, ZEROI, S1, S2); \ + CHECK_RES (a1, COPY, S1, S2); \ + b1 = S3 V3; \ + c1 = a1 OP b1; \ + CHECK_RES (c1, COPY, SR, SI); \ + a2 = ENCODE(ZERO, ZEROI, S1, S2); \ + CHECK_RES (a2, COPY, S1, S2); \ + b2 = S3 V3; \ + c2 = a2 OP b2; \ + CHECK_RES (c2, COPY, SR, SI); \ + } while (0) |