Implement the classification macros isfinite(), isinf(), isnan(), and
isnormal() the hard way, rather than relying on fpclassify(). This is a lose in the sense that we need a total of 12 functions, but it is necessary for binary compatibility because we have never bumped libm's major version number. In particular, isinf(), isnan(), and isnanf() were BSD libc functions before they were C99 macros, so we can't reimplement them in terms of fpclassify() without adding a dependency on libc.so.5. I have tried to arrange things so that programs that could be compiled in FreeBSD 4.X will generate the same external references when compiled in 5.X. At the same time, the new macros should remain C99-compliant. The isinf() and isnan() functions remain in libc for historical reasons; however, I have moved the functions that implement the macros isfinite() and isnormal() to libm where they belong. Moreover, half a dozen MD versions of isinf() and isnan() have been replaced with MI versions that work equally well. Prodded by: kris
This commit is contained in:
parent
5ef7c3d0ff
commit
65d8d759b1
@ -1,6 +1,6 @@
|
||||
# $FreeBSD$
|
||||
|
||||
SRCS+= _setjmp.S fabs.S frexp.c infinity.c isinf.c ldexp.c modf.c setjmp.S
|
||||
SRCS+= _setjmp.S fabs.S frexp.c infinity.c ldexp.c modf.c setjmp.S
|
||||
SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
|
||||
fpsetround.c fpsetsticky.c
|
||||
|
||||
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $NetBSD: isinf.c,v 1.1 1995/02/10 17:50:23 cgd Exp $
|
||||
*/
|
||||
|
||||
/* For binary compat; to be removed in FreeBSD 6.0. */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <machine/ieee.h>
|
||||
#include <math.h>
|
||||
|
||||
#undef isnan
|
||||
#undef isinf
|
||||
|
||||
int
|
||||
isnan(d)
|
||||
double d;
|
||||
{
|
||||
union {
|
||||
double v;
|
||||
struct ieee_double s;
|
||||
} u;
|
||||
|
||||
u.v = d;
|
||||
return (u.s.dbl_exp == DBL_EXP_INFNAN &&
|
||||
(u.s.dbl_frach || u.s.dbl_fracl));
|
||||
}
|
||||
|
||||
int
|
||||
isinf(d)
|
||||
double d;
|
||||
{
|
||||
union {
|
||||
double v;
|
||||
struct ieee_double s;
|
||||
} u;
|
||||
|
||||
u.v = d;
|
||||
return (u.s.dbl_exp == DBL_EXP_INFNAN &&
|
||||
!u.s.dbl_frach && !u.s.dbl_fracl);
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
|
||||
SRCS+= _setjmp.S rfork_thread.S setjmp.S sigsetjmp.S \
|
||||
fabs.S modf.S \
|
||||
frexp.c infinity.c isinf.c ldexp.c \
|
||||
frexp.c infinity.c ldexp.c \
|
||||
makecontext.c signalcontext.c \
|
||||
fpgetmask.c fpsetmask.c fpgetprec.c fpsetprec.c \
|
||||
fpgetround.c fpsetround.c fpgetsticky.c fpsetsticky.c
|
||||
|
@ -1,75 +0,0 @@
|
||||
/*-
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
*/
|
||||
|
||||
/* For binary compat; to be removed in FreeBSD 6.0. */
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
struct IEEEdp {
|
||||
u_int manl : 32;
|
||||
u_int manh : 20;
|
||||
u_int exp : 11;
|
||||
u_int sign : 1;
|
||||
};
|
||||
|
||||
int
|
||||
isnan(d)
|
||||
double d;
|
||||
{
|
||||
union {
|
||||
double v;
|
||||
struct IEEEdp s;
|
||||
} u;
|
||||
|
||||
u.v = d;
|
||||
return(u.s.exp == 2047 && (u.s.manh || u.s.manl));
|
||||
}
|
||||
|
||||
int
|
||||
isinf(d)
|
||||
double d;
|
||||
{
|
||||
union {
|
||||
double v;
|
||||
struct IEEEdp s;
|
||||
} u;
|
||||
|
||||
u.v = d;
|
||||
return(u.s.exp == 2047 && !u.s.manh && !u.s.manl);
|
||||
}
|
@ -2,5 +2,5 @@
|
||||
# $FreeBSD$
|
||||
|
||||
SRCS+= _ctx_start.S _setjmp.S alloca.S fabs.c frexp.c \
|
||||
infinity.c isinf.c ldexp.c makecontext.c modf.c \
|
||||
infinity.c ldexp.c makecontext.c modf.c \
|
||||
setjmp.S signalcontext.c sigsetjmp.S divsi3.S
|
||||
|
@ -1,70 +0,0 @@
|
||||
/*-
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
*/
|
||||
|
||||
/* For binary compat; to be removed in FreeBSD 6.0. */
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
int
|
||||
isnan(d)
|
||||
double d;
|
||||
{
|
||||
register struct IEEEdp {
|
||||
u_int manl : 32;
|
||||
u_int manh : 20;
|
||||
u_int exp : 11;
|
||||
u_int sign : 1;
|
||||
} *p = (struct IEEEdp *)&d;
|
||||
|
||||
return(p->exp == 2047 && (p->manh || p->manl));
|
||||
}
|
||||
|
||||
int
|
||||
isinf(d)
|
||||
double d;
|
||||
{
|
||||
register struct IEEEdp {
|
||||
u_int manl : 32;
|
||||
u_int manh : 20;
|
||||
u_int exp : 11;
|
||||
u_int sign : 1;
|
||||
} *p = (struct IEEEdp *)&d;
|
||||
|
||||
return(p->exp == 2047 && !p->manh && !p->manl);
|
||||
}
|
@ -17,7 +17,7 @@ SRCS+= __xuname.c _pthread_stubs.c _rand48.c _spinlock_stub.c _thread_init.c \
|
||||
getobjformat.c getosreldate.c getpagesize.c \
|
||||
getpeereid.c getprogname.c getpwent.c getttyent.c \
|
||||
getusershell.c getvfsbyname.c glob.c \
|
||||
initgroups.c isatty.c jrand48.c lcong48.c \
|
||||
initgroups.c isatty.c isinf.c isnan.c jrand48.c lcong48.c \
|
||||
lockf.c lrand48.c mrand48.c nice.c \
|
||||
nlist.c nrand48.c ntp_gettime.c opendir.c \
|
||||
pause.c pmadvise.c popen.c posixshm.c pselect.c \
|
||||
|
66
lib/libc/gen/isinf.c
Normal file
66
lib/libc/gen/isinf.c
Normal file
@ -0,0 +1,66 @@
|
||||
/*-
|
||||
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "fpmath.h"
|
||||
|
||||
/*
|
||||
* XXX These routines belong in libm, but they must remain in libc for
|
||||
* binary compat until we can bump libm's major version number.
|
||||
*/
|
||||
|
||||
__weak_reference(__isinf, isinf);
|
||||
|
||||
int
|
||||
__isinf(double d)
|
||||
{
|
||||
union IEEEd2bits u;
|
||||
|
||||
u.d = d;
|
||||
return (u.bits.exp == 2047 && u.bits.manl == 0 && u.bits.manh == 0);
|
||||
}
|
||||
|
||||
int
|
||||
__isinff(float f)
|
||||
{
|
||||
union IEEEf2bits u;
|
||||
|
||||
u.f = f;
|
||||
return (u.bits.exp == 255 && u.bits.man == 0);
|
||||
}
|
||||
|
||||
int
|
||||
__isinfl(long double e)
|
||||
{
|
||||
union IEEEl2bits u;
|
||||
|
||||
u.e = e;
|
||||
mask_nbit_l(u);
|
||||
return (u.bits.exp == 32767 && u.bits.manl == 0 && u.bits.manh == 0);
|
||||
}
|
67
lib/libc/gen/isnan.c
Normal file
67
lib/libc/gen/isnan.c
Normal file
@ -0,0 +1,67 @@
|
||||
/*-
|
||||
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "fpmath.h"
|
||||
|
||||
/*
|
||||
* XXX These routines belong in libm, but they must remain in libc for
|
||||
* binary compat until we can bump libm's major version number.
|
||||
*/
|
||||
|
||||
__weak_reference(__isnan, isnan);
|
||||
__weak_reference(__isnanf, isnanf);
|
||||
|
||||
int
|
||||
__isnan(double d)
|
||||
{
|
||||
union IEEEd2bits u;
|
||||
|
||||
u.d = d;
|
||||
return (u.bits.exp == 2047 && (u.bits.manl != 0 || u.bits.manh != 0));
|
||||
}
|
||||
|
||||
int
|
||||
__isnanf(float f)
|
||||
{
|
||||
union IEEEf2bits u;
|
||||
|
||||
u.f = f;
|
||||
return (u.bits.exp == 255 && u.bits.man != 0);
|
||||
}
|
||||
|
||||
int
|
||||
__isnanl(long double e)
|
||||
{
|
||||
union IEEEl2bits u;
|
||||
|
||||
u.e = e;
|
||||
mask_nbit_l(u);
|
||||
return (u.bits.exp == 32767 && (u.bits.manl != 0 || u.bits.manh != 0));
|
||||
}
|
@ -2,5 +2,5 @@
|
||||
# $FreeBSD$
|
||||
|
||||
SRCS+= _ctx_start.S _setjmp.S alloca.S fabs.S frexp.c \
|
||||
infinity.c isinf.c ldexp.c makecontext.c modf.S \
|
||||
infinity.c ldexp.c makecontext.c modf.S \
|
||||
rfork_thread.S setjmp.S signalcontext.c sigsetjmp.S
|
||||
|
@ -1,75 +0,0 @@
|
||||
/*-
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
*/
|
||||
|
||||
/* For binary compat; to be removed in FreeBSD 6.0. */
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
struct IEEEdp {
|
||||
u_int manl : 32;
|
||||
u_int manh : 20;
|
||||
u_int exp : 11;
|
||||
u_int sign : 1;
|
||||
};
|
||||
|
||||
int
|
||||
isnan(d)
|
||||
double d;
|
||||
{
|
||||
union {
|
||||
double v;
|
||||
struct IEEEdp s;
|
||||
} u;
|
||||
|
||||
u.v = d;
|
||||
return (u.s.exp == 2047 && (u.s.manh || u.s.manl));
|
||||
}
|
||||
|
||||
int
|
||||
isinf(d)
|
||||
double d;
|
||||
{
|
||||
union {
|
||||
double v;
|
||||
struct IEEEdp s;
|
||||
} u;
|
||||
|
||||
u.v = d;
|
||||
return (u.s.exp == 2047 && !u.s.manh && !u.s.manl);
|
||||
}
|
@ -3,8 +3,7 @@
|
||||
SRCS+= __divdf3.S __divdi3.S __divsf3.S __divsi3.S __moddi3.S __modsi3.S \
|
||||
__udivdi3.S __udivsi3.S __umoddi3.S __umodsi3.S _setjmp.S fabs.S \
|
||||
fpgetmask.c fpgetround.c fpsetmask.c fpsetround.c frexp.c infinity.c \
|
||||
isinf.c ldexp.c makecontext.c modf.c setjmp.S signalcontext.c \
|
||||
sigsetjmp.S
|
||||
ldexp.c makecontext.c modf.c setjmp.S signalcontext.c sigsetjmp.S
|
||||
|
||||
# The following may go away if function _Unwind_FindTableEntry()
|
||||
# will be part of GCC.
|
||||
|
@ -1,68 +0,0 @@
|
||||
/* $NetBSD: isinf.c,v 1.1 1995/02/10 17:50:23 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
/* For binary compat; to be removed in FreeBSD 6.0. */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <machine/ieee.h>
|
||||
#include <math.h>
|
||||
|
||||
#undef isnan
|
||||
#undef isinf
|
||||
|
||||
int
|
||||
isnan(d)
|
||||
double d;
|
||||
{
|
||||
union {
|
||||
double v;
|
||||
struct ieee_double s;
|
||||
} u;
|
||||
|
||||
u.v = d;
|
||||
return (u.s.dbl_exp == DBL_EXP_INFNAN &&
|
||||
(u.s.dbl_frach || u.s.dbl_fracl));
|
||||
}
|
||||
|
||||
int
|
||||
isinf(d)
|
||||
double d;
|
||||
{
|
||||
union {
|
||||
double v;
|
||||
struct ieee_double s;
|
||||
} u;
|
||||
|
||||
u.v = d;
|
||||
return (u.s.dbl_exp == DBL_EXP_INFNAN &&
|
||||
!u.s.dbl_frach && !u.s.dbl_fracl);
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
SRCS += _ctx_start.S fabs.S flt_rounds.c fpgetmask.c fpgetround.c \
|
||||
fpgetsticky.c fpsetmask.c fpsetround.c fpsetsticky.c frexp.c \
|
||||
infinity.c isinf.c ldexp.c makecontext.c modf.c _setjmp.S \
|
||||
infinity.c ldexp.c makecontext.c modf.c _setjmp.S \
|
||||
setjmp.S sigsetjmp.S syncicache.c
|
||||
|
||||
|
||||
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $NetBSD: isinf.c,v 1.1 1995/02/10 17:50:23 cgd Exp $
|
||||
* from: FreeBSD: src/lib/libc/alpha/gen/isinf.c,v 1.2 2000/05/10
|
||||
*/
|
||||
|
||||
/* For binary compat; to be removed in FreeBSD 6.0. */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <machine/ieee.h>
|
||||
#include <math.h>
|
||||
|
||||
#undef isnan
|
||||
#undef isinf
|
||||
|
||||
int
|
||||
isnan(double d)
|
||||
{
|
||||
union {
|
||||
double v;
|
||||
struct ieee_double s;
|
||||
} u;
|
||||
|
||||
u.v = d;
|
||||
return (u.s.dbl_exp == DBL_EXP_INFNAN &&
|
||||
(u.s.dbl_frach || u.s.dbl_fracl));
|
||||
}
|
||||
|
||||
int
|
||||
isinf(double d)
|
||||
{
|
||||
union {
|
||||
double v;
|
||||
struct ieee_double s;
|
||||
} u;
|
||||
|
||||
u.v = d;
|
||||
return (u.s.dbl_exp == DBL_EXP_INFNAN &&
|
||||
!u.s.dbl_frach && !u.s.dbl_fracl);
|
||||
}
|
@ -2,5 +2,5 @@
|
||||
|
||||
SRCS+= _ctx_start.S _setjmp.S fabs.S fixunsdfsi.S flt_rounds.c fpgetmask.c \
|
||||
fpgetround.c fpgetsticky.c fpsetmask.c fpsetround.c fpsetsticky.c \
|
||||
frexp.c infinity.c isinf.c ldexp.c makecontext.c modf.S \
|
||||
frexp.c infinity.c ldexp.c makecontext.c modf.S \
|
||||
signalcontext.c setjmp.S sigsetjmp.S
|
||||
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $NetBSD: isinf.c,v 1.1 1995/02/10 17:50:23 cgd Exp $
|
||||
* from: FreeBSD: src/lib/libc/alpha/gen/isinf.c,v 1.2 2000/05/10
|
||||
*/
|
||||
|
||||
/* For binary compat; to be removed in FreeBSD 6.0. */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <machine/ieee.h>
|
||||
#include <math.h>
|
||||
|
||||
#undef isnan
|
||||
#undef isinf
|
||||
|
||||
int
|
||||
isnan(d)
|
||||
double d;
|
||||
{
|
||||
union {
|
||||
double v;
|
||||
struct ieee_double s;
|
||||
} u;
|
||||
|
||||
u.v = d;
|
||||
return (u.s.dbl_exp == DBL_EXP_INFNAN &&
|
||||
(u.s.dbl_frach || u.s.dbl_fracl));
|
||||
}
|
||||
|
||||
int
|
||||
isinf(d)
|
||||
double d;
|
||||
{
|
||||
union {
|
||||
double v;
|
||||
struct ieee_double s;
|
||||
} u;
|
||||
|
||||
u.v = d;
|
||||
return (u.s.dbl_exp == DBL_EXP_INFNAN &&
|
||||
!u.s.dbl_frach && !u.s.dbl_fracl);
|
||||
}
|
@ -84,7 +84,8 @@ COMMON_SRCS= b_exp.c b_log.c b_tgamma.c \
|
||||
s_expm1.c s_expm1f.c s_fabsf.c s_fdim.c s_finite.c s_finitef.c \
|
||||
s_floor.c s_floorf.c s_fmax.c s_fmaxf.c s_fmaxl.c s_fmin.c \
|
||||
s_fminf.c s_fminl.c s_frexp.c s_frexpf.c s_ilogb.c s_ilogbf.c \
|
||||
s_isnanf.c s_ldexpf.c s_lib_version.c s_log1p.c \
|
||||
s_isfinite.c s_isnanf.c s_isnormal.c s_ldexpf.c \
|
||||
s_lib_version.c s_log1p.c \
|
||||
s_log1pf.c s_logb.c s_logbf.c s_matherr.c s_modff.c \
|
||||
s_nearbyint.c s_nextafter.c s_nextafterf.c \
|
||||
s_rint.c s_rintf.c s_round.c s_roundf.c \
|
||||
|
@ -79,10 +79,22 @@ extern const union __nan_un {
|
||||
: (sizeof (x) == sizeof (double)) ? __fpclassifyd(x) \
|
||||
: __fpclassifyl(x))
|
||||
|
||||
#define isfinite(x) ((fpclassify(x) & (FP_INFINITE|FP_NAN)) == 0)
|
||||
#define isinf(x) (fpclassify(x) == FP_INFINITE)
|
||||
#define isnan(x) (fpclassify(x) == FP_NAN)
|
||||
#define isnormal(x) (fpclassify(x) == FP_NORMAL)
|
||||
#define isfinite(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isfinitef(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? __isfinite(x) \
|
||||
: __isfinitel(x))
|
||||
#define isinf(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isinff(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? isinf(x) \
|
||||
: __isinfl(x))
|
||||
#define isnan(x) \
|
||||
((sizeof (x) == sizeof (float)) ? isnanf(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? isnan(x) \
|
||||
: __isnanl(x))
|
||||
#define isnormal(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isnormalf(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? __isnormal(x) \
|
||||
: __isnormall(x))
|
||||
|
||||
#ifdef __MATH_BUILTIN_RELOPS
|
||||
#define isgreater(x, y) __builtin_isgreater((x), (y))
|
||||
@ -161,8 +173,6 @@ struct exception {
|
||||
};
|
||||
#endif
|
||||
|
||||
#define isnanf(x) isnan(x)
|
||||
|
||||
#if 0
|
||||
/* Old value from 4.4BSD-Lite math.h; this is probably better. */
|
||||
#define HUGE HUGE_VAL
|
||||
@ -195,6 +205,15 @@ __BEGIN_DECLS
|
||||
int __fpclassifyd(double) __pure2;
|
||||
int __fpclassifyf(float) __pure2;
|
||||
int __fpclassifyl(long double) __pure2;
|
||||
int __isfinitef(float) __pure2;
|
||||
int __isfinite(double) __pure2;
|
||||
int __isfinitel(long double) __pure2;
|
||||
int __isinff(float) __pure2;
|
||||
int __isinfl(long double) __pure2;
|
||||
int __isnanl(long double) __pure2;
|
||||
int __isnormalf(float) __pure2;
|
||||
int __isnormal(double) __pure2;
|
||||
int __isnormall(long double) __pure2;
|
||||
int __signbit(double) __pure2;
|
||||
|
||||
double acos(double);
|
||||
@ -241,6 +260,8 @@ double fmax(double, double) __pure2;
|
||||
double fmin(double, double) __pure2;
|
||||
double hypot(double, double);
|
||||
int ilogb(double);
|
||||
int (isinf)(double) __pure2;
|
||||
int (isnan)(double) __pure2;
|
||||
double lgamma(double);
|
||||
double log1p(double) __pure2;
|
||||
double logb(double) __pure2;
|
||||
@ -279,6 +300,7 @@ double tgamma(double);
|
||||
#if __BSD_VISIBLE
|
||||
double drem(double, double);
|
||||
int finite(double) __pure2;
|
||||
int isnanf(float) __pure2;
|
||||
|
||||
/*
|
||||
* Reentrant version of gamma & lgamma; passes signgam back by reference
|
||||
|
58
lib/msun/src/s_isfinite.c
Normal file
58
lib/msun/src/s_isfinite.c
Normal file
@ -0,0 +1,58 @@
|
||||
/*-
|
||||
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "fpmath.h"
|
||||
|
||||
int
|
||||
__isfinite(double d)
|
||||
{
|
||||
union IEEEd2bits u;
|
||||
|
||||
u.d = d;
|
||||
return (u.bits.exp != 2047);
|
||||
}
|
||||
|
||||
int
|
||||
__isfinitef(float f)
|
||||
{
|
||||
union IEEEf2bits u;
|
||||
|
||||
u.f = f;
|
||||
return (u.bits.exp != 255);
|
||||
}
|
||||
|
||||
int
|
||||
__isfinitel(long double e)
|
||||
{
|
||||
union IEEEl2bits u;
|
||||
|
||||
u.e = e;
|
||||
return (u.bits.exp != 32767);
|
||||
}
|
58
lib/msun/src/s_isnormal.c
Normal file
58
lib/msun/src/s_isnormal.c
Normal file
@ -0,0 +1,58 @@
|
||||
/*-
|
||||
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "fpmath.h"
|
||||
|
||||
int
|
||||
__isnormal(double d)
|
||||
{
|
||||
union IEEEd2bits u;
|
||||
|
||||
u.d = d;
|
||||
return (u.bits.exp != 0 && u.bits.exp != 2047);
|
||||
}
|
||||
|
||||
int
|
||||
__isnormalf(float f)
|
||||
{
|
||||
union IEEEf2bits u;
|
||||
|
||||
u.f = f;
|
||||
return (u.bits.exp != 0 && u.bits.exp != 255);
|
||||
}
|
||||
|
||||
int
|
||||
__isnormall(long double e)
|
||||
{
|
||||
union IEEEl2bits u;
|
||||
|
||||
u.e = e;
|
||||
return (u.bits.exp != 0 && u.bits.exp != 32767);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user