XXX: ugly hack to make these valid for vax fp.

XXX: could consolidate some of this into a common header, but i'll
     leave that clean up for another time.
This commit is contained in:
mrg 2011-07-04 22:33:29 +00:00
parent 9980449ca3
commit 8aa4955581
4 changed files with 41 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_strtod.c,v 1.21 2011/06/14 02:37:31 jruoho Exp $ */
/* $NetBSD: t_strtod.c,v 1.22 2011/07/04 22:33:29 mrg 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.21 2011/06/14 02:37:31 jruoho Exp $");
__RCSID("$NetBSD: t_strtod.c,v 1.22 2011/07/04 22:33:29 mrg Exp $");
#include <errno.h>
#include <math.h>
@ -82,6 +82,12 @@ ATF_TC_HEAD(strtod_hex, tc)
atf_tc_set_md_var(tc, "descr", "A strtod(3) with hexadecimals");
}
#ifdef __vax__
#define SMALL_NUM 1.0e-38
#else
#define SMALL_NUM 1.0e-40
#endif
ATF_TC_BODY(strtod_hex, tc)
{
const char *str;
@ -93,14 +99,14 @@ ATF_TC_BODY(strtod_hex, tc)
ATF_REQUIRE(end == str + 4);
ATF_REQUIRE(signbit(d) != 0);
ATF_REQUIRE(fabs(d) < 1.0e-40);
ATF_REQUIRE(fabs(d) < SMALL_NUM);
str = "-0x";
d = strtod(str, &end); /* -0.0 */
ATF_REQUIRE(end == str + 2);
ATF_REQUIRE(signbit(d) != 0);
ATF_REQUIRE(fabs(d) < 1.0e-40);
ATF_REQUIRE(fabs(d) < SMALL_NUM);
}
ATF_TC(strtod_inf);

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_ceil.c,v 1.3 2011/03/25 10:42:38 jruoho Exp $ */
/* $NetBSD: t_ceil.c,v 1.4 2011/07/04 22:33:29 mrg Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_ceil.c,v 1.3 2011/03/25 10:42:38 jruoho Exp $");
__RCSID("$NetBSD: t_ceil.c,v 1.4 2011/07/04 22:33:29 mrg Exp $");
#include <math.h>
#include <limits.h>
@ -42,6 +42,12 @@ ATF_TC_HEAD(ceil, tc)
atf_tc_set_md_var(tc, "descr", "A basic test of ceil(3)");
}
#ifdef __vax__
#define SMALL_NUM 1.0e-38
#else
#define SMALL_NUM 1.0e-40
#endif
ATF_TC_BODY(ceil, tc)
{
const int n = 10240;
@ -53,8 +59,8 @@ ATF_TC_BODY(ceil, tc)
x = i + 0.999999999;
y = i + 0.000000001;
ATF_REQUIRE(fabs(ceil(x) - (double)(i + 1)) < 1.0e-40);
ATF_REQUIRE(fabs(ceil(x) - (double)(i + 1)) < 1.0e-40);
ATF_REQUIRE(fabs(ceil(x) - (double)(i + 1)) < SMALL_NUM);
ATF_REQUIRE(fabs(ceil(x) - (double)(i + 1)) < SMALL_NUM);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_floor.c,v 1.4 2011/03/25 10:42:38 jruoho Exp $ */
/* $NetBSD: t_floor.c,v 1.5 2011/07/04 22:33:29 mrg Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_floor.c,v 1.4 2011/03/25 10:42:38 jruoho Exp $");
__RCSID("$NetBSD: t_floor.c,v 1.5 2011/07/04 22:33:29 mrg Exp $");
#include <math.h>
#include <limits.h>
@ -43,6 +43,12 @@ ATF_TC_HEAD(floor, tc)
atf_tc_set_md_var(tc, "descr", "A basic test of floor(3)");
}
#ifdef __vax__
#define SMALL_NUM 1.0e-38
#else
#define SMALL_NUM 1.0e-40
#endif
ATF_TC_BODY(floor, tc)
{
const int n = 10240;
@ -60,8 +66,8 @@ ATF_TC_BODY(floor, tc)
x = i + 0.999999999;
y = i + 0.000000001;
ATF_REQUIRE(fabs(floor(x) - (double)i) < 1.0e-40);
ATF_REQUIRE(fabs(floor(y) - (double)i) < 1.0e-40);
ATF_REQUIRE(fabs(floor(x) - (double)i) < SMALL_NUM);
ATF_REQUIRE(fabs(floor(y) - (double)i) < SMALL_NUM);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_round.c,v 1.1 2011/04/08 06:49:21 jruoho Exp $ */
/* $NetBSD: t_round.c,v 1.2 2011/07/04 22:33:29 mrg Exp $ */
#include <atf-c.h>
#include <math.h>
@ -13,6 +13,12 @@
#define VAL 0x0.7ffffffffffffcp0
#define VALF 0x0.7fffff8p0
#ifdef __vax__
#define SMALL_NUM 1.0e-38
#else
#define SMALL_NUM 1.0e-40
#endif
ATF_TC(round_dir);
ATF_TC_HEAD(round_dir, tc)
{
@ -27,14 +33,14 @@ ATF_TC_BODY(round_dir, tc)
b = round(a);
bf = roundf(af);
ATF_REQUIRE(fabs(b) < 1.0e-40);
ATF_REQUIRE(fabsf(bf) < 1.0e-40);
ATF_REQUIRE(fabs(b) < SMALL_NUM);
ATF_REQUIRE(fabsf(bf) < SMALL_NUM);
c = round(-a);
cf = roundf(-af);
ATF_REQUIRE(fabs(c) < 1.0e-40);
ATF_REQUIRE(fabsf(cf) < 1.0e-40);
ATF_REQUIRE(fabs(c) < SMALL_NUM);
ATF_REQUIRE(fabsf(cf) < SMALL_NUM);
}
ATF_TP_ADD_TCS(tp)