From 336bc4aedebe8416db2a3414461edb8310a21ae8 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Fri, 5 Jan 2001 22:06:29 +0000 Subject: [PATCH] 991228-1.c: Take word endianness into account. * gcc.c-torture/execute/991228-1.c: Take word endianness into account. From-SVN: r38725 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/execute/991228-1.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e30ed6002e2..e02464653b7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2001-01-05 Alexandre Oliva + + * gcc.c-torture/execute/991228-1.c: Take word endianness into + account. + 2001-01-05 Joseph S. Myers * gcc.c-torture/execute/builtin-complex-1.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/execute/991228-1.c b/gcc/testsuite/gcc.c-torture/execute/991228-1.c index 31350eb934c..c6fe78e7dad 100644 --- a/gcc/testsuite/gcc.c-torture/execute/991228-1.c +++ b/gcc/testsuite/gcc.c-torture/execute/991228-1.c @@ -1,15 +1,21 @@ __extension__ union { double d; int i[2]; } u = { d: -0.25 }; +/* This assumes the endianness of words in a long long is the same as + that for doubles, which doesn't hold for a few platforms, but we + can probably special case them here, as appropriate. */ +long long endianness_test = 1; +#define MSW (*(int*)&endianness_test) + int signbit(double x) { __extension__ union { double d; int i[2]; } u = { d: x }; - return u.i[0] < 0; + return u.i[MSW] < 0; } int main(void) { - if (2*sizeof(int) != sizeof(double) || u.i[0] >= 0) + if (2*sizeof(int) != sizeof(double) || u.i[MSW] >= 0) exit(0); if (!signbit(-0.25)) -- 2.30.2