diff options
| author | Joseph Myers <joseph@codesourcery.com> | 2013-11-29 16:27:55 +0000 |
|---|---|---|
| committer | Joseph Myers <joseph@codesourcery.com> | 2013-11-29 16:27:55 +0000 |
| commit | ffb536d0ac914a110c160c48d01097d132e20531 (patch) | |
| tree | aaf8d810651e89fa739d42791d66ce1c6df0885e /math | |
| parent | 97161a937370c6a20f93647b3260a7d1a87f2645 (diff) | |
| download | glibc-ffb536d0ac914a110c160c48d01097d132e20531.tar.xz glibc-ffb536d0ac914a110c160c48d01097d132e20531.zip | |
Start generating libm tests automatically with MPFR.
Diffstat (limited to 'math')
| -rw-r--r-- | math/Makefile | 3 | ||||
| -rw-r--r-- | math/auto-libm-test-in | 27 | ||||
| -rw-r--r-- | math/auto-libm-test-out | 225 | ||||
| -rw-r--r-- | math/gen-auto-libm-tests.c | 1626 | ||||
| -rwxr-xr-x | math/gen-libm-test.pl | 185 | ||||
| -rw-r--r-- | math/libm-test.inc | 63 |
6 files changed, 2110 insertions, 19 deletions
diff --git a/math/Makefile b/math/Makefile index fcccab2051..d178789fb5 100644 --- a/math/Makefile +++ b/math/Makefile @@ -112,7 +112,8 @@ ulps-file = $(firstword $(wildcard $(sysdirs:%=%/libm-test-ulps))) $(addprefix $(objpfx), $(libm-tests-generated)): $(objpfx)libm-test.stmp -$(objpfx)libm-test.stmp: $(ulps-file) libm-test.inc gen-libm-test.pl +$(objpfx)libm-test.stmp: $(ulps-file) libm-test.inc gen-libm-test.pl \ + auto-libm-test-out $(make-target-directory) $(PERL) gen-libm-test.pl -u $< -o "$(objpfx)" @echo > $@ diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in new file mode 100644 index 0000000000..5dc790c692 --- /dev/null +++ b/math/auto-libm-test-in @@ -0,0 +1,27 @@ +# libm test inputs for gen-auto-libm-tests.c. +# Copyright (C) 1997-2013 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. */ + +sqrt 0 +sqrt -0 +sqrt 2209 +sqrt 4 +sqrt 2 +sqrt 0.25 +sqrt 6642.25 +sqrt 15190.5625 +sqrt 0.75 diff --git a/math/auto-libm-test-out b/math/auto-libm-test-out new file mode 100644 index 0000000000..bdb6bdc8b8 --- /dev/null +++ b/math/auto-libm-test-out @@ -0,0 +1,225 @@ +sqrt 0 += sqrt downward flt-32 0x0p+0f : 0x0p+0f : += sqrt tonearest flt-32 0x0p+0f : 0x0p+0f : += sqrt towardzero flt-32 0x0p+0f : 0x0p+0f : += sqrt upward flt-32 0x0p+0f : 0x0p+0f : += sqrt downward dbl-64 0x0p+0 : 0x0p+0 : += sqrt tonearest dbl-64 0x0p+0 : 0x0p+0 : += sqrt towardzero dbl-64 0x0p+0 : 0x0p+0 : += sqrt upward dbl-64 0x0p+0 : 0x0p+0 : += sqrt downward ldbl-96-intel 0x0p+0L : 0x0p+0L : += sqrt tonearest ldbl-96-intel 0x0p+0L : 0x0p+0L : += sqrt towardzero ldbl-96-intel 0x0p+0L : 0x0p+0L : += sqrt upward ldbl-96-intel 0x0p+0L : 0x0p+0L : += sqrt downward ldbl-96-m68k 0x0p+0L : 0x0p+0L : += sqrt tonearest ldbl-96-m68k 0x0p+0L : 0x0p+0L : += sqrt towardzero ldbl-96-m68k 0x0p+0L : 0x0p+0L : += sqrt upward ldbl-96-m68k 0x0p+0L : 0x0p+0L : += sqrt downward ldbl-128 0x0p+0L : 0x0p+0L : += sqrt tonearest ldbl-128 0x0p+0L : 0x0p+0L : += sqrt towardzero ldbl-128 0x0p+0L : 0x0p+0L : += sqrt upward ldbl-128 0x0p+0L : 0x0p+0L : += sqrt downward ldbl-128ibm 0x0p+0L : 0x0p+0L : += sqrt tonearest ldbl-128ibm 0x0p+0L : 0x0p+0L : += sqrt towardzero ldbl-128ibm 0x0p+0L : 0x0p+0L : += sqrt upward ldbl-128ibm 0x0p+0L : 0x0p+0L : +sqrt -0 += sqrt downward flt-32 -0x0p+0f : -0x0p+0f : += sqrt tonearest flt-32 -0x0p+0f : -0x0p+0f : += sqrt towardzero flt-32 -0x0p+0f : -0x0p+0f : += sqrt upward flt-32 -0x0p+0f : -0x0p+0f : += sqrt downward dbl-64 -0x0p+0 : -0x0p+0 : += sqrt tonearest dbl-64 -0x0p+0 : -0x0p+0 : += sqrt towardzero dbl-64 -0x0p+0 : -0x0p+0 : += sqrt upward dbl-64 -0x0p+0 : -0x0p+0 : += sqrt downward ldbl-96-intel -0x0p+0L : -0x0p+0L : += sqrt tonearest ldbl-96-intel -0x0p+0L : -0x0p+0L : += sqrt towardzero ldbl-96-intel -0x0p+0L : -0x0p+0L : += sqrt upward ldbl-96-intel -0x0p+0L : -0x0p+0L : += sqrt downward ldbl-96-m68k -0x0p+0L : -0x0p+0L : += sqrt tonearest ldbl-96-m68k -0x0p+0L : -0x0p+0L : += sqrt towardzero ldbl-96-m68k -0x0p+0L : -0x0p+0L : += sqrt upward ldbl-96-m68k -0x0p+0L : -0x0p+0L : += sqrt downward ldbl-128 -0x0p+0L : -0x0p+0L : += sqrt tonearest ldbl-128 -0x0p+0L : -0x0p+0L : += sqrt towardzero ldbl-128 -0x0p+0L : -0x0p+0L : += sqrt upward ldbl-128 -0x0p+0L : -0x0p+0L : += sqrt downward ldbl-128ibm -0x0p+0L : -0x0p+0L : += sqrt tonearest ldbl-128ibm -0x0p+0L : -0x0p+0L : += sqrt towardzero ldbl-128ibm -0x0p+0L : -0x0p+0L : += sqrt upward ldbl-128ibm -0x0p+0L : -0x0p+0L : +sqrt 2209 += sqrt downward flt-32 0x8.a1p+8f : 0x2.fp+4f : += sqrt tonearest flt-32 0x8.a1p+8f : 0x2.fp+4f : += sqrt towardzero flt-32 0x8.a1p+8f : 0x2.fp+4f : += sqrt upward flt-32 0x8.a1p+8f : 0x2.fp+4f : += sqrt downward dbl-64 0x8.a1p+8 : 0x2.fp+4 : += sqrt tonearest dbl-64 0x8.a1p+8 : 0x2.fp+4 : += sqrt towardzero dbl-64 0x8.a1p+8 : 0x2.fp+4 : += sqrt upward dbl-64 0x8.a1p+8 : 0x2.fp+4 : += sqrt downward ldbl-96-intel 0x8.a1p+8L : 0x2.fp+4L : += sqrt tonearest ldbl-96-intel 0x8.a1p+8L : 0x2.fp+4L : += sqrt towardzero ldbl-96-intel 0x8.a1p+8L : 0x2.fp+4L : += sqrt upward ldbl-96-intel 0x8.a1p+8L : 0x2.fp+4L : += sqrt downward ldbl-96-m68k 0x8.a1p+8L : 0x2.fp+4L : += sqrt tonearest ldbl-96-m68k 0x8.a1p+8L : 0x2.fp+4L : += sqrt towardzero ldbl-96-m68k 0x8.a1p+8L : 0x2.fp+4L : += sqrt upward ldbl-96-m68k 0x8.a1p+8L : 0x2.fp+4L : += sqrt downward ldbl-128 0x8.a1p+8L : 0x2.fp+4L : += sqrt tonearest ldbl-128 0x8.a1p+8L : 0x2.fp+4L : += sqrt towardzero ldbl-128 0x8.a1p+8L : 0x2.fp+4L : += sqrt upward ldbl-128 0x8.a1p+8L : 0x2.fp+4L : += sqrt downward ldbl-128ibm 0x8.a1p+8L : 0x2.fp+4L : += sqrt tonearest ldbl-128ibm 0x8.a1p+8L : 0x2.fp+4L : += sqrt towardzero ldbl-128ibm 0x8.a1p+8L : 0x2.fp+4L : += sqrt upward ldbl-128ibm 0x8.a1p+8L : 0x2.fp+4L : +sqrt 4 += sqrt downward flt-32 0x4p+0f : 0x2p+0f : += sqrt tonearest flt-32 0x4p+0f : 0x2p+0f : += sqrt towardzero flt-32 0x4p+0f : 0x2p+0f : += sqrt upward flt-32 0x4p+0f : 0x2p+0f : += sqrt downward dbl-64 0x4p+0 : 0x2p+0 : += sqrt tonearest dbl-64 0x4p+0 : 0x2p+0 : += sqrt towardzero dbl-64 0x4p+0 : 0x2p+0 : += sqrt upward dbl-64 0x4p+0 : 0x2p+0 : += sqrt downward ldbl-96-intel 0x4p+0L : 0x2p+0L : += sqrt tonearest ldbl-96-intel 0x4p+0L : 0x2p+0L : += sqrt towardzero ldbl-96-intel 0x4p+0L : 0x2p+0L : += sqrt upward ldbl-96-intel 0x4p+0L : 0x2p+0L : += sqrt downward ldbl-96-m68k 0x4p+0L : 0x2p+0L : += sqrt tonearest ldbl-96-m68k 0x4p+0L : 0x2p+0L : += sqrt towardzero ldbl-96-m68k 0x4p+0L : 0x2p+0L : += sqrt upward ldbl-96-m68k 0x4p+0L : 0x2p+0L : += sqrt downward ldbl-128 0x4p+0L : 0x2p+0L : += sqrt tonearest ldbl-128 0x4p+0L : 0x2p+0L : += sqrt towardzero ldbl-128 0x4p+0L : 0x2p+0L : += sqrt upward ldbl-128 0x4p+0L : 0x2p+0L : += sqrt downward ldbl-128ibm 0x4p+0L : 0x2p+0L : += sqrt tonearest ldbl-128ibm 0x4p+0L : 0x2p+0L : += sqrt towardzero ldbl-128ibm 0x4p+0L : 0x2p+0L : += sqrt upward ldbl-128ibm 0x4p+0L : 0x2p+0L : +sqrt 2 += sqrt downward flt-32 0x2p+0f : 0x1.6a09e6p+0f : inexact += sqrt tonearest flt-32 0x2p+0f : 0x1.6a09e6p+0f : inexact += sqrt towardzero flt-32 0x2p+0f : 0x1.6a09e6p+0f : inexact += sqrt upward flt-32 0x2p+0f : 0x1.6a09e8p+0f : inexact += sqrt downward dbl-64 0x2p+0 : 0x1.6a09e667f3bccp+0 : inexact += sqrt tonearest dbl-64 0x2p+0 : 0x1.6a09e667f3bcdp+0 : inexact += sqrt towardzero dbl-64 0x2p+0 : 0x1.6a09e667f3bccp+0 : inexact += sqrt upward dbl-64 0x2p+0 : 0x1.6a09e667f3bcdp+0 : inexact += sqrt downward ldbl-96-intel 0x2p+0L : 0x1.6a09e667f3bcc908p+0L : inexact += sqrt tonearest ldbl-96-intel 0x2p+0L : 0x1.6a09e667f3bcc908p+0L : inexact += sqrt towardzero ldbl-96-intel 0x2p+0L : 0x1.6a09e667f3bcc908p+0L : inexact += sqrt upward ldbl-96-intel 0x2p+0L : 0x1.6a09e667f3bcc90ap+0L : inexact += sqrt downward ldbl-96-m68k 0x2p+0L : 0x1.6a09e667f3bcc908p+0L : inexact += sqrt tonearest ldbl-96-m68k 0x2p+0L : 0x1.6a09e667f3bcc908p+0L : inexact += sqrt towardzero ldbl-96-m68k 0x2p+0L : 0x1.6a09e667f3bcc908p+0L : inexact += sqrt upward ldbl-96-m68k 0x2p+0L : 0x1.6a09e667f3bcc90ap+0L : inexact += sqrt downward ldbl-128 0x2p+0L : 0x1.6a09e667f3bcc908b2fb1366ea95p+0L : inexact += sqrt tonearest ldbl-128 0x2p+0L : 0x1.6a09e667f3bcc908b2fb1366ea95p+0L : inexact += sqrt towardzero ldbl-128 0x2p+0L : 0x1.6a09e667f3bcc908b2fb1366ea95p+0L : inexact += sqrt upward ldbl-128 0x2p+0L : 0x1.6a09e667f3bcc908b2fb1366ea96p+0L : inexact += sqrt downward ldbl-128ibm 0x2p+0L : 0x1.6a09e667f3bcc908b2fb1366ea8p+0L : inexact += sqrt tonearest ldbl-128ibm 0x2p+0L : 0x1.6a09e667f3bcc908b2fb1366ea8p+0L : inexact += sqrt towardzero ldbl-128ibm 0x2p+0L : 0x1.6a09e667f3bcc908b2fb1366ea8p+0L : inexact += sqrt upward ldbl-128ibm 0x2p+0L : 0x1.6a09e667f3bcc908b2fb1366ebp+0L : inexact +sqrt 0.25 += sqrt downward flt-32 0x4p-4f : 0x8p-4f : += sqrt tonearest flt-32 0x4p-4f : 0x8p-4f : += sqrt towardzero flt-32 0x4p-4f : 0x8p-4f : += sqrt upward flt-32 0x4p-4f : 0x8p-4f : += sqrt downward dbl-64 0x4p-4 : 0x8p-4 : += sqrt tonearest dbl-64 0x4p-4 : 0x8p-4 : += sqrt towardzero dbl-64 0x4p-4 : 0x8p-4 : += sqrt upward dbl-64 0x4p-4 : 0x8p-4 : += sqrt downward ldbl-96-intel 0x4p-4L : 0x8p-4L : += sqrt tonearest ldbl-96-intel 0x4p-4L : 0x8p-4L : += sqrt towardzero ldbl-96-intel 0x4p-4L : 0x8p-4L : += sqrt upward ldbl-96-intel 0x4p-4L : 0x8p-4L : += sqrt downward ldbl-96-m68k 0x4p-4L : 0x8p-4L : += sqrt tonearest ldbl-96-m68k 0x4p-4L : 0x8p-4L : += sqrt towardzero ldbl-96-m68k 0x4p-4L : 0x8p-4L : += sqrt upward ldbl-96-m68k 0x4p-4L : 0x8p-4L : += sqrt downward ldbl-128 0x4p-4L : 0x8p-4L : += sqrt tonearest ldbl-128 0x4p-4L : 0x8p-4L : += sqrt towardzero ldbl-128 0x4p-4L : 0x8p-4L : += sqrt upward ldbl-128 0x4p-4L : 0x8p-4L : += sqrt downward ldbl-128ibm 0x4p-4L : 0x8p-4L : += sqrt tonearest ldbl-128ibm 0x4p-4L : 0x8p-4L : += sqrt towardzero ldbl-128ibm 0x4p-4L : 0x8p-4L : += sqrt upward ldbl-128ibm 0x4p-4L : 0x8p-4L : +sqrt 6642.25 += sqrt downward flt-32 0x1.9f24p+12f : 0x5.18p+4f : += sqrt tonearest flt-32 0x1.9f24p+12f : 0x5.18p+4f : += sqrt towardzero flt-32 0x1.9f24p+12f : 0x5.18p+4f : += sqrt upward flt-32 0x1.9f24p+12f : 0x5.18p+4f : += sqrt downward dbl-64 0x1.9f24p+12 : 0x5.18p+4 : += sqrt tonearest dbl-64 0x1.9f24p+12 : 0x5.18p+4 : += sqrt towardzero dbl-64 0x1.9f24p+12 : 0x5.18p+4 : += sqrt upward dbl-64 0x1.9f24p+12 : 0x5.18p+4 : += sqrt downward ldbl-96-intel 0x1.9f24p+12L : 0x5.18p+4L : += sqrt tonearest ldbl-96-intel 0x1.9f24p+12L : 0x5.18p+4L : += sqrt towardzero ldbl-96-intel 0x1.9f24p+12L : 0x5.18p+4L : += sqrt upward ldbl-96-intel 0x1.9f24p+12L : 0x5.18p+4L : += sqrt downward ldbl-96-m68k 0x1.9f24p+12L : 0x5.18p+4L : += sqrt tonearest ldbl-96-m68k 0x1.9f24p+12L : 0x5.18p+4L : += sqrt towardzero ldbl-96-m68k 0x1.9f24p+12L : 0x5.18p+4L : += sqrt upward ldbl-96-m68k 0x1.9f24p+12L : 0x5.18p+4L : += sqrt downward ldbl-128 0x1.9f24p+12L : 0x5.18p+4L : += sqrt tonearest ldbl-128 0x1.9f24p+12L : 0x5.18p+4L : += sqrt towardzero ldbl-128 0x1.9f24p+12L : 0x5.18p+4L : += sqrt upward ldbl-128 0x1.9f24p+12L : 0x5.18p+4L : += sqrt downward ldbl-128ibm 0x1.9f24p+12L : 0x5.18p+4L : += sqrt tonearest ldbl-128ibm 0x1.9f24p+12L : 0x5.18p+4L : += sqrt towardzero ldbl-128ibm 0x1.9f24p+12L : 0x5.18p+4L : += sqrt upward ldbl-128ibm 0x1.9f24p+12L : 0x5.18p+4L : +sqrt 15190.5625 += sqrt downward flt-32 0x3.b569p+12f : 0x7.b4p+4f : += sqrt tonearest flt-32 0x3.b569p+12f : 0x7.b4p+4f : += sqrt towardzero flt-32 0x3.b569p+12f : 0x7.b4p+4f : += sqrt upward flt-32 0x3.b569p+12f : 0x7.b4p+4f : += sqrt downward dbl-64 0x3.b569p+12 : 0x7.b4p+4 : += sqrt tonearest dbl-64 0x3.b569p+12 : 0x7.b4p+4 : += sqrt towardzero dbl-64 0x3.b569p+12 : 0x7.b4p+4 : += sqrt upward dbl-64 0x3.b569p+12 : 0x7.b4p+4 : += sqrt downward ldbl-96-intel 0x3.b569p+12L : 0x7.b4p+4L : += sqrt tonearest ldbl-96-intel 0x3.b569p+12L : 0x7.b4p+4L : += sqrt towardzero ldbl-96-intel 0x3.b569p+12L : 0x7.b4p+4L : += sqrt upward ldbl-96-intel 0x3.b569p+12L : 0x7.b4p+4L : += sqrt downward ldbl-96-m68k 0x3.b569p+12L : 0x7.b4p+4L : += sqrt tonearest ldbl-96-m68k 0x3.b569p+12L : 0x7.b4p+4L : += sqrt towardzero ldbl-96-m68k 0x3.b569p+12L : 0x7.b4p+4L : += sqrt upward ldbl-96-m68k 0x3.b569p+12L : 0x7.b4p+4L : += sqrt downward ldbl-128 0x3.b569p+12L : 0x7.b4p+4L : += sqrt tonearest ldbl-128 0x3.b569p+12L : 0x7.b4p+4L : += sqrt towardzero ldbl-128 0x3.b569p+12L : 0x7.b4p+4L : += sqrt upward ldbl-128 0x3.b569p+12L : 0x7.b4p+4L : += sqrt downward ldbl-128ibm 0x3.b569p+12L : 0x7.b4p+4L : += sqrt tonearest ldbl-128ibm 0x3.b569p+12L : 0x7.b4p+4L : += sqrt towardzero ldbl-128ibm 0x3.b569p+12L : 0x7.b4p+4L : += sqrt upward ldbl-128ibm 0x3.b569p+12L : 0x7.b4p+4L : +sqrt 0.75 += sqrt downward flt-32 0xcp-4f : 0xd.db3d7p-4f : inexact += sqrt tonearest flt-32 0xcp-4f : 0xd.db3d7p-4f : inexact += sqrt towardzero flt-32 0xcp-4f : 0xd.db3d7p-4f : inexact += sqrt upward flt-32 0xcp-4f : 0xd.db3d8p-4f : inexact += sqrt downward dbl-64 0xcp-4 : 0xd.db3d742c2655p-4 : inexact += sqrt tonearest dbl-64 0xcp-4 : 0xd.db3d742c2655p-4 : inexact += sqrt towardzero dbl-64 0xcp-4 : 0xd.db3d742c2655p-4 : inexact += sqrt upward dbl-64 0xcp-4 : 0xd.db3d742c26558p-4 : inexact += sqrt downward ldbl-96-intel 0xcp-4L : 0xd.db3d742c265539dp-4L : inexact += sqrt tonearest ldbl-96-intel 0xcp-4L : 0xd.db3d742c265539ep-4L : inexact += sqrt towardzero ldbl-96-intel 0xcp-4L : 0xd.db3d742c265539dp-4L : inexact += sqrt upward ldbl-96-intel 0xcp-4L : 0xd.db3d742c265539ep-4L : inexact += sqrt downward ldbl-96-m68k 0xcp-4L : 0xd.db3d742c265539dp-4L : inexact += sqrt tonearest ldbl-96-m68k 0xcp-4L : 0xd.db3d742c265539ep-4L : inexact += sqrt towardzero ldbl-96-m68k 0xcp-4L : 0xd.db3d742c265539dp-4L : inexact += sqrt upward ldbl-96-m68k 0xcp-4L : 0xd.db3d742c265539ep-4L : inexact += sqrt downward ldbl-128 0xcp-4L : 0xd.db3d742c265539d92ba16b83c5cp-4L : inexact += sqrt tonearest ldbl-128 0xcp-4L : 0xd.db3d742c265539d92ba16b83c5cp-4L : inexact += sqrt towardzero ldbl-128 0xcp-4L : 0xd.db3d742c265539d92ba16b83c5cp-4L : inexact += sqrt upward ldbl-128 0xcp-4L : 0xd.db3d742c265539d92ba16b83c5c8p-4L : inexact += sqrt downward ldbl-128ibm 0xcp-4L : 0xd.db3d742c265539d92ba16b83c4p-4L : inexact += sqrt tonearest ldbl-128ibm 0xcp-4L : 0xd.db3d742c265539d92ba16b83c4p-4L : inexact += sqrt towardzero ldbl-128ibm 0xcp-4L : 0xd.db3d742c265539d92ba16b83c4p-4L : inexact += sqrt upward ldbl-128ibm 0xcp-4L : 0xd.db3d742c265539d92ba16b83c8p-4L : inexact diff --git a/math/gen-auto-libm-tests.c b/math/gen-auto-libm-tests.c new file mode 100644 index 0000000000..57053ad420 --- /dev/null +++ b/math/gen-auto-libm-tests.c @@ -0,0 +1,1626 @@ +/* Generate expected output for libm tests with MPFR and MPC. + Copyright (C) 2013 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Compile this program as: + + gcc -std=gnu99 -O2 -Wall -Wextra gen-auto-libm-tests.c -lmpc -lmpfr -lgmp \ + -o gen-auto-libm-tests + + (use of current MPC and MPFR versions recommended) and run it as: + + gen-auto-libm-tests auto-libm-test-in auto-libm-test-out + + The input file auto-libm-test-in contains three kinds of lines: + + Lines beginning with "#" are comments, and are ignored, as are + empty lines. + + Other lines are test lines, of the form "function input1 input2 + ... [flag1 flag2 ...]". Inputs are either finite real numbers or + integers, depending on the function under test. Real numbers may + be in any form acceptable to mpfr_strtofr (base 0); integers in any + form acceptable to mpz_set_str (base 0). In addition, real numbers + may be certain special strings such as "pi", as listed in the + special_real_inputs array. + + Each flag is a flag name possibly followed by a series of + ":condition". Conditions may be any of the names of floating-point + formats in the floating_point_formats array, "long32" and "long64" + to indicate the number of bits in the "long" type, or other strings + for which libm-test.inc defines a TEST_COND_<condition> macro (with + "-"- changed to "_" in the condition name) evaluating to nonzero + when the condition is true and zero when the condition is false. + The meaning is that the flag applies to the test if all the listed + conditions are true. "flag:cond1:cond2 flag:cond3:cond4" means the + flag applies if ((cond1 && cond2) || (cond3 && cond4)). + + A real number specified as an input is considered to represent the + set of real numbers arising from rounding the given number in any + direction for any supported floating-point format; any roundings + that give infinity are ignored. Each input on a test line has all + the possible roundings considered independently. Each resulting + choice of the tuple of inputs to the function is ignored if the + mathematical result of the function involves a NaN or an exact + infinity, and is otherwise considered for each floating-point + format for which all those inputs are exactly representable. Thus + tests may result in "overflow", "underflow" and "inexact" + exceptions; "invalid" may arise only when the final result type is + an integer type and it is the conversion of a mathematically + defined finite result to integer type that results in that + exception. + + By default, it is assumed that "overflow" and "underflow" + exceptions should be correct, but that "inexact" exceptions should + only be correct for functions listed as exactly determined. For + such functions, "underflow" exceptions should respect whether the + machine has before-rounding or after-rounding tininess detection. + For other functions, it is considered that if the exact result is + somewhere between the greatest magnitude subnormal of a given sign + (exclusive) and the least magnitude normal of that sign + (inclusive), underflow exceptions are permitted but optional on all + machines, and they are also permitted but optional for smaller + subnormal exact results for functions that are not exactly + determined. errno setting is expected for overflow to infinity and + underflow to zero (for real functions), and for out-of-range + conversion of a finite result to integer type, and is considered + permitted but optional for all other cases where overflow + exceptions occur, and where underflow exceptions occur or are + permitted. In other cases (where no overflow or underflow is + permitted), errno is expected to be left unchanged. + + The flag "no-test-inline" indicates a test is disabled for inline + function testing; "xfail" indicates the test is disabled as + expected to produce incorrect results. Otherwise, test flags are + of the form "spurious-<exception>" and "missing-<exception>", for + any exception ("overflow", "underflow", "inexact", "invalid", + "divbyzero"), "spurious-errno" and "missing-errno", to indicate + when tests are expected to deviate from the exception and errno + settings corresponding to the mathematical results. "xfail", + "spurious-" and "missing-" flags should be accompanied by a comment + referring to an open bug in glibc Bugzilla. + + The output file auto-libm-test-out contains the test lines from + auto-libm-test-in, and, after the line for a given test, some + number of output test lines. An output test line is of the form "= + function rounding-mode format input1 input2 ... : output1 output2 + ... : flags". rounding-mode is "tonearest", "towardzero", "upward" + or "downward". format is a name from the floating_point_formats + array, possibly followed by a sequence of ":flag" for flags from + "long32", "long64", "before-rounding" and "after-rounding" (the + last two indicating tests where expectations for underflow + exceptions depend on how the architecture detects tininess). + Inputs and outputs are specified as hex floats with the required + suffix for the floating-point type, or plus_infty or minus_infty + for infinite expected results, or as integer constant expressions + (not necessarily with the right type) or IGNORE for integer inputs + and outputs. Flags are "no-test-inline", "xfail", "<exception>", + "<exception>-ok", "errno-<value>", "errno-<value>-ok", where + "<exception>" and "errno-<value>" are unconditional, indicating + that a correct result means the given exception should be raised or + errno should be set to the given value, and other settings may be + conditional or unconditional; "-ok" means not to test for the given + exception or errno value (whether because it was marked as possibly + missing or spurious, or because the calculation of correct results + indicated it was optional). */ + +#define _GNU_SOURCE + +#include <assert.h> +#include <ctype.h> +#include <errno.h> +#include <error.h> +#include <stdbool.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <gmp.h> +#include <mpfr.h> +#include <mpc.h> + +#define ARRAY_SIZE(A) (sizeof (A) / sizeof ((A)[0])) + +/* The supported floating-point formats. */ +typedef enum + { + fp_flt_32, + fp_dbl_64, + fp_ldbl_96_intel, + fp_ldbl_96_m68k, + fp_ldbl_128, + fp_ldbl_128ibm, + fp_num_formats, + fp_first_format = 0 + } fp_format; + +/* Structure describing a single floating-point format. */ +typedef struct +{ + /* The name of the format. */ + const char *name; + /* The suffix to use on floating-point constants with this + format. */ + const char *suffix; + /* A string for the largest normal value, or NULL for IEEE formats + where this can be determined automatically. */ + const char *max_string; + /* The number of mantissa bits. */ + int mant_dig; + /* The least N such that 2^N overflows. */ + int max_exp; + /* One more than the least N such that 2^N is normal. */ + int min_exp; + /* The largest normal value. */ + mpfr_t max; + /* The least positive normal value, 2^(MIN_EXP-1). */ + mpfr_t min; + /* The greatest positive subnormal value. */ + mpfr_t subnorm_max; + /* The least positive subnormal value, 2^(MIN_EXP-MANT_DIG). */ + mpfr_t subnorm_min; +} fp_format_desc; + +/* List of floating-point formats, in the same order as the fp_format + enumeration. */ +static fp_format_desc fp_formats[fp_num_formats] = + { + { "flt-32", "f", NULL, 24, 128, -125, {}, {}, {}, {} }, + { "dbl-64", "", NULL, 53, 1024, -1021, {}, {}, {}, {} }, + { "ldbl-96-intel", "L", NULL, 64, 16384, -16381, {}, {}, {}, {} }, + { "ldbl-96-m68k", "L", NULL, 64, 16384, -16382, {}, {}, {}, {} }, + { "ldbl-128", "L", NULL, 113, 16384, -16381, {}, {}, {}, {} }, + { "ldbl-128ibm", "L", "0x1.fffffffffffff7ffffffffffff8p+1023", + 106, 1024, -968, {}, {}, {}, {} }, + }; + +/* The supported rounding modes. */ +typedef enum + { + rm_downward, + rm_tonearest, + rm_towardzero, + rm_upward, + rm_num_modes, + rm_first_mode = 0 + } rounding_mode; + +/* Structure describing a single rounding mode. */ +typedef struct +{ + /* The name of the rounding mode. */ + const char *name; + /* The MPFR rounding mode. */ + mpfr_rnd_t mpfr_mode; +} rounding_mode_desc; + +/* List of rounding modes, in the same order as the rounding_mode + enumeration. */ +static const rounding_mode_desc rounding_modes[rm_num_modes] = + { + { "downward", MPFR_RNDD }, + { "tonearest", MPFR_RNDN }, + { "towardzero", MPFR_RNDZ }, + { "upward", MPFR_RNDU }, + }; + +/* The supported exceptions. */ +typedef enum + { + exc_divbyzero, + exc_inexact, + exc_invalid, + exc_overflow, + exc_underflow, + exc_num_exceptions, + exc_first_exception = 0 + } fp_exception; + +/* List of exceptions, in the same order as the fp_exception + enumeration. */ +static const char *const exceptions[exc_num_exceptions] = + { + "divbyzero", + "inexact", + "invalid", + "overflow", + "underflow", + }; + +/* The internal precision to use for most MPFR calculations, which + must be at least 2 more than the greatest precision of any + supported floating-point format. */ +static int internal_precision; + +/* A value that overflows all supported floating-point formats. */ +static mpfr_t global_max; + +/* A value that is at most half the least subnormal in any + floating-point format and so is rounded the same way as all + sufficiently small positive values. */ +static mpfr_t global_min; + +/* The maximum number of (real or integer) arguments to a function + handled by this program (complex arguments count as two real + arguments). */ +#define MAX_NARGS 4 |
