Try fixing t_strtod to not depend on -ffloat-store by adding the

necessary volatiles.
This commit is contained in:
joerg 2012-04-04 10:52:59 +00:00
parent 719fcf70e0
commit be8014a7fa
2 changed files with 13 additions and 14 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.22 2012/03/29 06:16:56 jruoho Exp $
# $NetBSD: Makefile,v 1.23 2012/04/04 10:52:59 joerg Exp $
.include <bsd.own.mk>
@ -28,7 +28,6 @@ BINDIR= ${TESTSDIR}
PROGS+= h_atexit
PROGS+= h_getopt h_getopt_long
COPTS.t_strtod.c+= -ffloat-store
LDADD.t_strtod= -lm
LDADD.t_getenv_thread= -lpthread

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_strtod.c,v 1.28 2012/03/18 07:00:51 jruoho Exp $ */
/* $NetBSD: t_strtod.c,v 1.29 2012/04/04 10:52:59 joerg Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@ -32,7 +32,7 @@
/* Public domain, Otto Moerbeek <otto@drijf.net>, 2006. */
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_strtod.c,v 1.28 2012/03/18 07:00:51 jruoho Exp $");
__RCSID("$NetBSD: t_strtod.c,v 1.29 2012/04/04 10:52:59 joerg Exp $");
#include <errno.h>
#include <math.h>
@ -92,7 +92,7 @@ ATF_TC_BODY(strtod_hex, tc)
{
const char *str;
char *end;
double d;
volatile double d;
str = "-0x0";
d = strtod(str, &end); /* -0.0 */
@ -119,7 +119,7 @@ ATF_TC_BODY(strtod_inf, tc)
{
#ifndef __vax__
for (size_t i = 0; i < __arraycount(inf_strings); i++) {
double d = strtod(inf_strings[i], NULL);
volatile double d = strtod(inf_strings[i], NULL);
ATF_REQUIRE(isinf(d) != 0);
}
#else
@ -137,7 +137,7 @@ ATF_TC_BODY(strtof_inf, tc)
{
#ifndef __vax__
for (size_t i = 0; i < __arraycount(inf_strings); i++) {
float f = strtof(inf_strings[i], NULL);
volatile float f = strtof(inf_strings[i], NULL);
ATF_REQUIRE(isinf(f) != 0);
}
#else
@ -159,7 +159,7 @@ ATF_TC_BODY(strtold_inf, tc)
atf_tc_expect_fail("PR misc/44767");
for (size_t i = 0; i < __arraycount(inf_strings); i++) {
long double ld = strtold(inf_strings[i], NULL);
volatile long double ld = strtold(inf_strings[i], NULL);
ATF_REQUIRE(isinf(ld) != 0);
}
# else
@ -181,7 +181,7 @@ ATF_TC_BODY(strtod_nan, tc)
#ifndef __vax__
char *end;
double d = strtod(nan_string, &end);
volatile double d = strtod(nan_string, &end);
ATF_REQUIRE(isnan(d) != 0);
ATF_REQUIRE(strcmp(end, "y") == 0);
#else
@ -200,7 +200,7 @@ ATF_TC_BODY(strtof_nan, tc)
#ifndef __vax__
char *end;
float f = strtof(nan_string, &end);
volatile float f = strtof(nan_string, &end);
ATF_REQUIRE(isnanf(f) != 0);
ATF_REQUIRE(strcmp(end, "y") == 0);
#else
@ -224,7 +224,7 @@ ATF_TC_BODY(strtold_nan, tc)
if (system("cpuctl identify 0 | grep -q QEMU") == 0)
atf_tc_expect_fail("PR misc/44767");
long double ld = strtold(nan_string, &end);
volatile long double ld = strtold(nan_string, &end);
ATF_REQUIRE(isnan(ld) != 0);
ATF_REQUIRE(__isnanl(ld) != 0);
ATF_REQUIRE(strcmp(end, "y") == 0);
@ -255,11 +255,11 @@ ATF_TC_BODY(strtod_round, tc)
(void)fesetround(FE_UPWARD);
double d1 = strtod(val, NULL);
volatile double d1 = strtod(val, NULL);
(void)fesetround(FE_DOWNWARD);
double d2 = strtod(val, NULL);
volatile double d2 = strtod(val, NULL);
if (fabs(d1 - d2) > 0.0)
return;
@ -292,7 +292,7 @@ ATF_TC_BODY(strtod_underflow, tc)
"000000000000000002";
errno = 0;
double d = strtod(tmp, NULL);
volatile double d = strtod(tmp, NULL);
if (d != 0 || errno != ERANGE)
atf_tc_fail("strtod(3) did not detect underflow");