summaryrefslogtreecommitdiff
path: root/lib/logf.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2012-03-10 16:05:56 +0100
committerBruno Haible <bruno@clisp.org>2012-03-10 16:08:06 +0100
commit14a3c6e4da8e6c5e65d0bba54cd42a91fd582603 (patch)
tree3d28190eac440afcf939c2a961676058d19c846c /lib/logf.c
parent204f9216c0518251439234fe17bd2f7798156aa3 (diff)
downloadgnulib-14a3c6e4da8e6c5e65d0bba54cd42a91fd582603.tar.gz
logf-ieee: Work around test failure on NetBSD 5.1.
* m4/logf-ieee.m4: New file. * m4/logf.m4 (gl_FUNC_LOGF): If gl_FUNC_LOGF_IEEE is present, test whether logf works with a negative argument. Replace it if not. * lib/logf.c (logf): For negative arguments, return NaN. * modules/logf-ieee (Files): Add m4/logf-ieee.m4. (configure.ac): Invoke gl_FUNC_LOGF_IEEE. * doc/posix-functions/logf.texi: Mention the logf-ieee module.
Diffstat (limited to 'lib/logf.c')
-rw-r--r--lib/logf.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/logf.c b/lib/logf.c
index 3bf0f138fe..f2d5250f61 100644
--- a/lib/logf.c
+++ b/lib/logf.c
@@ -24,10 +24,17 @@ logf (float x)
#undef logf
{
#if HAVE_LOGF
- /* Work around the OSF/1 5.1 bug. */
- if (x == 0.0f)
- /* Return -Infinity. */
- return -1.0f / 0.0f;
+ if (x <= 0.0f)
+ {
+ /* Work around the OSF/1 5.1 bug. */
+ if (x == 0.0f)
+ /* Return -Infinity. */
+ return -1.0f / 0.0f;
+ /* Work around the NetBSD 5.1 bug. */
+ else /* x < 0.0 */
+ /* Return NaN. */
+ return 0.0f / 0.0f;
+ }
return logf (x);
#else
return (float) log ((double) x);