From 8e54f10bf7ab7efff6333e42da442fce5955ab13 Mon Sep 17 00:00:00 2001 From: kleink Date: Thu, 4 Mar 2004 23:42:38 +0000 Subject: [PATCH] * Turn isinf(3) and isnan(3) into C99-style macros. * Make it possible for ports to override these (i.e., VAX). * Remove isnanl(), which was internal to libc only. --- include/math.h | 36 ++++++-- lib/libc/arch/alpha/gen/Makefile.inc | 8 +- lib/libc/arch/arm/gen/Makefile.inc | 7 +- lib/libc/arch/hppa/gen/Makefile.inc | 6 +- lib/libc/arch/i386/gen/Makefile.inc | 6 +- lib/libc/arch/i386/gen/isinfl.c | 21 ++--- lib/libc/arch/i386/gen/isnanl.c | 21 ++--- lib/libc/arch/m68k/gen/Makefile.inc | 7 +- lib/libc/arch/m68k/gen/isinfl.c | 21 ++--- lib/libc/arch/m68k/gen/isnanl.c | 21 ++--- lib/libc/arch/mips/gen/Makefile.inc | 7 +- lib/libc/arch/ns32k/gen/Makefile.inc | 8 +- lib/libc/arch/powerpc/gen/Makefile.inc | 8 +- lib/libc/arch/sh3/gen/Makefile.inc | 8 +- lib/libc/arch/sh5/gen/Makefile.inc | 6 +- lib/libc/arch/sparc/gen/Makefile.inc | 8 +- lib/libc/arch/sparc64/gen/Makefile.inc | 5 +- lib/libc/arch/sparc64/gen/isinfl.c | 25 +++--- lib/libc/arch/sparc64/gen/isnanl.c | 25 +++--- lib/libc/arch/vax/gen/Makefile.inc | 7 +- lib/libc/arch/vax/gen/isinf.c | 10 +-- lib/libc/arch/vax/gen/isinfl.c | 55 ------------ lib/libc/arch/vax/gen/isnan.c | 9 +- lib/libc/arch/vax/gen/isnanl.c | 55 ------------ lib/libc/arch/x86_64/gen/Makefile.inc | 5 +- lib/libc/arch/x86_64/gen/isinfl.c | 21 ++--- lib/libc/arch/x86_64/gen/isnanl.c | 21 ++--- lib/libc/gen/Makefile.inc | 7 +- lib/libc/gen/isinf.3 | 59 +++++++------ .../gen/{isinf_ieee754.c => isinfd_ieee754.c} | 18 ++-- ...{isnanl_dbl_ieee754.c => isinff_ieee754.c} | 34 +++----- lib/libc/gen/isnan.3 | 86 +++++++++++++++++++ .../gen/{isnan_ieee754.c => isnand_ieee754.c} | 18 ++-- ...{isinfl_dbl_ieee754.c => isnanf_ieee754.c} | 34 +++----- lib/libc/include/namespace.h | 6 +- sys/arch/vax/include/math.h | 5 +- 36 files changed, 339 insertions(+), 365 deletions(-) delete mode 100644 lib/libc/arch/vax/gen/isinfl.c delete mode 100644 lib/libc/arch/vax/gen/isnanl.c rename lib/libc/gen/{isinf_ieee754.c => isinfd_ieee754.c} (86%) rename lib/libc/gen/{isnanl_dbl_ieee754.c => isinff_ieee754.c} (75%) create mode 100644 lib/libc/gen/isnan.3 rename lib/libc/gen/{isnan_ieee754.c => isnand_ieee754.c} (86%) rename lib/libc/gen/{isinfl_dbl_ieee754.c => isnanf_ieee754.c} (75%) diff --git a/include/math.h b/include/math.h index 74e2fb1c6260..7fdd6541bdc8 100644 --- a/include/math.h +++ b/include/math.h @@ -1,4 +1,4 @@ -/* $NetBSD: math.h,v 1.33 2004/03/04 00:17:44 kleink Exp $ */ +/* $NetBSD: math.h,v 1.34 2004/03/04 23:42:38 kleink Exp $ */ /* * ==================================================== @@ -209,10 +209,6 @@ double erf __P((double)); double erfc __P((double)); double gamma __P((double)); double hypot __P((double, double)); -int isnan __P((double)); -#if defined(_LIBC) -int isnanl __P((long double)); -#endif int finite __P((double)); double j0 __P((double)); double j1 __P((double)); @@ -261,6 +257,26 @@ double scalb __P((double, double)); #endif /* !_ANSI_SOURCE && ... */ +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) || \ + !defined(_XOPEN_SOURCE) || \ + ((__STDC_VERSION__ - 0) >= 199901L) || \ + ((_POSIX_C_SOURCE - 0) >= 200112L) || \ + defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +/* 7.12.3.3 int isinf(real-floating x) */ +#ifdef __isinf +#define isinf(__x) __isinf(__x) +#else +#define isinf(__x) __fpmacro_unary_floating(isinf, __x) +#endif + +/* 7.12.3.4 int isnan(real-floating x) */ +#ifdef __isnan +#define isnan(__x) __isnan(__x) +#else +#define isnan(__x) __fpmacro_unary_floating(isnan, __x) +#endif +#endif /* !_ANSI_SOURCE && ... */ + #if defined(_NETBSD_SOURCE) #ifndef __cplusplus int matherr __P((struct exception *)); @@ -298,10 +314,6 @@ double lgamma_r __P((double, int *)); #if defined(_NETBSD_SOURCE) -int isinf __P((double)); -#if defined(_LIBC) -int isinfl __P((long double)); -#endif /* float versions of ANSI/POSIX functions */ float acosf __P((float)); @@ -397,12 +409,18 @@ int __fpclassifyf __P((float)); int __fpclassifyd __P((double)); int __isfinitef __P((float)); int __isfinited __P((double)); +int __isinff __P((float)); +int __isinfd __P((double)); +int __isnanf __P((float)); +int __isnand __P((double)); int __signbitf __P((float)); int __signbitd __P((double)); #ifdef __HAVE_LONG_DOUBLE int __fpclassifyl __P((long double)); int __isfinitel __P((long double)); +int __isinfl __P((long double)); +int __isnanl __P((long double)); int __signbitl __P((long double)); #endif __END_DECLS diff --git a/lib/libc/arch/alpha/gen/Makefile.inc b/lib/libc/arch/alpha/gen/Makefile.inc index a6d21738eed6..0019722939dc 100644 --- a/lib/libc/arch/alpha/gen/Makefile.inc +++ b/lib/libc/arch/alpha/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.17 2004/03/01 19:26:29 drochner Exp $ +# $NetBSD: Makefile.inc,v 1.18 2004/03/04 23:42:38 kleink Exp $ SRCS+= fabs.S @@ -6,9 +6,11 @@ SRCS+= fabs.S SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c SRCS+= nanf_ieee754.c SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= frexp_ieee754.c isinf_ieee754.c isinfl_dbl_ieee754.c isnan_ieee754.c +SRCS+= frexp_ieee754.c +SRCS+= isinff_ieee754.c isinfd_ieee754.c +SRCS+= isnanf_ieee754.c isnand_ieee754.c SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= isnanl_dbl_ieee754.c ldexp_ieee754.c modf_ieee754.c +SRCS+= ldexp_ieee754.c modf_ieee754.c SRCS+= signbitf_ieee754.c signbitd_ieee754.c SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ diff --git a/lib/libc/arch/arm/gen/Makefile.inc b/lib/libc/arch/arm/gen/Makefile.inc index 572dfd89c179..34b1c01b1b15 100644 --- a/lib/libc/arch/arm/gen/Makefile.inc +++ b/lib/libc/arch/arm/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.11 2004/01/15 19:43:45 kleink Exp $ +# $NetBSD: Makefile.inc,v 1.12 2004/03/04 23:42:38 kleink Exp $ SRCS+= alloca.S byte_swap_2.S byte_swap_4.S bswap64.c divsi3.S \ fabs.c flt_rounds.c @@ -8,8 +8,9 @@ SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c SRCS+= nanf_ieee754.c SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= isinfl_dbl_ieee754.c isnanl_dbl_ieee754.c -SRCS+= frexp_ieee754.c isinf_ieee754.c isnan_ieee754.c +SRCS+= isinff_ieee754.c isinfd_ieee754.c +SRCS+= isnanf_ieee754.c isnand_ieee754.c +SRCS+= frexp_ieee754.c SRCS+= ldexp_ieee754.c modf_ieee754.c SRCS+= signbitf_ieee754.c signbitd_ieee754.c diff --git a/lib/libc/arch/hppa/gen/Makefile.inc b/lib/libc/arch/hppa/gen/Makefile.inc index fdb575bc31e4..4d4aed097534 100644 --- a/lib/libc/arch/hppa/gen/Makefile.inc +++ b/lib/libc/arch/hppa/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.9 2004/01/15 19:43:45 kleink Exp $ +# $NetBSD: Makefile.inc,v 1.10 2004/03/04 23:42:38 kleink Exp $ SRCS+= bswap16.c bswap32.c bswap64.c __sigsetjmp14.S __setjmp14.S _setjmp.S @@ -8,8 +8,8 @@ SRCS+= nanf_ieee754.c SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c SRCS+= frexp_ieee754.c ldexp_ieee754.c SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= isinf_ieee754.c isinfl_dbl_ieee754.c -SRCS+= isnan_ieee754.c isnanl_dbl_ieee754.c +SRCS+= isinff_ieee754.c isinfd_ieee754.c +SRCS+= isnanf_ieee754.c isnand_ieee754.c SRCS+= modf_ieee754.c SRCS+= signbitf_ieee754.c signbitd_ieee754.c diff --git a/lib/libc/arch/i386/gen/Makefile.inc b/lib/libc/arch/i386/gen/Makefile.inc index 81851b5817b1..6dd4d2ecf0ea 100644 --- a/lib/libc/arch/i386/gen/Makefile.inc +++ b/lib/libc/arch/i386/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.19 2004/01/15 19:43:45 kleink Exp $ +# $NetBSD: Makefile.inc,v 1.20 2004/03/04 23:42:38 kleink Exp $ # objects built from assembler sources (need lint stubs) SRCS+= alloca.S byte_swap_2.S byte_swap_4.S fabs.S modf.S \ @@ -18,7 +18,9 @@ SRCS+= bswap64.c ldexp.c _lwp.c makecontext.c SRCS+= infinityf_ieee754.c infinity_ieee754.c SRCS+= nanf_ieee754.c SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= frexp_ieee754.c isinf_ieee754.c isnan_ieee754.c +SRCS+= frexp_ieee754.c +SRCS+= isinff_ieee754.c isinfd_ieee754.c +SRCS+= isnanf_ieee754.c isnand_ieee754.c SRCS+= isfinitef_ieee754.c isfinited_ieee754.c SRCS+= signbitf_ieee754.c signbitd_ieee754.c diff --git a/lib/libc/arch/i386/gen/isinfl.c b/lib/libc/arch/i386/gen/isinfl.c index 6cb2e839a299..fdd5bc130c02 100644 --- a/lib/libc/arch/i386/gen/isinfl.c +++ b/lib/libc/arch/i386/gen/isinfl.c @@ -1,4 +1,4 @@ -/* $NetBSD: isinfl.c,v 1.4 2003/10/27 01:11:46 kleink Exp $ */ +/* $NetBSD: isinfl.c,v 1.5 2004/03/04 23:42:38 kleink Exp $ */ /* * Copyright (c) 1992, 1993 @@ -40,27 +40,24 @@ #if 0 static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: isinfl.c,v 1.4 2003/10/27 01:11:46 kleink Exp $"); +__RCSID("$NetBSD: isinfl.c,v 1.5 2004/03/04 23:42:38 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" -#include #include #include -#if 0 /* XXX Currently limited to internal use. */ -#ifdef __weak_alias -__weak_alias(isinfl,_isinfl) -#endif -#endif - +/* + * 7.12.3.3 isinf - test for infinity + * IEEE 754 compatible 80-bit extended-precision Intel 386 version + */ int -isinfl(long double ld) +__isinfl(long double x) { union ieee_ext_u u; - u.extu_ld = ld; + u.extu_ld = x; + return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && (u.extu_ext.ext_int == 1 && u.extu_ext.ext_frach == 0 && u.extu_ext.ext_fracl == 0)); diff --git a/lib/libc/arch/i386/gen/isnanl.c b/lib/libc/arch/i386/gen/isnanl.c index 35eede44783e..9c8531e74100 100644 --- a/lib/libc/arch/i386/gen/isnanl.c +++ b/lib/libc/arch/i386/gen/isnanl.c @@ -1,4 +1,4 @@ -/* $NetBSD: isnanl.c,v 1.4 2003/10/27 01:11:46 kleink Exp $ */ +/* $NetBSD: isnanl.c,v 1.5 2004/03/04 23:42:38 kleink Exp $ */ /* * Copyright (c) 1992, 1993 @@ -40,27 +40,24 @@ #if 0 static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: isnanl.c,v 1.4 2003/10/27 01:11:46 kleink Exp $"); +__RCSID("$NetBSD: isnanl.c,v 1.5 2004/03/04 23:42:38 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" -#include #include #include -#if 0 /* XXX Currently limited to internal use. */ -#ifdef __weak_alias -__weak_alias(isnanl,_isnanl) -#endif -#endif - +/* + * 7.12.3.4 isnan - test for a NaN + * IEEE 754 compatible 80-bit extended-precision Intel 386 version + */ int -isnanl(long double ld) +__isnanl(long double x) { union ieee_ext_u u; - u.extu_ld = ld; + u.extu_ld = x; + return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && u.extu_ext.ext_int == 1 && (u.extu_ext.ext_frach != 0 || u.extu_ext.ext_fracl != 0)); diff --git a/lib/libc/arch/m68k/gen/Makefile.inc b/lib/libc/arch/m68k/gen/Makefile.inc index f495416ae97b..5a2a8c6ed6e2 100644 --- a/lib/libc/arch/m68k/gen/Makefile.inc +++ b/lib/libc/arch/m68k/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.23 2004/01/15 19:43:45 kleink Exp $ +# $NetBSD: Makefile.inc,v 1.24 2004/03/04 23:42:38 kleink Exp $ SRCS+= alloca.S fabs.S @@ -6,7 +6,9 @@ SRCS+= alloca.S fabs.S SRCS+= infinityf_ieee754.c infinity_ieee754.c SRCS+= nanf_ieee754.c SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= frexp_ieee754.c isinf_ieee754.c isnan_ieee754.c +SRCS+= frexp_ieee754.c +SRCS+= isinff_ieee754.c isinfd_ieee754.c +SRCS+= isnanf_ieee754.c isnand_ieee754.c SRCS+= isfinitef_ieee754.c isfinited_ieee754.c SRCS+= signbitf_ieee754.c signbitd_ieee754.c @@ -14,7 +16,6 @@ SRCS+= signbitf_ieee754.c signbitd_ieee754.c # for which the generic ieee754 versions can be used .if ${MACHINE_ARCH} == "m68000" SRCS+= infinityl_dbl_ieee754.c -SRCS+= isinfl_dbl_ieee754.c isnanl_dbl_ieee754.c .else SRCS+= infinityl.c SRCS+= fpclassifyl.c isfinitel.c isinfl.c isnanl.c signbitl.c diff --git a/lib/libc/arch/m68k/gen/isinfl.c b/lib/libc/arch/m68k/gen/isinfl.c index f599a285bfaf..8b26c2176a40 100644 --- a/lib/libc/arch/m68k/gen/isinfl.c +++ b/lib/libc/arch/m68k/gen/isinfl.c @@ -1,4 +1,4 @@ -/* $NetBSD: isinfl.c,v 1.3 2003/10/27 01:11:46 kleink Exp $ */ +/* $NetBSD: isinfl.c,v 1.4 2004/03/04 23:42:38 kleink Exp $ */ /* * Copyright (c) 1992, 1993 @@ -40,27 +40,24 @@ #if 0 static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: isinfl.c,v 1.3 2003/10/27 01:11:46 kleink Exp $"); +__RCSID("$NetBSD: isinfl.c,v 1.4 2004/03/04 23:42:38 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" -#include #include #include -#if 0 /* XXX Currently limited to internal use. */ -#ifdef __weak_alias -__weak_alias(isinfl,_isinfl) -#endif -#endif - +/* + * 7.12.3.3 isinf - test for infinity + * IEEE 754 compatible 80-bit extended-precision Motorola 68k version + */ int -isinfl(long double ld) +__isinfl(long double x) { union ieee_ext_u u; - u.extu_ld = ld; + u.extu_ld = x; + /* Note: the explicit integer bit is "don't care". */ return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && (u.extu_ext.ext_frach == 0 && u.extu_ext.ext_fracl == 0)); diff --git a/lib/libc/arch/m68k/gen/isnanl.c b/lib/libc/arch/m68k/gen/isnanl.c index f26467a15dbc..d046f7d33c4c 100644 --- a/lib/libc/arch/m68k/gen/isnanl.c +++ b/lib/libc/arch/m68k/gen/isnanl.c @@ -1,4 +1,4 @@ -/* $NetBSD: isnanl.c,v 1.4 2003/10/28 00:13:22 kleink Exp $ */ +/* $NetBSD: isnanl.c,v 1.5 2004/03/04 23:42:38 kleink Exp $ */ /* * Copyright (c) 1992, 1993 @@ -40,27 +40,24 @@ #if 0 static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: isnanl.c,v 1.4 2003/10/28 00:13:22 kleink Exp $"); +__RCSID("$NetBSD: isnanl.c,v 1.5 2004/03/04 23:42:38 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" -#include #include #include -#if 0 /* XXX Currently limited to internal use. */ -#ifdef __weak_alias -__weak_alias(isnanl,_isnanl) -#endif -#endif - +/* + * 7.12.3.4 isnan - test for a NaN + * IEEE 754 compatible 80-bit extended-precision Motorola 68k version + */ int -isnanl(long double ld) +__isnanl(long double x) { union ieee_ext_u u; - u.extu_ld = ld; + u.extu_ld = x; + /* Note: the explicit integer bit is "don't care". */ return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && (u.extu_ext.ext_frach != 0 || u.extu_ext.ext_fracl != 0)); diff --git a/lib/libc/arch/mips/gen/Makefile.inc b/lib/libc/arch/mips/gen/Makefile.inc index b7ac9d624be8..f0c7793f236c 100644 --- a/lib/libc/arch/mips/gen/Makefile.inc +++ b/lib/libc/arch/mips/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.22 2004/01/15 19:43:45 kleink Exp $ +# $NetBSD: Makefile.inc,v 1.23 2004/03/04 23:42:38 kleink Exp $ SRCS+= fabs.S ldexp.S modf.S @@ -6,9 +6,10 @@ SRCS+= fabs.S ldexp.S modf.S SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c SRCS+= nanf_ieee754.c SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= frexp_ieee754.c isinf_ieee754.c isinfl_dbl_ieee754.c isnan_ieee754.c +SRCS+= frexp_ieee754.c +SRCS+= isinff_ieee754.c isinfd_ieee754.c +SRCS+= isnanf_ieee754.c isnand_ieee754.c SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= isnanl_dbl_ieee754.c SRCS+= signbitf_ieee754.c signbitd_ieee754.c SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ diff --git a/lib/libc/arch/ns32k/gen/Makefile.inc b/lib/libc/arch/ns32k/gen/Makefile.inc index 4e86f8aa9d8d..19b831029b0c 100644 --- a/lib/libc/arch/ns32k/gen/Makefile.inc +++ b/lib/libc/arch/ns32k/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.21 2004/01/15 19:43:45 kleink Exp $ +# $NetBSD: Makefile.inc,v 1.22 2004/03/04 23:42:38 kleink Exp $ # objects built from assembler sources (need lint stubs) ASSRCS+=alloca.S fabs.S modf.S @@ -21,9 +21,11 @@ SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c SRCS+= nanf_ieee754.c SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= frexp_ieee754.c isinf_ieee754.c isinfl_dbl_ieee754.c isnan_ieee754.c +SRCS+= frexp_ieee754.c +SRCS+= isinff_ieee754.c isinfd_ieee754.c +SRCS+= isnanf_ieee754.c isnand_ieee754.c SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= isnanl_dbl_ieee754.c ldexp_ieee754.c +SRCS+= ldexp_ieee754.c SRCS+= signbitf_ieee754.c signbitd_ieee754.c SRCS+= makecontext.c diff --git a/lib/libc/arch/powerpc/gen/Makefile.inc b/lib/libc/arch/powerpc/gen/Makefile.inc index 324a04fb0b1b..68b13b6f83ef 100644 --- a/lib/libc/arch/powerpc/gen/Makefile.inc +++ b/lib/libc/arch/powerpc/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.18 2004/01/15 19:43:45 kleink Exp $ +# $NetBSD: Makefile.inc,v 1.19 2004/03/04 23:42:38 kleink Exp $ SRCS+= _setjmp.S setjmp.S sigsetjmp.S __setjmp14.S __sigsetjmp14.S SRCS+= bswap16.c bswap32.c bswap64.c @@ -10,9 +10,11 @@ SRCS+= _lwp.c makecontext.c resumecontext.c swapcontext.S SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c SRCS+= nanf_ieee754.c SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= frexp_ieee754.c isinf_ieee754.c isinfl_dbl_ieee754.c isnan_ieee754.c +SRCS+= frexp_ieee754.c +SRCS+= isinff_ieee754.c isinfd_ieee754.c +SRCS+= isnanf_ieee754.c isnand_ieee754.c SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= isnanl_dbl_ieee754.c ldexp_ieee754.c modf_ieee754.c +SRCS+= ldexp_ieee754.c modf_ieee754.c SRCS+= signbitf_ieee754.c signbitd_ieee754.c .if (${MKSOFTFLOAT} == "no") diff --git a/lib/libc/arch/sh3/gen/Makefile.inc b/lib/libc/arch/sh3/gen/Makefile.inc index 689352c765bd..d7f1b9b69798 100644 --- a/lib/libc/arch/sh3/gen/Makefile.inc +++ b/lib/libc/arch/sh3/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.15 2004/02/22 01:05:49 uwe Exp $ +# $NetBSD: Makefile.inc,v 1.16 2004/03/04 23:42:38 kleink Exp $ SRCS+= _setjmp.S setjmp.S sigsetjmp.S __setjmp14.S __sigsetjmp14.S @@ -12,9 +12,11 @@ SRCS+= fabs.c flt_rounds.c bswap16.c bswap32.c bswap64.c SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c SRCS+= nanf_ieee754.c SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= frexp_ieee754.c isinf_ieee754.c isinfl_dbl_ieee754.c isnan_ieee754.c +SRCS+= frexp_ieee754.c +SRCS+= isinff_ieee754.c isinfd_ieee754.c +SRCS+= isnanf_ieee754.c isnand_ieee754.c SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= isnanl_dbl_ieee754.c ldexp_ieee754.c modf_ieee754.c +SRCS+= ldexp_ieee754.c modf_ieee754.c SRCS+= signbitf_ieee754.c signbitd_ieee754.c # In gcc3 dynamic world these functions must be ".hidden" in libgcc*.a, diff --git a/lib/libc/arch/sh5/gen/Makefile.inc b/lib/libc/arch/sh5/gen/Makefile.inc index 55b8a1282efb..afa4fc974a4c 100644 --- a/lib/libc/arch/sh5/gen/Makefile.inc +++ b/lib/libc/arch/sh5/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.13 2004/01/15 19:43:45 kleink Exp $ +# $NetBSD: Makefile.inc,v 1.14 2004/03/04 23:42:38 kleink Exp $ SRCS+= __setjmp14.S __sigsetjmp14.S _setjmp.S \ alloca.S \ @@ -9,8 +9,8 @@ SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c \ frexp_ieee754.c \ infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c \ isfinitef_ieee754.c isfinited_ieee754.c \ - isinf_ieee754.c isinfl_dbl_ieee754.c \ - isnan_ieee754.c isnanl_dbl_ieee754.c \ + isinff_ieee754.c isinfd_ieee754.c \ + isnanf_ieee754.c isnand_ieee754.c \ signbitf_ieee754.c signbitd_ieee754.c \ ldexp_ieee754.c \ modf_ieee754.c \ diff --git a/lib/libc/arch/sparc/gen/Makefile.inc b/lib/libc/arch/sparc/gen/Makefile.inc index 15e27775c248..f27c0b65e346 100644 --- a/lib/libc/arch/sparc/gen/Makefile.inc +++ b/lib/libc/arch/sparc/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.16 2004/02/12 10:28:28 kleink Exp $ +# $NetBSD: Makefile.inc,v 1.17 2004/03/04 23:42:38 kleink Exp $ SRCS+= fabs.S modf.S SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ @@ -8,9 +8,11 @@ SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c SRCS+= nanf_ieee754.c -SRCS+= frexp_ieee754.c isinf_ieee754.c isinfl_dbl_ieee754.c isnan_ieee754.c +SRCS+= frexp_ieee754.c +SRCS+= isinff_ieee754.c isinfd_ieee754.c +SRCS+= isnanf_ieee754.c isnand_ieee754.c SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= isnanl_dbl_ieee754.c ldexp_ieee754.c +SRCS+= ldexp_ieee754.c SRCS+= signbitf_ieee754.c signbitd_ieee754.c diff --git a/lib/libc/arch/sparc64/gen/Makefile.inc b/lib/libc/arch/sparc64/gen/Makefile.inc index 184356070d8c..b4479a99a191 100644 --- a/lib/libc/arch/sparc64/gen/Makefile.inc +++ b/lib/libc/arch/sparc64/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.13 2004/01/17 22:01:15 martin Exp $ +# $NetBSD: Makefile.inc,v 1.14 2004/03/04 23:42:39 kleink Exp $ SRCS+= fabs.S modf.S SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ @@ -10,7 +10,8 @@ SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c SRCS+= nanf_ieee754.c SRCS+= frexp_ieee754.c SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= isinf_ieee754.c isnan_ieee754.c +SRCS+= isinff_ieee754.c isinfd_ieee754.c +SRCS+= isnanf_ieee754.c isnand_ieee754.c SRCS+= ldexp_ieee754.c SRCS+= signbitf_ieee754.c signbitd_ieee754.c diff --git a/lib/libc/arch/sparc64/gen/isinfl.c b/lib/libc/arch/sparc64/gen/isinfl.c index 000c53537ac5..8d7acc6ddc5a 100644 --- a/lib/libc/arch/sparc64/gen/isinfl.c +++ b/lib/libc/arch/sparc64/gen/isinfl.c @@ -1,4 +1,4 @@ -/* $NetBSD: isinfl.c,v 1.3 2003/10/27 01:11:46 kleink Exp $ */ +/* $NetBSD: isinfl.c,v 1.4 2004/03/04 23:42:39 kleink Exp $ */ /* * Copyright (c) 1992, 1993 @@ -40,28 +40,25 @@ #if 0 static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: isinfl.c,v 1.3 2003/10/27 01:11:46 kleink Exp $"); +__RCSID("$NetBSD: isinfl.c,v 1.4 2004/03/04 23:42:39 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" -#include #include #include -#if 0 /* XXX Currently limited to internal use. */ -#ifdef __weak_alias -__weak_alias(isinfl,_isinfl) -#endif -#endif - +/* + * 7.12.3.3 isinf - test for infinity + * IEEE 754 compatible 128-bit extended-precision version + */ int -isinfl(long double ld) +__isinfl(long double x) { union ieee_ext_u u; - u.extu_ld = ld; + u.extu_ld = x; + return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && - (u.extu_ext.ext_frach == 0 && u.extu_ext.ext_frachm == 0 && - u.extu_ext.ext_fraclm == 0 && u.extu_ext.ext_fracl == 0)); + (u.extu_ext.ext_frach == 0 && u.extu_ext.ext_frachm == 0 && + u.extu_ext.ext_fraclm == 0 && u.extu_ext.ext_fracl == 0)); } diff --git a/lib/libc/arch/sparc64/gen/isnanl.c b/lib/libc/arch/sparc64/gen/isnanl.c index f83ead497e3a..2b67f0866db2 100644 --- a/lib/libc/arch/sparc64/gen/isnanl.c +++ b/lib/libc/arch/sparc64/gen/isnanl.c @@ -1,4 +1,4 @@ -/* $NetBSD: isnanl.c,v 1.3 2003/10/27 01:11:46 kleink Exp $ */ +/* $NetBSD: isnanl.c,v 1.4 2004/03/04 23:42:39 kleink Exp $ */ /* * Copyright (c) 1992, 1993 @@ -40,28 +40,25 @@ #if 0 static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: isnanl.c,v 1.3 2003/10/27 01:11:46 kleink Exp $"); +__RCSID("$NetBSD: isnanl.c,v 1.4 2004/03/04 23:42:39 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" -#include #include #include -#if 0 /* XXX Currently limited to internal use. */ -#ifdef __weak_alias -__weak_alias(isnanl,_isnanl) -#endif -#endif - +/* + * 7.12.3.4 isnan - test for a NaN + * IEEE 754 compatible 128-bit extended-precision version + */ int -isnanl(long double ld) +__isnanl(long double x) { union ieee_ext_u u; - u.extu_ld = ld; + u.extu_ld = x; + return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && - (u.extu_ext.ext_frach != 0 || u.extu_ext.ext_frachm != 0 || - u.extu_ext.ext_fraclm != 0 || u.extu_ext.ext_fracl != 0)); + (u.extu_ext.ext_frach != 0 || u.extu_ext.ext_frachm != 0 || + u.extu_ext.ext_fraclm != 0 || u.extu_ext.ext_fracl != 0)); } diff --git a/lib/libc/arch/vax/gen/Makefile.inc b/lib/libc/arch/vax/gen/Makefile.inc index 04b7f6d43a78..e476b8990935 100644 --- a/lib/libc/arch/vax/gen/Makefile.inc +++ b/lib/libc/arch/vax/gen/Makefile.inc @@ -1,9 +1,9 @@ -# $NetBSD: Makefile.inc,v 1.13 2004/01/16 10:46:11 ragge Exp $ +# $NetBSD: Makefile.inc,v 1.14 2004/03/04 23:42:39 kleink Exp $ SRCS+= byte_swap_2.S byte_swap_4.S bswap64.S \ fabs.S frexp.c \ fpclassifyf.c fpclassifyd.c \ - infinityf.c infinity.c infinityl.c isinf.c isinfl.c isnan.c isnanl.c \ + infinityf.c infinity.c infinityl.c \ isfinitef.c isfinited.c \ ldexp.S \ makecontext.c modf.S \ @@ -13,6 +13,9 @@ SRCS+= byte_swap_2.S byte_swap_4.S bswap64.S \ udiv.S urem.S \ __setjmp14.S __sigsetjmp14.S _setjmp.S +# ABI compatibility for libc.so.12 +SRCS+= isinf.c isnan.c + .if ${OBJECT_FMT} != "ELF" SRCS+= setjmp.S sigsetjmp.S .endif diff --git a/lib/libc/arch/vax/gen/isinf.c b/lib/libc/arch/vax/gen/isinf.c index e185b1871df6..8478a4cb0329 100644 --- a/lib/libc/arch/vax/gen/isinf.c +++ b/lib/libc/arch/vax/gen/isinf.c @@ -1,4 +1,4 @@ -/* $NetBSD: isinf.c,v 1.7 2003/08/07 16:42:31 agc Exp $ */ +/* $NetBSD: isinf.c,v 1.8 2004/03/04 23:42:39 kleink Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -34,16 +34,14 @@ #if 0 static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: isinf.c,v 1.7 2003/08/07 16:42:31 agc Exp $"); +__RCSID("$NetBSD: isinf.c,v 1.8 2004/03/04 23:42:39 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" #include -#ifdef __weak_alias -__weak_alias(isinf,_isinf) -#endif +#undef isinf +int isinf __P((double)); /* ARGSUSED */ int diff --git a/lib/libc/arch/vax/gen/isinfl.c b/lib/libc/arch/vax/gen/isinfl.c deleted file mode 100644 index 68b4bc138388..000000000000 --- a/lib/libc/arch/vax/gen/isinfl.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: isinfl.c,v 1.2 2003/08/07 16:42:31 agc Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isinfl.c,v 1.2 2003/08/07 16:42:31 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -#if 0 /* XXX Currently limted to internal use. */ -#ifdef __weak_alias -__weak_alias(isinfl,_isinfl) -#endif -#endif - -/* ARGSUSED */ -int -isinfl(long double d) -{ - return (0); -} diff --git a/lib/libc/arch/vax/gen/isnan.c b/lib/libc/arch/vax/gen/isnan.c index c48e640d21dd..d46615ef3adc 100644 --- a/lib/libc/arch/vax/gen/isnan.c +++ b/lib/libc/arch/vax/gen/isnan.c @@ -1,4 +1,4 @@ -/* $NetBSD: isnan.c,v 1.2 2003/08/07 16:42:31 agc Exp $ */ +/* $NetBSD: isnan.c,v 1.3 2004/03/04 23:42:39 kleink Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -34,16 +34,15 @@ #if 0 static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: isnan.c,v 1.2 2003/08/07 16:42:31 agc Exp $"); +__RCSID("$NetBSD: isnan.c,v 1.3 2004/03/04 23:42:39 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ #include "namespace.h" #include -#ifdef __weak_alias -__weak_alias(isnan,_isnan) -#endif +#undef isnan +int isnan __P((double)); /* ARGSUSED */ int diff --git a/lib/libc/arch/vax/gen/isnanl.c b/lib/libc/arch/vax/gen/isnanl.c deleted file mode 100644 index 899c79ea3fa2..000000000000 --- a/lib/libc/arch/vax/gen/isnanl.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: isnanl.c,v 1.2 2003/08/07 16:42:31 agc Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isnanl.c,v 1.2 2003/08/07 16:42:31 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -#if 0 /* XXX Currently limited to internal use. */ -#ifdef __weak_alias -__weak_alias(isnan,_isnan) -#endif -#endif - -/* ARGSUSED */ -int -isnanl(long double d) -{ - return (0); -} diff --git a/lib/libc/arch/x86_64/gen/Makefile.inc b/lib/libc/arch/x86_64/gen/Makefile.inc index fd7630856d69..3d0c4fdbf2e9 100644 --- a/lib/libc/arch/x86_64/gen/Makefile.inc +++ b/lib/libc/arch/x86_64/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.10 2004/01/15 19:43:45 kleink Exp $ +# $NetBSD: Makefile.inc,v 1.11 2004/03/04 23:42:39 kleink Exp $ # objects built from assembler sources (need lint stubs) SRCS+= alloca.S bswap64.S byte_swap_2.S byte_swap_4.S fabs.S modf.S \ @@ -20,7 +20,8 @@ SRCS+= nanf_ieee754.c SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c SRCS+= frexp_ieee754.c SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= isinf_ieee754.c isnan_ieee754.c +SRCS+= isinff_ieee754.c isinfd_ieee754.c +SRCS+= isnanf_ieee754.c isnand_ieee754.c SRCS+= signbitf_ieee754.c signbitd_ieee754.c SRCS+= infinityl.c diff --git a/lib/libc/arch/x86_64/gen/isinfl.c b/lib/libc/arch/x86_64/gen/isinfl.c index 6cb2e839a299..d97382ccd63e 100644 --- a/lib/libc/arch/x86_64/gen/isinfl.c +++ b/lib/libc/arch/x86_64/gen/isinfl.c @@ -1,4 +1,4 @@ -/* $NetBSD: isinfl.c,v 1.4 2003/10/27 01:11:46 kleink Exp $ */ +/* $NetBSD: isinfl.c,v 1.5 2004/03/04 23:42:39 kleink Exp $ */ /* * Copyright (c) 1992, 1993 @@ -40,27 +40,24 @@ #if 0 static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: isinfl.c,v 1.4 2003/10/27 01:11:46 kleink Exp $"); +__RCSID("$NetBSD: isinfl.c,v 1.5 2004/03/04 23:42:39 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" -#include #include #include -#if 0 /* XXX Currently limited to internal use. */ -#ifdef __weak_alias -__weak_alias(isinfl,_isinfl) -#endif -#endif - +/* + * 7.12.3.3 isinf - test for infinity + * IEEE 754 compatible 80-bit extended-precision Intel 386 version + */ int -isinfl(long double ld) +__isinfl(long double x) { union ieee_ext_u u; - u.extu_ld = ld; + u.extu_ld = x; + return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && (u.extu_ext.ext_int == 1 && u.extu_ext.ext_frach == 0 && u.extu_ext.ext_fracl == 0)); diff --git a/lib/libc/arch/x86_64/gen/isnanl.c b/lib/libc/arch/x86_64/gen/isnanl.c index 919d8e028942..043c24774752 100644 --- a/lib/libc/arch/x86_64/gen/isnanl.c +++ b/lib/libc/arch/x86_64/gen/isnanl.c @@ -1,4 +1,4 @@ -/* $NetBSD: isnanl.c,v 1.4 2003/10/27 01:11:47 kleink Exp $ */ +/* $NetBSD: isnanl.c,v 1.5 2004/03/04 23:42:39 kleink Exp $ */ /* * Copyright (c) 1992, 1993 @@ -40,27 +40,24 @@ #if 0 static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: isnanl.c,v 1.4 2003/10/27 01:11:47 kleink Exp $"); +__RCSID("$NetBSD: isnanl.c,v 1.5 2004/03/04 23:42:39 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" -#include #include #include -#if 0 /* XXX Currently limited to internal use. */ -#ifdef __weak_alias -__weak_alias(isnanl,_isnanl) -#endif -#endif - +/* + * 7.12.3.4 isnan - test for a NaN + * IEEE 754 compatible 80-bit extended-precision Intel 386 version + */ int -isnanl(long double ld) +__isnanl(long double x) { union ieee_ext_u u; - u.extu_ld = ld; + u.extu_ld = x; + return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && u.extu_ext.ext_int == 1 && (u.extu_ext.ext_frach != 0 || u.extu_ext.ext_fracl != 0)); diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index a9621a4068f7..7761b05f78e8 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.126 2004/01/15 19:43:45 kleink Exp $ +# $NetBSD: Makefile.inc,v 1.127 2004/03/04 23:42:39 kleink Exp $ # from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 # gen sources @@ -51,8 +51,8 @@ MAN+= alarm.3 arc4random.3 basename.3 bswap.3 clock.3 confstr.3 \ getprogname.3 getpwent.3 getttyent.3 getusershell.3 glob.3 \ humanize_number.3 \ initgroups.3 isalnum.3 isalpha.3 isascii.3 isblank.3 iscntrl.3 \ - isdigit.3 isfinite.3 isgraph.3 isinf.3 islower.3 isnormal.3 isprint.3 \ - ispunct.3 isspace.3 isupper.3 isxdigit.3 ldexp.3 lockf.3 \ + isdigit.3 isfinite.3 isgraph.3 isinf.3 islower.3 isnan.3 isnormal.3 \ + isprint.3 ispunct.3 isspace.3 isupper.3 isxdigit.3 ldexp.3 lockf.3 \ _lwp_makecontext.3 makecontext.3 \ modf.3 nice.3 nlist.3 \ pause.3 popen.3 psignal.3 pwcache.3 pthread_atfork.3 \ @@ -103,7 +103,6 @@ MLINKS+=getpwent.3 endpwent.3 getpwent.3 setpassent.3 getpwent.3 getpwnam.3 \ MLINKS+=getttyent.3 endttyent.3 getttyent.3 getttynam.3 getttyent.3 setttyent.3 MLINKS+=getusershell.3 endusershell.3 getusershell.3 setusershell.3 MLINKS+=glob.3 globfree.3 -MLINKS+=isinf.3 isnan.3 MLINKS+=makecontext.3 swapcontext.3 MLINKS+=popen.3 pclose.3 MLINKS+=psignal.3 sys_siglist.3 psignal.3 sys_signame.3 diff --git a/lib/libc/gen/isinf.3 b/lib/libc/gen/isinf.3 index a937d50354be..6fae0778557d 100644 --- a/lib/libc/gen/isinf.3 +++ b/lib/libc/gen/isinf.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: isinf.3,v 1.10 2003/08/07 16:42:52 agc Exp $ +.\" $NetBSD: isinf.3,v 1.11 2004/03/04 23:42:39 kleink Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,47 +29,56 @@ .\" .\" @(#)isinf.3 8.2 (Berkeley) 1/29/94 .\" -.Dd January 29, 1994 +.Dd March 5, 2004 .Dt ISINF 3 .Os .Sh NAME -.Nm isinf , -.Nm isnan -.Nd test for infinity or not-a-number +.Nm isinf +.Nd test for infinity .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In math.h .Ft int -.Fn isinf double -.Ft int -.Fn isnan double +.Fn isinf "real-floating x" .Sh DESCRIPTION The .Fn isinf -function -returns 1 if the number is -.Dq \\*(If , -otherwise 0. -.Pp +macro determines whether its argument +.Fa x +is an infinity (positive or negative). +An argument represented in a format wider than its semantic type is +converted to its semantic type first. +The determination is then based on the type of the argument. +.Ss IEEE 754 +It is determined whether the value of +.Fa x +is an infinity. +.Ss VAX +Infinities are not supported. +.Sh RETURN VALUES The -.Fn isnan -function -returns 1 if the number is -.Dq not-a-number , -otherwise 0. +.Fn isinf +macro returns a non-zero value if the value of +.Fa x +is an infinity. +Otherwise 0 is returned. .Sh SEE ALSO +.Xr fpclassify 3 , +.Xr isfinite 3 , +.Xr isnormal 3 , .Xr isinff 3 , +.Xr isnan 3 , .Xr isnanf 3 , -.Xr math 3 +.Xr math 3 , +.Xr signbit 3 .Rs .%T "IEEE Standard for Binary Floating-Point Arithmetic" .%Q ANSI .%R Std 754-1985 .Re -.Sh BUGS -Neither the -.Tn VAX -nor the Tahoe floating point have distinguished values -for either infinity or not-a-number. -These routines always return 0 on those architectures. +.Sh STANDARDS +The +.Fn isinf +macro conforms to +.St -isoC-99 . diff --git a/lib/libc/gen/isinf_ieee754.c b/lib/libc/gen/isinfd_ieee754.c similarity index 86% rename from lib/libc/gen/isinf_ieee754.c rename to lib/libc/gen/isinfd_ieee754.c index f6022a49310a..18899b740574 100644 --- a/lib/libc/gen/isinf_ieee754.c +++ b/lib/libc/gen/isinfd_ieee754.c @@ -1,4 +1,4 @@ -/* $NetBSD: isinf_ieee754.c,v 1.4 2003/10/27 09:27:03 skrll Exp $ */ +/* $NetBSD: isinfd_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $ */ /* * Copyright (c) 1992, 1993 @@ -40,25 +40,29 @@ #if 0 static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: isinf_ieee754.c,v 1.4 2003/10/27 09:27:03 skrll Exp $"); +__RCSID("$NetBSD: isinfd_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" -#include #include #include +/* libc.so.12 ABI compatbility */ #ifdef __weak_alias -__weak_alias(isinf,_isinf) +__weak_alias(isinf,__isinfd) #endif +/* + * 7.12.3.3 isinf - test for infinity + * IEEE 754 double-precision version + */ int -isinf(double d) +__isinfd(double x) { union ieee_double_u u; - u.dblu_d = d; + u.dblu_d = x; + return (u.dblu_dbl.dbl_exp == DBL_EXP_INFNAN && (u.dblu_dbl.dbl_frach == 0 && u.dblu_dbl.dbl_fracl == 0)); } diff --git a/lib/libc/gen/isnanl_dbl_ieee754.c b/lib/libc/gen/isinff_ieee754.c similarity index 75% rename from lib/libc/gen/isnanl_dbl_ieee754.c rename to lib/libc/gen/isinff_ieee754.c index bf267e47a765..62f4e0f4579a 100644 --- a/lib/libc/gen/isnanl_dbl_ieee754.c +++ b/lib/libc/gen/isinff_ieee754.c @@ -1,4 +1,4 @@ -/* $NetBSD: isnanl_dbl_ieee754.c,v 1.2 2003/10/24 10:30:36 kleink Exp $ */ +/* $NetBSD: isinff_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $ */ /* * Copyright (c) 1992, 1993 @@ -40,38 +40,24 @@ #if 0 static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: isnanl_dbl_ieee754.c,v 1.2 2003/10/24 10:30:36 kleink Exp $"); +__RCSID("$NetBSD: isinff_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" -#include #include -#include #include -#if 0 /* XXX Currently limited to internal use. */ -#ifdef __weak_alias -__weak_alias(isnanl,_isnanl) -#endif -#endif - -#if LDBL_MANT_DIG != DBL_MANT_DIG -#error double / long double mismatch -#endif - /* - * isnanl() for platforms where long double == double. + * 7.12.3.3 isinf - test for infinity + * IEEE 754 single-precision version */ int -isnanl(long double ld) +__isinff(float x) { - union { - long double ld; - struct ieee_double dbl; - } u; + union ieee_single_u u; - u.ld = ld; - return (u.dbl.dbl_exp == DBL_EXP_INFNAN && - (u.dbl.dbl_frach != 0 || u.dbl.dbl_fracl != 0)); + u.sngu_f = x; + + return (u.sngu_sng.sng_exp == SNG_EXP_INFNAN && + u.sngu_sng.sng_frac == 0); } diff --git a/lib/libc/gen/isnan.3 b/lib/libc/gen/isnan.3 new file mode 100644 index 000000000000..f5d7cacf8cb4 --- /dev/null +++ b/lib/libc/gen/isnan.3 @@ -0,0 +1,86 @@ +.\" $NetBSD: isnan.3,v 1.1 2004/03/04 23:42:39 kleink Exp $ +.\" +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" From: @(#)isinf.3 8.2 (Berkeley) 1/29/94 +.\" from: NetBSD: isinf.3,v 1.10 2003/08/07 16:42:52 agc Exp +.\" +.Dd March 5, 2004 +.Dt ISNAN 3 +.Os +.Sh NAME +.Nm isnan +.Nd test for not-a-number +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In math.h +.Ft int +.Fn isnan "real-floating x" +.Sh DESCRIPTION +The +.Fn isnan +macro determines whether its argument +.Fa x +is not-a-number +.Pq Dq NaN . +An argument represented in a format wider than its semantic type is +converted to its semantic type first. +The determination is then based on the type of the argument. +.Ss IEEE 754 +It is determined whether the value of +.Fa x +is a NaN. +.Ss VAX +NaNs are not supported. +.Sh RETURN VALUES +The +.Fn isnan +macro returns a non-zero value if the value of +.Fa x +is a NaN. +Otherwise 0 is returned. +.Sh SEE ALSO +.Xr fpclassify 3 , +.Xr isfinite 3 , +.Xr isnormal 3 , +.Xr isinf 3 , +.Xr isinff 3 , +.Xr isnanf 3 , +.Xr math 3 , +.Xr signbit 3 +.Rs +.%T "IEEE Standard for Binary Floating-Point Arithmetic" +.%Q ANSI +.%R Std 754-1985 +.Re +.Sh STANDARDS +The +.Fn isnan +macro conforms to +.St -isoC-99 . diff --git a/lib/libc/gen/isnan_ieee754.c b/lib/libc/gen/isnand_ieee754.c similarity index 86% rename from lib/libc/gen/isnan_ieee754.c rename to lib/libc/gen/isnand_ieee754.c index 1927152924f4..0ce4bd93679f 100644 --- a/lib/libc/gen/isnan_ieee754.c +++ b/lib/libc/gen/isnand_ieee754.c @@ -1,4 +1,4 @@ -/* $NetBSD: isnan_ieee754.c,v 1.3 2003/10/27 00:05:46 kleink Exp $ */ +/* $NetBSD: isnand_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $ */ /* * Copyright (c) 1992, 1993 @@ -40,25 +40,29 @@ #if 0 static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: isnan_ieee754.c,v 1.3 2003/10/27 00:05:46 kleink Exp $"); +__RCSID("$NetBSD: isnand_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" -#include #include #include +/* libc.so.12 ABI compatbility */ #ifdef __weak_alias -__weak_alias(isnan,_isnan) +__weak_alias(isnan,__isnand) #endif +/* + * 7.12.3.4 isnan - test for a NaN + * IEEE 754 double-precision version + */ int -isnan(double d) +__isnand(double x) { union ieee_double_u u; - u.dblu_d = d; + u.dblu_d = x; + return (u.dblu_dbl.dbl_exp == DBL_EXP_INFNAN && (u.dblu_dbl.dbl_frach != 0 || u.dblu_dbl.dbl_fracl != 0)); } diff --git a/lib/libc/gen/isinfl_dbl_ieee754.c b/lib/libc/gen/isnanf_ieee754.c similarity index 75% rename from lib/libc/gen/isinfl_dbl_ieee754.c rename to lib/libc/gen/isnanf_ieee754.c index 5e0a3237f299..ee3b94dec731 100644 --- a/lib/libc/gen/isinfl_dbl_ieee754.c +++ b/lib/libc/gen/isnanf_ieee754.c @@ -1,4 +1,4 @@ -/* $NetBSD: isinfl_dbl_ieee754.c,v 1.2 2003/10/24 10:30:36 kleink Exp $ */ +/* $NetBSD: isnanf_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $ */ /* * Copyright (c) 1992, 1993 @@ -40,38 +40,24 @@ #if 0 static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: isinfl_dbl_ieee754.c,v 1.2 2003/10/24 10:30:36 kleink Exp $"); +__RCSID("$NetBSD: isnanf_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" -#include #include -#include #include -#if 0 /* XXX Currently limited to internal use. */ -#ifdef __weak_alias -__weak_alias(isinfl,_isinfl) -#endif -#endif - -#if LDBL_MANT_DIG != DBL_MANT_DIG -#error double / long double mismatch -#endif - /* - * isinfl() for platforms where long double == double. + * 7.12.3.4 isnan - test for a NaN + * IEEE 754 single-precision version */ int -isinfl(long double ld) +__isnanf(float x) { - union { - long double ld; - struct ieee_double dbl; - } u; + union ieee_single_u u; - u.ld = ld; - return (u.dbl.dbl_exp == DBL_EXP_INFNAN && - (u.dbl.dbl_frach == 0 && u.dbl.dbl_fracl == 0)); + u.sngu_f = x; + + return (u.sngu_sng.sng_exp == SNG_EXP_INFNAN && + u.sngu_sng.sng_frac != 0); } diff --git a/lib/libc/include/namespace.h b/lib/libc/include/namespace.h index bb1a234faa61..1750892a56f1 100644 --- a/lib/libc/include/namespace.h +++ b/lib/libc/include/namespace.h @@ -1,4 +1,4 @@ -/* $NetBSD: namespace.h,v 1.83 2004/02/19 19:22:51 christos Exp $ */ +/* $NetBSD: namespace.h,v 1.84 2004/03/04 23:42:39 kleink Exp $ */ /*- * Copyright (c) 1997-2002 The NetBSD Foundation, Inc. @@ -331,10 +331,6 @@ #define initstate _initstate #define innetgr _innetgr #define isatty _isatty -#define isinf _isinf -#define isinfl _isinfl -#define isnan _isnan -#define isnanl _isnanl #define jrand48 _jrand48 #define kill _kill #define l64a _l64a diff --git a/sys/arch/vax/include/math.h b/sys/arch/vax/include/math.h index 3df841d46a93..6c6a5ec85f7d 100644 --- a/sys/arch/vax/include/math.h +++ b/sys/arch/vax/include/math.h @@ -1,7 +1,10 @@ -/* $NetBSD: math.h,v 1.3 2004/01/20 19:52:40 kleink Exp $ */ +/* $NetBSD: math.h,v 1.4 2004/03/04 23:42:38 kleink Exp $ */ #define __INFINITY 1.0E+39F +#define __isinf(__x) (0) +#define __isnan(__x) (0) + #if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ !defined(_XOPEN_SOURCE) || \ ((__STDC_VERSION__ - 0) >= 199901L) || \