X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-signbit.c;h=97f68e6a71b2d323478b07d6328d52066e6e6aca;hb=41fc74b9ab67321453d103d056a6e8eb8897042a;hp=30ba1b07e453b3ef747eca17e1f193cb6c528a63;hpb=4eb59b32a2a687c113f3c0dfc166fc2573acb84f;p=gnulib.git diff --git a/tests/test-signbit.c b/tests/test-signbit.c index 30ba1b07e..97f68e6a7 100644 --- a/tests/test-signbit.c +++ b/tests/test-signbit.c @@ -1,5 +1,5 @@ /* Test of signbit() substitute. - Copyright (C) 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ #include +#include #include #include #include @@ -39,9 +40,28 @@ float zerof = 0.0f; double zerod = 0.0; long double zerol = 0.0L; -/* We cannot use the expression '-zerol' here, because on HP-UX/hppa it - evaluates to 0.0L, not -0.0L. */ + +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f. + So we use -zerof instead. */ + +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. + So we use -zerod instead. */ + +/* On HP-UX 10.20, negating 0.0L does not yield -0.0L. + So we use minus_zerol instead. + IRIX cc can't put -0.0L into .data, but can compute at runtime. + Note that the expression -LDBL_MIN * LDBL_MIN does not work on other + platforms, such as when cross-compiling to PowerPC on MacOS X 10.5. */ +#if defined __hpux || defined __sgi +static long double +compute_minus_zerol (void) +{ + return -LDBL_MIN * LDBL_MIN; +} +# define minus_zerol compute_minus_zerol () +#else long double minus_zerol = -0.0L; +#endif static void test_signbitf () @@ -144,9 +164,9 @@ test_signbitl () /* Zeros. */ ASSERT (!signbit (0.0L)); if (1.0L / minus_zerol < 0) - ASSERT (signbit (-zerol)); + ASSERT (signbit (minus_zerol)); else - ASSERT (!signbit (-zerol)); + ASSERT (!signbit (minus_zerol)); /* Infinite values. */ ASSERT (!signbit (1.0L / 0.0L)); ASSERT (signbit (-1.0L / 0.0L));