diff options
author | ngie <ngie@FreeBSD.org> | 2017-03-12 04:52:09 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2017-03-12 04:52:09 +0000 |
commit | 8279661d6d20dc463f504556b579d2c3cd815b73 (patch) | |
tree | 042065bc2bb30dda20918b863bb50b19c121d4ba /lib | |
parent | 93db61de59060520fbd8ac493f5555485f2acfb9 (diff) | |
download | FreeBSD-src-8279661d6d20dc463f504556b579d2c3cd815b73.zip FreeBSD-src-8279661d6d20dc463f504556b579d2c3cd815b73.tar.gz |
MFC r314650:
Fix warnings in lib/msun/tests/... to help pave way for WARNS?= 6.
- Staticize variables.
- Use nitems liberally. Wherever nitems is used, use unsigned integers
- Remove unused variables (argc, argv, etc)
This fixes most issues -- some issues remain in logarithm_test though.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/msun/tests/cexp_test.c | 28 | ||||
-rw-r--r-- | lib/msun/tests/conj_test.c | 4 | ||||
-rw-r--r-- | lib/msun/tests/csqrt_test.c | 16 | ||||
-rw-r--r-- | lib/msun/tests/ctrig_test.c | 13 | ||||
-rw-r--r-- | lib/msun/tests/exponential_test.c | 8 | ||||
-rw-r--r-- | lib/msun/tests/fenv_test.c | 237 | ||||
-rw-r--r-- | lib/msun/tests/fma_test.c | 6 | ||||
-rw-r--r-- | lib/msun/tests/fmaxmin_test.c | 8 | ||||
-rw-r--r-- | lib/msun/tests/invctrig_test.c | 23 | ||||
-rw-r--r-- | lib/msun/tests/invtrig_test.c | 5 | ||||
-rw-r--r-- | lib/msun/tests/logarithm_test.c | 19 | ||||
-rw-r--r-- | lib/msun/tests/lrint_test.c | 4 | ||||
-rw-r--r-- | lib/msun/tests/nan_test.c | 10 | ||||
-rw-r--r-- | lib/msun/tests/nearbyint_test.c | 21 | ||||
-rw-r--r-- | lib/msun/tests/next_test.c | 2 | ||||
-rw-r--r-- | lib/msun/tests/rem_test.c | 2 | ||||
-rw-r--r-- | lib/msun/tests/test-utils.h | 14 | ||||
-rw-r--r-- | lib/msun/tests/trig_test.c | 4 |
18 files changed, 210 insertions, 214 deletions
diff --git a/lib/msun/tests/cexp_test.c b/lib/msun/tests/cexp_test.c index 6be71ad..5505849 100644 --- a/lib/msun/tests/cexp_test.c +++ b/lib/msun/tests/cexp_test.c @@ -94,7 +94,7 @@ static const float finites[] = /* Tests for 0 */ -void +static void test_zero(void) { @@ -109,10 +109,10 @@ test_zero(void) * Tests for NaN. The signs of the results are indeterminate unless the * imaginary part is 0. */ -void -test_nan() +static void +test_nan(void) { - int i; + unsigned i; /* cexp(x + NaNi) = NaN + NaNi and optionally raises invalid */ /* cexp(NaN + yi) = NaN + NaNi and optionally raises invalid (|y|>0) */ @@ -142,10 +142,10 @@ test_nan() ALL_STD_EXCEPT, 0, 0); } -void +static void test_inf(void) { - int i; + unsigned i; /* cexp(x + inf i) = NaN + NaNi and raises invalid */ for (i = 0; i < nitems(finites); i++) { @@ -184,10 +184,10 @@ test_inf(void) ALL_STD_EXCEPT, 0, 1); } -void +static void test_reals(void) { - int i; + unsigned i; for (i = 0; i < nitems(finites); i++) { /* XXX could check exceptions more meticulously */ @@ -207,10 +207,10 @@ test_reals(void) } } -void +static void test_imaginaries(void) { - int i; + unsigned i; for (i = 0; i < nitems(finites); i++) { printf("# Run %d..\n", i); @@ -229,7 +229,7 @@ test_imaginaries(void) } } -void +static void test_small(void) { static const double tests[] = { @@ -242,7 +242,7 @@ test_small(void) }; double a, b; double x, y; - int i; + unsigned i; for (i = 0; i < nitems(tests); i += 4) { printf("# Run %d..\n", i); @@ -260,7 +260,7 @@ test_small(void) } /* Test inputs with a real part r that would overflow exp(r). */ -void +static void test_large(void) { @@ -288,7 +288,7 @@ test_large(void) } int -main(int argc, char *argv[]) +main(void) { printf("1..7\n"); diff --git a/lib/msun/tests/conj_test.c b/lib/msun/tests/conj_test.c index 7426f9e..960fed5 100644 --- a/lib/msun/tests/conj_test.c +++ b/lib/msun/tests/conj_test.c @@ -71,7 +71,7 @@ static const double tests[] = { }; int -main(int argc, char *argv[]) +main(void) { static const int ntests = sizeof(tests) / sizeof(tests[0]) / 2; complex float in; @@ -90,7 +90,7 @@ main(int argc, char *argv[]) assert(fpequal(libcreall(in), __real__ in)); assert(fpequal(libcimagf(in), __imag__ in)); assert(fpequal(libcimag(in), __imag__ in)); - assert(fpequal(libcimagl(in), __imag__ in)); + assert(fpequal(libcimagl(in), __imag__ in)); feclearexcept(FE_ALL_EXCEPT); if (!cfpequal(libconjf(in), expected)) { diff --git a/lib/msun/tests/csqrt_test.c b/lib/msun/tests/csqrt_test.c index aa119d1..89de14b 100644 --- a/lib/msun/tests/csqrt_test.c +++ b/lib/msun/tests/csqrt_test.c @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); * The latter two convert to float or double, respectively, and test csqrtf() * and csqrt() with the same arguments. */ -long double complex (*t_csqrt)(long double complex); +static long double complex (*t_csqrt)(long double complex); static long double complex _csqrtf(long double complex d) @@ -82,7 +82,7 @@ assert_equal(long double complex d1, long double complex d2) * exceptions.) */ static void -test_finite() +test_finite(void) { static const double tests[] = { /* csqrt(a + bI) = x + yI */ @@ -125,7 +125,7 @@ test_finite() double a, b; double x, y; - int i, j; + unsigned i, j; for (i = 0; i < nitems(tests); i += 4) { for (j = 0; j < nitems(mults); j++) { @@ -143,7 +143,7 @@ test_finite() * Test the handling of +/- 0. */ static void -test_zeros() +test_zeros(void) { assert_equal(t_csqrt(CMPLXL(0.0, 0.0)), CMPLXL(0.0, 0.0)); @@ -156,7 +156,7 @@ test_zeros() * Test the handling of infinities when the other argument is not NaN. */ static void -test_infinities() +test_infinities(void) { static const double vals[] = { 0.0, @@ -167,7 +167,7 @@ test_infinities() -INFINITY, }; - int i; + unsigned i; for (i = 0; i < nitems(vals); i++) { if (isfinite(vals[i])) { @@ -187,7 +187,7 @@ test_infinities() * Test the handling of NaNs. */ static void -test_nans() +test_nans(void) { assert(creall(t_csqrt(CMPLXL(INFINITY, NAN))) == INFINITY); @@ -232,7 +232,7 @@ test_overflow(int maxexp) } int -main(int argc, char *argv[]) +main(void) { printf("1..15\n"); diff --git a/lib/msun/tests/ctrig_test.c b/lib/msun/tests/ctrig_test.c index 0f6d616..c37e151 100644 --- a/lib/msun/tests/ctrig_test.c +++ b/lib/msun/tests/ctrig_test.c @@ -31,6 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/param.h> #include <complex.h> #include <fenv.h> #include <float.h> @@ -238,7 +239,7 @@ ATF_TC_BODY(test_inf_inputs, tc) 0, M_PI / 4, 3 * M_PI / 4, 5 * M_PI / 4, }; long double complex z, c, s; - int i; + unsigned i; /* * IN CSINH CCOSH CTANH @@ -260,7 +261,7 @@ ATF_TC_BODY(test_inf_inputs, tc) testall_odd(ctan, z, CMPLXL(0, 1), ALL_STD_EXCEPT, 0, CS_REAL); /* XXX We allow spurious inexact exceptions here (hard to avoid). */ - for (i = 0; i < sizeof(finites) / sizeof(finites[0]); i++) { + for (i = 0; i < nitems(finites); i++) { z = CMPLXL(INFINITY, finites[i]); c = INFINITY * cosl(finites[i]); s = finites[i] == 0 ? finites[i] : INFINITY * sinl(finites[i]); @@ -308,9 +309,9 @@ ATF_TC_BODY(test_axes, tc) 5 * M_PI / 4, 3 * M_PI / 2, 7 * M_PI / 4, }; long double complex z; - int i; + unsigned i; - for (i = 0; i < sizeof(nums) / sizeof(nums[0]); i++) { + for (i = 0; i < nitems(nums); i++) { /* Real axis */ z = CMPLXL(nums[i], 0.0); test_odd_tol(csinh, z, CMPLXL(sinh(nums[i]), 0), DBL_ULP()); @@ -412,9 +413,9 @@ ATF_TC_BODY(test_small_inputs, tc) -0.26580222883407969212086273981988897L } }; long double complex z; - int i; + unsigned i; - for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { + for (i = 0; i < nitems(tests); i++) { z = CMPLXL(tests[i].a, tests[i].b); testall_odd_tol(csinh, z, CMPLXL(tests[i].sinh_a, tests[i].sinh_b), 1.1); diff --git a/lib/msun/tests/exponential_test.c b/lib/msun/tests/exponential_test.c index df552ee..5b39d29 100644 --- a/lib/msun/tests/exponential_test.c +++ b/lib/msun/tests/exponential_test.c @@ -89,7 +89,7 @@ __FBSDID("$FreeBSD$"); test(expm1f, x, result, exceptmask, excepts); \ } while (0) -void +static void run_generic_tests(void) { @@ -122,10 +122,10 @@ run_generic_tests(void) testall1(-50000.0, -1.0, ALL_STD_EXCEPT, FE_INEXACT); } -void +static void run_exp2_tests(void) { - int i; + unsigned i; /* * We should insist that exp2() return exactly the correct @@ -148,7 +148,7 @@ run_exp2_tests(void) } int -main(int argc, char *argv[]) +main(void) { printf("1..3\n"); diff --git a/lib/msun/tests/fenv_test.c b/lib/msun/tests/fenv_test.c index 0ea6e42..1599644 100644 --- a/lib/msun/tests/fenv_test.c +++ b/lib/msun/tests/fenv_test.c @@ -64,56 +64,15 @@ static const int std_excepts[] = { /* init_exceptsets() initializes this to the power set of std_excepts[] */ static int std_except_sets[1 << NEXCEPTS]; -static void init_exceptsets(void); - -static void test_dfl_env(void); -static void test_fegsetenv(void); -static void test_fegsetexceptflag(void); -static void test_masking(void); -static void test_fegsetround(void); -static void test_feholdupdate(void); -static void test_feraiseexcept(void); -static void test_fetestclearexcept(void); - -static int getround(void); -static void raiseexcept(int excepts); -static void trap_handler(int sig); - #pragma STDC FENV_ACCESS ON -int -main(int argc, char *argv[]) -{ - - printf("1..8\n"); - init_exceptsets(); - test_dfl_env(); - printf("ok 1 - fenv\n"); - test_fetestclearexcept(); - printf("ok 2 - fenv\n"); - test_fegsetexceptflag(); - printf("ok 3 - fenv\n"); - test_feraiseexcept(); - printf("ok 4 - fenv\n"); - test_fegsetround(); - printf("ok 5 - fenv\n"); - test_fegsetenv(); - printf("ok 6 - fenv\n"); - test_masking(); - printf("ok 7 - fenv\n"); - test_feholdupdate(); - printf("ok 8 - fenv\n"); - - return (0); -} - /* * Initialize std_except_sets[] to the power set of std_excepts[] */ -void +static void init_exceptsets(void) { - int i, j, sr; + unsigned i, j, sr; for (i = 0; i < 1 << NEXCEPTS; i++) { for (sr = i, j = 0; sr != 0; sr >>= 1, j++) @@ -122,6 +81,90 @@ init_exceptsets(void) } /* + * Raise a floating-point exception without relying on the standard + * library routines, which we are trying to test. + * + * XXX We can't raise an {over,under}flow without also raising an + * inexact exception. + */ +static void +raiseexcept(int excepts) +{ + volatile double d; + + /* + * With a compiler that supports the FENV_ACCESS pragma + * properly, simple expressions like '0.0 / 0.0' should + * be sufficient to generate traps. Unfortunately, we + * need to bring a volatile variable into the equation + * to prevent incorrect optimizations. + */ + if (excepts & FE_INVALID) { + d = 0.0; + d = 0.0 / d; + } + if (excepts & FE_DIVBYZERO) { + d = 0.0; + d = 1.0 / d; + } + if (excepts & FE_OVERFLOW) { + d = DBL_MAX; + d *= 2.0; + } + if (excepts & FE_UNDERFLOW) { + d = DBL_MIN; + d /= DBL_MAX; + } + if (excepts & FE_INEXACT) { + d = DBL_MIN; + d += 1.0; + } + + /* + * On the x86 (and some other architectures?) the FPU and + * integer units are decoupled. We need to execute an FWAIT + * or a floating-point instruction to get synchronous exceptions. + */ + d = 1.0; + d += 1.0; +} + +/* + * Determine the current rounding mode without relying on the fenv + * routines. This function may raise an inexact exception. + */ +static int +getround(void) +{ + volatile double d; + + /* + * This test works just as well with 0.0 - 0.0, except on ia64 + * where 0.0 - 0.0 gives the wrong sign when rounding downwards. + */ + d = 1.0; + d -= 1.0; + if (copysign(1.0, d) < 0.0) + return (FE_DOWNWARD); + + d = 1.0; + if (d + (DBL_EPSILON * 3.0 / 4.0) == 1.0) + return (FE_TOWARDZERO); + if (d + (DBL_EPSILON * 1.0 / 4.0) > 1.0) + return (FE_UPWARD); + + return (FE_TONEAREST); +} + +static void +trap_handler(int sig) +{ + + assert(sig == SIGFPE); + _exit(0); +} + +/* * This tests checks the default FP environment, so it must be first. * The memcmp() test below may be too much to ask for, since there * could be multiple machine-specific default environments. @@ -347,7 +390,8 @@ static void test_masking(void) { struct sigaction act; - int except, i, pass, raise, status; + int except, pass, raise, status; + unsigned i; assert((fegetexcept() & ALL_STD_EXCEPT) == 0); assert((feenableexcept(FE_INVALID|FE_OVERFLOW) & ALL_STD_EXCEPT) == 0); @@ -427,7 +471,8 @@ test_feholdupdate(void) fenv_t env; struct sigaction act; - int except, i, pass, status, raise; + int except, pass, status, raise; + unsigned i; sigemptyset(&act.sa_mask); act.sa_flags = 0; @@ -452,7 +497,7 @@ test_feholdupdate(void) * We don't want to cause a fatal exception in * the child until the second pass, so we can * check other properties of feupdateenv(). - */ + */ if (pass == 1) assert((feenableexcept(except) & ALL_STD_EXCEPT) == 0); @@ -491,86 +536,28 @@ test_feholdupdate(void) assert(fetestexcept(FE_ALL_EXCEPT) == 0); } -/* - * Raise a floating-point exception without relying on the standard - * library routines, which we are trying to test. - * - * XXX We can't raise an {over,under}flow without also raising an - * inexact exception. - */ -static void -raiseexcept(int excepts) -{ - volatile double d; - - /* - * With a compiler that supports the FENV_ACCESS pragma - * properly, simple expressions like '0.0 / 0.0' should - * be sufficient to generate traps. Unfortunately, we - * need to bring a volatile variable into the equation - * to prevent incorrect optimizations. - */ - if (excepts & FE_INVALID) { - d = 0.0; - d = 0.0 / d; - } - if (excepts & FE_DIVBYZERO) { - d = 0.0; - d = 1.0 / d; - } - if (excepts & FE_OVERFLOW) { - d = DBL_MAX; - d *= 2.0; - } - if (excepts & FE_UNDERFLOW) { - d = DBL_MIN; - d /= DBL_MAX; - } - if (excepts & FE_INEXACT) { - d = DBL_MIN; - d += 1.0; - } - - /* - * On the x86 (and some other architectures?) the FPU and - * integer units are decoupled. We need to execute an FWAIT - * or a floating-point instruction to get synchronous exceptions. - */ - d = 1.0; - d += 1.0; -} - -/* - * Determine the current rounding mode without relying on the fenv - * routines. This function may raise an inexact exception. - */ -static int -getround(void) +int +main(void) { - volatile double d; - /* - * This test works just as well with 0.0 - 0.0, except on ia64 - * where 0.0 - 0.0 gives the wrong sign when rounding downwards. - */ - d = 1.0; - d -= 1.0; - if (copysign(1.0, d) < 0.0) - return (FE_DOWNWARD); - - d = 1.0; - if (d + (DBL_EPSILON * 3.0 / 4.0) == 1.0) - return (FE_TOWARDZERO); - if (d + (DBL_EPSILON * 1.0 / 4.0) > 1.0) - return (FE_UPWARD); - - return (FE_TONEAREST); -} - -static void -trap_handler(int sig) -{ + printf("1..8\n"); + init_exceptsets(); + test_dfl_env(); + printf("ok 1 - fenv\n"); + test_fetestclearexcept(); + printf("ok 2 - fenv\n"); + test_fegsetexceptflag(); + printf("ok 3 - fenv\n"); + test_feraiseexcept(); + printf("ok 4 - fenv\n"); + test_fegsetround(); + printf("ok 5 - fenv\n"); + test_fegsetenv(); + printf("ok 6 - fenv\n"); + test_masking(); + printf("ok 7 - fenv\n"); + test_feholdupdate(); + printf("ok 8 - fenv\n"); - assert(sig == SIGFPE); - _exit(0); + return (0); } diff --git a/lib/msun/tests/fma_test.c b/lib/msun/tests/fma_test.c index dfcea2a..1b9a490 100644 --- a/lib/msun/tests/fma_test.c +++ b/lib/msun/tests/fma_test.c @@ -84,7 +84,7 @@ __FBSDID("$FreeBSD$"); * This is needed because clang constant-folds fma in ways that are incorrect * in rounding modes other than FE_TONEAREST. */ -volatile double one = 1.0; +static volatile double one = 1.0; static void test_zeroes(void) @@ -472,10 +472,10 @@ test_double_rounding(void) } int -main(int argc, char *argv[]) +main(void) { int rmodes[] = { FE_TONEAREST, FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO }; - int i, j; + unsigned i, j; #if defined(__i386__) printf("1..0 # SKIP all testcases fail on i386\n"); diff --git a/lib/msun/tests/fmaxmin_test.c b/lib/msun/tests/fmaxmin_test.c index 24056b0..581fc25 100644 --- a/lib/msun/tests/fmaxmin_test.c +++ b/lib/msun/tests/fmaxmin_test.c @@ -61,7 +61,7 @@ __FBSDID("$FreeBSD$"); } \ } while (0) -int +static int testall_r(long double big, long double small) { int ok; @@ -86,14 +86,14 @@ testall_r(long double big, long double small) return (ok); } -const char *comment = NULL; +static const char *comment = NULL; /* * Test all the functions: fmaxf, fmax, fmaxl, fminf, fmin, and fminl, * in all rounding modes and with the arguments in different orders. * The input 'big' must be >= 'small'. */ -void +static void testall(int testnum, long double big, long double small) { static const int rmodes[] = { @@ -122,7 +122,7 @@ testall(int testnum, long double big, long double small) #endif int -main(int argc, char *argv[]) +main(void) { printf("1..12\n"); diff --git a/lib/msun/tests/invctrig_test.c b/lib/msun/tests/invctrig_test.c index 34e78a1..7856605 100644 --- a/lib/msun/tests/invctrig_test.c +++ b/lib/msun/tests/invctrig_test.c @@ -31,6 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/param.h> #include <assert.h> #include <complex.h> #include <fenv.h> @@ -123,7 +124,7 @@ c3pi = 9.42477796076937971538793014983850839L; /* Tests for 0 */ -void +static void test_zero(void) { long double complex zero = CMPLXL(0.0, 0.0); @@ -143,8 +144,8 @@ test_zero(void) /* * Tests for NaN inputs. */ -void -test_nan() +static void +test_nan(void) { long double complex nan_nan = CMPLXL(NAN, NAN); long double complex z; @@ -154,7 +155,7 @@ test_nan() * NaN,NaN NaN,NaN NaN,NaN NaN,NaN NaN,NaN * finite,NaN NaN,NaN* NaN,NaN* NaN,NaN* NaN,NaN* * NaN,finite NaN,NaN* NaN,NaN* NaN,NaN* NaN,NaN* - * NaN,Inf Inf,NaN NaN,-Inf ?Inf,NaN ?0,pi/2 + * NaN,Inf Inf,NaN NaN,-Inf ?Inf,NaN ?0,pi/2 * +-Inf,NaN Inf,NaN NaN,?Inf +-Inf,NaN +-0,NaN * +-0,NaN NaN,NaN* pi/2,NaN NaN,NaN* +-0,NaN * NaN,0 NaN,NaN* NaN,NaN* NaN,0 NaN,NaN* @@ -222,7 +223,7 @@ test_nan() testall(catan, z, CMPLXL(NAN, 0.0), ALL_STD_EXCEPT, 0, 0); } -void +static void test_inf(void) { long double complex z; @@ -269,16 +270,16 @@ test_inf(void) } /* Tests along the real and imaginary axes. */ -void +static void test_axes(void) { static const long double nums[] = { -2, -1, -0.5, 0.5, 1, 2 }; long double complex z; - int i; + unsigned i; - for (i = 0; i < sizeof(nums) / sizeof(nums[0]); i++) { + for (i = 0; i < nitems(nums); i++) { /* Real axis */ z = CMPLXL(nums[i], 0.0); if (fabsl(nums[i]) <= 1) { @@ -306,7 +307,7 @@ test_axes(void) } } -void +static void test_small(void) { /* @@ -332,7 +333,7 @@ test_small(void) } /* Test inputs that might cause overflow in a sloppy implementation. */ -void +static void test_large(void) { @@ -340,7 +341,7 @@ test_large(void) } int -main(int argc, char *argv[]) +main(void) { printf("1..6\n"); diff --git a/lib/msun/tests/invtrig_test.c b/lib/msun/tests/invtrig_test.c index 01b0379..3c24d61 100644 --- a/lib/msun/tests/invtrig_test.c +++ b/lib/msun/tests/invtrig_test.c @@ -110,11 +110,10 @@ __FBSDID("$FreeBSD$"); #define testall2(prefix, y, x, result, excepts) \ testall2_tol(prefix, (y), (x), (result), 0, (excepts)) -long double +static long double pi = 3.14159265358979323846264338327950280e+00L, pio3 = 1.04719755119659774615421446109316766e+00L, c3pi = 9.42477796076937971538793014983850839e+00L, -c5pi = 1.57079632679489661923132169163975140e+01L, c7pi = 2.19911485751285526692385036829565196e+01L, c5pio3 = 5.23598775598298873077107230546583851e+00L, sqrt2m1 = 4.14213562373095048801688724209698081e-01L; @@ -444,7 +443,7 @@ test_inverse(void) } int -main(int argc, char *argv[]) +main(void) { #if defined(__i386__) diff --git a/lib/msun/tests/logarithm_test.c b/lib/msun/tests/logarithm_test.c index 18b9ebe..8f253e3 100644 --- a/lib/msun/tests/logarithm_test.c +++ b/lib/msun/tests/logarithm_test.c @@ -31,6 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/param.h> #include <assert.h> #include <fenv.h> #include <float.h> @@ -98,7 +99,7 @@ __FBSDID("$FreeBSD$"); test(log1pl, x, result, exceptmask, excepts); \ } while (0) -void +static void run_generic_tests(void) { @@ -127,10 +128,10 @@ run_generic_tests(void) testall1(-1.0, -INFINITY, ALL_STD_EXCEPT & ~FE_INEXACT, FE_DIVBYZERO); } -void +static void run_log2_tests(void) { - int i; + unsigned i; /* * We should insist that log2() return exactly the correct @@ -154,7 +155,7 @@ run_log2_tests(void) } } -void +static void run_roundingmode_tests(void) { @@ -188,7 +189,7 @@ run_roundingmode_tests(void) fesetround(FE_TONEAREST); } -void +static void run_accuracy_tests(void) { static const struct { @@ -219,9 +220,9 @@ run_accuracy_tests(void) 7.229787154734166181706169344438271459e1L, 3.139856666636059855894123306947856631e1L }, }; - int i; + unsigned i; - for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { + for (i = 0; i < nitems(tests); i++) { test_tol(log2, tests[i].x, tests[i].log2x, DBL_ULP()); test_tol(log2f, tests[i].x, tests[i].log2x, FLT_ULP()); test_tol(log2l, tests[i].x, tests[i].log2x, LDBL_ULP()); @@ -242,7 +243,7 @@ run_accuracy_tests(void) } } -void +static void run_log1p_accuracy_tests(void) { @@ -262,7 +263,7 @@ run_log1p_accuracy_tests(void) } int -main(int argc, char *argv[]) +main(void) { printf("1..5\n"); diff --git a/lib/msun/tests/lrint_test.c b/lib/msun/tests/lrint_test.c index ba099aa..0c85df0 100644 --- a/lib/msun/tests/lrint_test.c +++ b/lib/msun/tests/lrint_test.c @@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$"); #pragma STDC FENV_ACCESS ON -void +static void run_tests(void) { @@ -132,7 +132,7 @@ run_tests(void) } int -main(int argc, char *argv[]) +main(void) { printf("1..1\n"); diff --git a/lib/msun/tests/nan_test.c b/lib/msun/tests/nan_test.c index c12926b..d78f6f4 100644 --- a/lib/msun/tests/nan_test.c +++ b/lib/msun/tests/nan_test.c @@ -32,6 +32,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/param.h> #include <assert.h> #include <fenv.h> #include <float.h> @@ -41,7 +42,7 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include <string.h> -void +static void testnan(const char *nan_format) { char nan_str[128]; @@ -49,10 +50,10 @@ testnan(const char *nan_format) long double ald[4]; double ad[4]; float af[4]; - int i; + unsigned i; snprintf(nan_str, sizeof(nan_str), "nan(%s)", nan_format); - for (i = 0; i < 4; i++) { + for (i = 0; i < nitems(ad); i++) { /* * x86 has an 80-bit long double stored in 96 bits, * so we need to initialize the memory for the memcmp() @@ -61,7 +62,6 @@ testnan(const char *nan_format) bzero(&af[i], sizeof(float)); bzero(&ad[i], sizeof(double)); bzero(&ald[i], sizeof(long double)); - } af[0] = nanf(nan_format); @@ -105,7 +105,7 @@ testnan(const char *nan_format) } int -main(int argc, char *argv[]) +main(void) { printf("1..1\n"); diff --git a/lib/msun/tests/nearbyint_test.c b/lib/msun/tests/nearbyint_test.c index 602ea2a..eebe5c9 100644 --- a/lib/msun/tests/nearbyint_test.c +++ b/lib/msun/tests/nearbyint_test.c @@ -35,6 +35,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/param.h> #include <assert.h> #include <fenv.h> #include <math.h> @@ -49,9 +50,9 @@ static const int rmodes[] = { }; /* Make sure we're testing the library, not some broken compiler built-ins. */ -double (*libnearbyint)(double) = nearbyint; -float (*libnearbyintf)(float) = nearbyintf; -long double (*libnearbyintl)(long double) = nearbyintl; +static double (*libnearbyint)(double) = nearbyint; +static float (*libnearbyintf)(float) = nearbyintf; +static long double (*libnearbyintl)(long double) = nearbyintl; #define nearbyintf libnearbyintf #define nearbyint libnearbyint #define nearbyintl libnearbyintl @@ -69,8 +70,6 @@ static const struct { { NAN, { NAN, NAN, NAN }}, }; -static const int ntests = sizeof(tests) / sizeof(tests[0]); - /* Get the appropriate result for the current rounding mode. */ static float get_output(int testindex, int rmodeindex, int negative) @@ -93,7 +92,7 @@ static void test_nearby(int testindex) { float in, out; - int i; + unsigned i; for (i = 0; i < sizeof(rmodes) / sizeof(rmodes[0]); i++) { fesetround(rmodes[i]); @@ -124,7 +123,7 @@ test_modf(int testindex) float ipartf, ipart_expected; double ipart; long double ipartl; - int i; + unsigned i; for (i = 0; i < sizeof(rmodes) / sizeof(rmodes[0]); i++) { fesetround(rmodes[i]); @@ -161,13 +160,13 @@ test_modf(int testindex) } int -main(int argc, char *argv[]) +main(void) { - int i; + unsigned i; - printf("1..%d\n", ntests * 2); + printf("1..%zu\n", (size_t)(nitems(tests) * 2)); testnum = 1; - for (i = 0; i < ntests; i++) { + for (i = 0; i < nitems(tests); i++) { test_nearby(i); test_modf(i); } diff --git a/lib/msun/tests/next_test.c b/lib/msun/tests/next_test.c index d16fa77..26eaacf 100644 --- a/lib/msun/tests/next_test.c +++ b/lib/msun/tests/next_test.c @@ -73,7 +73,7 @@ static double idd(double); static float idf(float); int -main(int argc, char *argv[]) +main(void) { static const int ex_under = FE_UNDERFLOW | FE_INEXACT; /* shorthand */ static const int ex_over = FE_OVERFLOW | FE_INEXACT; diff --git a/lib/msun/tests/rem_test.c b/lib/msun/tests/rem_test.c index 36e3476..f652ada 100644 --- a/lib/msun/tests/rem_test.c +++ b/lib/msun/tests/rem_test.c @@ -52,7 +52,7 @@ static void testf(float, float, float, int); } while (0) int -main(int argc, char *argv[]) +main(void) { printf("1..3\n"); diff --git a/lib/msun/tests/test-utils.h b/lib/msun/tests/test-utils.h index bf0d6de..023a8f8 100644 --- a/lib/msun/tests/test-utils.h +++ b/lib/msun/tests/test-utils.h @@ -88,6 +88,13 @@ CMPLXL(long double x, long double y) } #endif +static int fpequal(long double, long double) __used; +static int cfpequal(long double complex, long double complex) __used; +static int cfpequal_cs(long double complex, long double complex, + int) __used; +static int cfpequal_tol(long double complex, long double complex, + long double, unsigned int) __used; + /* * Compare d1 and d2 using special rules: NaN == NaN and +0 != -0. * Fail an assertion if they differ. @@ -119,7 +126,8 @@ fpequal_cs(long double x, long double y, int checksign) } static int -fpequal_tol(long double x, long double y, long double tol, unsigned int flags) +fpequal_tol(long double x, long double y, long double tol, + unsigned int flags) { fenv_t env; int ret; @@ -153,7 +161,7 @@ cfpequal(long double complex d1, long double complex d2) { return (fpequal(creall(d1), creall(d2)) && - fpequal(cimagl(d1), cimagl(d2))); + fpequal(cimagl(d1), cimagl(d2))); } static int @@ -165,7 +173,7 @@ cfpequal_cs(long double complex x, long double complex y, int checksign) static int cfpequal_tol(long double complex x, long double complex y, long double tol, - unsigned int flags) + unsigned int flags) { return (fpequal_tol(creal(x), creal(y), tol, flags) && fpequal_tol(cimag(x), cimag(y), tol, flags)); diff --git a/lib/msun/tests/trig_test.c b/lib/msun/tests/trig_test.c index 1dcce1f..3066d15 100644 --- a/lib/msun/tests/trig_test.c +++ b/lib/msun/tests/trig_test.c @@ -153,7 +153,7 @@ run_reduction_tests(void) }; #endif - int i; + unsigned i; for (i = 0; i < nitems(f_pi_odd); i++) { assert(fabs(sinf(f_pi_odd[i])) < FLT_EPSILON); @@ -258,7 +258,7 @@ run_accuracy_tests(void) } int -main(int argc, char *argv[]) +main(void) { printf("1..3\n"); |