@@ -18,3 +18,6 @@ bench bench-clean:
# Convenience target to rebuild ULPs for all math tests.
regen-ulps:
$(MAKE) -C $(srcdir)/math $(PARALLELMFLAGS) objdir=`pwd` $@
+
+gen-libm-inputs:
+ $(MAKE) -C $(srcdir)/math $(PARALLELMFLAGS) objdir=`pwd` $@
@@ -179,3 +179,10 @@ $(objpfx)bench-%.c: %-inputs $(bench-deps)
fi; \
scripts/bench.py $(patsubst %-inputs,%,$<); } > $@-tmp
mv -f $@-tmp $@
+
+# Auto-generate inputs for libm tests.
+
+auto-libm-test-in-benchtests: $(..)scripts/gen-libm-test-from-benchtests.awk \
+ $(bench-math:%=%-inputs)
+ $(AWK) -f $^ > $(..)math/$@-tmp
+ mv -f $(..)math/$@{-tmp,}
@@ -305,3 +305,31 @@ $(objpfx)atest-exp: $(gmp-objs)
$(objpfx)atest-sincos: $(gmp-objs)
$(objpfx)atest-exp2: $(gmp-objs)
$(objpfx)test-fenv-tls: $(shared-thread-library)
+
+# Generate libm test inputs
+
+# The input files; auto-libm-test-in is the default and
+# auto-libm-test-in-benchtests is auto-generated from all of the input files in
+# benchtests. If there are others that need to be separate from these files,
+# then mention them here to have them included in generating
+# auto-libm-test-out.
+auto-libm-test-inputs := auto-libm-test-in auto-libm-test-in-benchtests
+
+gen-auto-libm-tests-modules := gen-auto-libm-tests
+
+# Very simple target. We don't really care for any glibc configuration to
+# affect this. TODO: add configure check to determine if MPC, MPFR development
+# libraries are available.
+$(objpfx)gen-auto-libm-tests: $(gen-auto-libm-tests-modules:%=%.c)
+ $(CC) -o $@ $^ -O2 -std=gnu11 -Wall -Wextra -lmpc -lmpfr -lgmp
+
+# Don't introduce auto-libm-test-out in the dependency tree because we don't
+# want the tests to be regenerated by default. The target system may not have
+# gmp, mpfr, etc. installed.
+gen-libm-inputs: $(objpfx)gen-auto-libm-tests $(auto-libm-test-inputs)
+ $^ auto-libm-test-out
+
+# Auto-generate inputs from the math benchmark inputs.
+.PHONY: auto-libm-test-in-benchtests
+auto-libm-test-in-benchtests:
+ $(MAKE) -C $(..)/benchtests $(PARALLELMFLAGS) $@
@@ -57,9 +57,16 @@ before it's considered incorrect.
The "auto-libm-test-out" file contains sets of test cases to exercise,
the conditions under which to exercise each, and the expected results.
-The file is generated by the "gen-auto-libm-tests" program from the
-"auto-libm-test-in" file. See the comments in gen-auto-libm-tests.c
-for details about the content and format of the -in and -out files.
+The file is generated by calling make as follows:
+
+ make gen-libm-inputs
+
+This needs a current version of MPC and MPFR. The default input file
+for this is auto-libm-test-in, but there may be additional input files
+that the target may read to generate the output. See the Makefile to
+know which input files the make target currently reads. See also the
+comments in gen-auto-libm-tests.c for details about the content and
+format of the -in and -out files.
How can I generate "libm-test-ulps"?
====================================
@@ -16,16 +16,8 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-/* Compile this program as:
-
- gcc -std=gnu11 -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:
+/* The input files (auto-libm-test-in auto-libm-test-in-benchtests and others)
+ contain three kinds of lines:
Lines beginning with "#" are comments, and are ignored, as are
empty lines.
@@ -99,7 +91,7 @@
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
+ all input files, 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"
@@ -557,7 +549,10 @@ static test_function test_functions[] =
FUNC_mpfr_f_f ("log10", mpfr_log10, false),
FUNC_mpfr_f_f ("log1p", mpfr_log1p, false),
FUNC_mpfr_f_f ("log2", mpfr_log2, false),
+ FUNC ("modf", ARGS1 (type_fp), RET2 (type_fp, type_fp), false, false,
+ false, CALC (mpfr_f_11, mpfr_modf)),
FUNC_mpfr_ff_f ("pow", mpfr_pow, false),
+ FUNC_mpfr_f_f ("rint", mpfr_erf, false),
FUNC_mpfr_f_f ("sin", mpfr_sin, false),
FUNC ("sincos", ARGS1 (type_fp), RET2 (type_fp, type_fp), false, false,
false, CALC (mpfr_f_11, mpfr_sin_cos)),
@@ -2174,12 +2169,15 @@ generate_output (const char *filename)
int
main (int argc, char **argv)
{
- if (argc != 3)
- error (EXIT_FAILURE, 0, "usage: gen-auto-libm-tests <input> <output>");
- const char *input_filename = argv[1];
- const char *output_filename = argv[2];
+ if (argc < 3)
+ error (EXIT_FAILURE, 0, "usage: gen-auto-libm-tests <input> [<input> <input> ...] <output>");
+
init_fp_formats ();
- read_input (input_filename);
- generate_output (output_filename);
+
+ /* Read all input files. */
+ for (int i = 1; i < argc - 1; i++)
+ read_input (argv[i]);
+
+ generate_output (argv[argc - 1]);
exit (EXIT_SUCCESS);
}