Mercurial > hg > octave-shane > gnulib-hg
annotate lib/log10.c @ 16745:78fe2a20b15c
log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
* m4/log10-ieee.m4: New file.
* m4/log10.m4 (gl_FUNC_LOG10): If gl_FUNC_LOG10_IEEE is present, test
whether log10 works with a negative argument. Replace it if not.
* lib/log10.c (log10): For negative arguments, return NaN.
* modules/log10-ieee (Files): Add m4/log10-ieee.m4.
(configure.ac): Invoke gl_FUNC_LOG10_IEEE.
* doc/posix-functions/log10.texi: Mention the log10-ieee module.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 01 Apr 2012 17:10:01 +0200 |
parents | 747e0285fa98 |
children | e542fd46ad6f |
rev | line source |
---|---|
16736
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Base 10 logarithmic function. |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
2 Copyright (C) 2012 Free Software Foundation, Inc. |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 (at your option) any later version. |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 #include <config.h> |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 /* Specification. */ |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 #include <math.h> |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 double |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 log10 (double x) |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 #undef log10 |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 { |
16745
78fe2a20b15c
log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents:
16736
diff
changeset
|
26 if (x <= 0.0) |
78fe2a20b15c
log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents:
16736
diff
changeset
|
27 { |
78fe2a20b15c
log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents:
16736
diff
changeset
|
28 /* Work around the OSF/1 5.1 bug. */ |
78fe2a20b15c
log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents:
16736
diff
changeset
|
29 if (x == 0.0) |
78fe2a20b15c
log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents:
16736
diff
changeset
|
30 /* Return -Infinity. */ |
78fe2a20b15c
log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents:
16736
diff
changeset
|
31 return -1.0 / 0.0; |
78fe2a20b15c
log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents:
16736
diff
changeset
|
32 /* Work around the NetBSD 5.1, Solaris 11 2011-11 bug. */ |
78fe2a20b15c
log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents:
16736
diff
changeset
|
33 else /* x < 0.0 */ |
78fe2a20b15c
log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents:
16736
diff
changeset
|
34 /* Return NaN. */ |
78fe2a20b15c
log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents:
16736
diff
changeset
|
35 return 0.0 / 0.0; |
78fe2a20b15c
log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents:
16736
diff
changeset
|
36 } |
16736
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 return log10 (x); |
747e0285fa98
log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 } |