annotate lib/log.c @ 17587:344018b6e5d7

maint: update copyright I ran 'make update-copyright'. Signed-off-by: Eric Blake <eblake@redhat.com>
author Eric Blake <eblake@redhat.com>
date Wed, 01 Jan 2014 00:04:40 -0700
parents e542fd46ad6f
children ab58d4870664
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16631
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Logarithm.
17587
344018b6e5d7 maint: update copyright
Eric Blake <eblake@redhat.com>
parents: 17249
diff changeset
2 Copyright (C) 2012-2014 Free Software Foundation, Inc.
16631
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
45443deebb7d log: 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
45443deebb7d log: 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
45443deebb7d log: 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
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
45443deebb7d log: 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,
45443deebb7d log: 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
45443deebb7d log: 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
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
45443deebb7d log: 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
45443deebb7d log: 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/>. */
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 #include <config.h>
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 /* Specification. */
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 #include <math.h>
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 double
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 log (double x)
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #undef log
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 {
16643
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16631
diff changeset
26 if (x <= 0.0)
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16631
diff changeset
27 {
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16631
diff changeset
28 /* Work around the OSF/1 5.1 bug. */
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16631
diff changeset
29 if (x == 0.0)
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16631
diff changeset
30 /* Return -Infinity. */
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16631
diff changeset
31 return -1.0 / 0.0;
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16631
diff changeset
32 /* Work around the NetBSD 5.1, Solaris 11 2011-11 bug. */
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16631
diff changeset
33 else /* x < 0.0 */
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16631
diff changeset
34 /* Return NaN. */
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16631
diff changeset
35 return 0.0 / 0.0;
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16631
diff changeset
36 }
16631
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 return log (x);
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 }