* 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.
This commit is contained in:
kleink 2004-03-04 23:42:38 +00:00
parent bb362b40bf
commit 8e54f10bf7
36 changed files with 339 additions and 365 deletions

View File

@ -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

View File

@ -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 \

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 <sys/types.h>
#include <machine/ieee.h>
#include <math.h>
#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));

View File

@ -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 <sys/types.h>
#include <machine/ieee.h>
#include <math.h>
#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));

View File

@ -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

View File

@ -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 <sys/types.h>
#include <machine/ieee.h>
#include <math.h>
#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));

View File

@ -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 <sys/types.h>
#include <machine/ieee.h>
#include <math.h>
#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));

View File

@ -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 \

View File

@ -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

View File

@ -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")

View File

@ -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,

View File

@ -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 \

View File

@ -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

View File

@ -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

View File

@ -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 <sys/types.h>
#include <machine/ieee.h>
#include <math.h>
#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));
}

View File

@ -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 <sys/types.h>
#include <machine/ieee.h>
#include <math.h>
#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));
}

View File

@ -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

View File

@ -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 <math.h>
#ifdef __weak_alias
__weak_alias(isinf,_isinf)
#endif
#undef isinf
int isinf __P((double));
/* ARGSUSED */
int

View File

@ -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 <sys/cdefs.h>
#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 <math.h>
#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);
}

View File

@ -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 <math.h>
#ifdef __weak_alias
__weak_alias(isnan,_isnan)
#endif
#undef isnan
int isnan __P((double));
/* ARGSUSED */
int

View File

@ -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 <sys/cdefs.h>
#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 <math.h>
#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);
}

View File

@ -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

View File

@ -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 <sys/types.h>
#include <machine/ieee.h>
#include <math.h>
#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));

View File

@ -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 <sys/types.h>
#include <machine/ieee.h>
#include <math.h>
#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));

View File

@ -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

View File

@ -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 .

View File

@ -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 <sys/types.h>
#include <machine/ieee.h>
#include <math.h>
/* 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));
}

View File

@ -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 <sys/types.h>
#include <machine/ieee.h>
#include <float.h>
#include <math.h>
#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);
}

86
lib/libc/gen/isnan.3 Normal file
View File

@ -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 .

View File

@ -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 <sys/types.h>
#include <machine/ieee.h>
#include <math.h>
/* 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));
}

View File

@ -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 <sys/types.h>
#include <machine/ieee.h>
#include <float.h>
#include <math.h>
#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);
}

View File

@ -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

View File

@ -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) || \