From: martynas Date: Thu, 24 Jul 2008 09:31:06 +0000 (+0000) Subject: - move isinf, isnan dups to gen, since most is ieee 754 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=610deaf95d539135818b68651d2d9514b605d5e7;p=openbsd - move isinf, isnan dups to gen, since most is ieee 754 - is{inf,nan} should be macros for real-floating, so rename to __is{inf,nan}, per C99 - implement C99 __fpclassify(), __fpclassifyf(), __isfinite(), __isfinitef(), __isnormal(), __isnormalf(), __signbit(), __signbitf() - long functions added, but not yet enabled, till ieee.h is fixed - implement vax equivalents of the functions - reimplement isinff, isnanf in a better way, and move to libc - add qnan bytes for all archs - bump major man pages will follow ok millert@. arm bits looked over by drahn@ discussed w/ theo, who showed the right direction, to put these functions in libc --- diff --git a/lib/libc/arch/alpha/gen/Makefile.inc b/lib/libc/arch/alpha/gen/Makefile.inc index 127dc88c7a4..2f82f39d175 100644 --- a/lib/libc/arch/alpha/gen/Makefile.inc +++ b/lib/libc/arch/alpha/gen/Makefile.inc @@ -1,8 +1,7 @@ -# $OpenBSD: Makefile.inc,v 1.7 2005/11/29 21:38:06 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.8 2008/07/24 09:31:06 martynas Exp $ # $NetBSD: Makefile.inc,v 1.3 1995/04/29 05:09:14 cgd Exp $ -SRCS+= _setjmp.S fabs.S infinity.c isinf.c isnan.c ldexp.c \ - modf.c setjmp.S +SRCS+= _setjmp.S fabs.S infinity.c ldexp.c modf.c nan.c setjmp.S SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ fpsetround.c fpsetsticky.c SRCS+= sigsetjmp.S diff --git a/lib/libc/arch/alpha/gen/isinf.c b/lib/libc/arch/alpha/gen/isinf.c deleted file mode 100644 index 2c3170f0483..00000000000 --- a/lib/libc/arch/alpha/gen/isinf.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isinf.c,v 1.6 2005/08/07 16:40:13 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isinf(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - p->dbl_frach == 0 && p->dbl_fracl == 0); -} diff --git a/lib/libc/arch/alpha/gen/isnan.c b/lib/libc/arch/alpha/gen/isnan.c deleted file mode 100644 index 016b1f3ebd3..00000000000 --- a/lib/libc/arch/alpha/gen/isnan.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isnan.c,v 1.3 2005/08/07 16:40:13 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isnan(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - (p->dbl_frach != 0 || p->dbl_fracl != 0)); -} diff --git a/lib/libc/arch/alpha/gen/nan.c b/lib/libc/arch/alpha/gen/nan.c new file mode 100644 index 00000000000..2d253788b11 --- /dev/null +++ b/lib/libc/arch/alpha/gen/nan.c @@ -0,0 +1,9 @@ +/* $OpenBSD: nan.c,v 1.1 2008/07/24 09:31:06 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include + +/* bytes for qNaN on an alpha (IEEE single format) */ +char __nan[] __attribute__((__aligned__(sizeof(float)))) = + { 0, 0, 0xc0, 0x7f }; diff --git a/lib/libc/arch/amd64/gen/Makefile.inc b/lib/libc/arch/amd64/gen/Makefile.inc index c9b9041804c..6358bd86c61 100644 --- a/lib/libc/arch/amd64/gen/Makefile.inc +++ b/lib/libc/arch/amd64/gen/Makefile.inc @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile.inc,v 1.3 2005/11/29 21:38:08 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.4 2008/07/24 09:31:06 martynas Exp $ -SRCS+= _setjmp.S fabs.S infinity.c isinf.c isnan.c ldexp.c \ - modf.S setjmp.S sigsetjmp.S +SRCS+= _setjmp.S fabs.S infinity.c ldexp.c modf.S nan.c setjmp.S \ + sigsetjmp.S SRCS+= flt_rounds.S fpgetmask.S fpgetround.S fpgetsticky.S fpsetmask.S \ fpsetround.S fpsetsticky.S diff --git a/lib/libc/arch/amd64/gen/isinf.c b/lib/libc/arch/amd64/gen/isinf.c deleted file mode 100644 index 962640ec7ec..00000000000 --- a/lib/libc/arch/amd64/gen/isinf.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isinf.c,v 1.2 2005/08/07 16:40:13 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isinf(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - p->dbl_frach == 0 && p->dbl_fracl == 0); -} diff --git a/lib/libc/arch/amd64/gen/isnan.c b/lib/libc/arch/amd64/gen/isnan.c deleted file mode 100644 index ea55abf7ca1..00000000000 --- a/lib/libc/arch/amd64/gen/isnan.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isnan.c,v 1.2 2005/08/07 16:40:13 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isnan(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - (p->dbl_frach != 0 || p->dbl_fracl != 0)); -} diff --git a/lib/libc/arch/amd64/gen/nan.c b/lib/libc/arch/amd64/gen/nan.c new file mode 100644 index 00000000000..39800b64c75 --- /dev/null +++ b/lib/libc/arch/amd64/gen/nan.c @@ -0,0 +1,9 @@ +/* $OpenBSD: nan.c,v 1.1 2008/07/24 09:31:06 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include + +/* bytes for qNaN on an amd64 (IEEE single format) */ +char __nan[] __attribute__((__aligned__(sizeof(float)))) = + { 0, 0, 0xc0, 0x7f }; diff --git a/lib/libc/arch/arm/gen/Makefile.inc b/lib/libc/arch/arm/gen/Makefile.inc index 851c307566f..9877978c8dd 100644 --- a/lib/libc/arch/arm/gen/Makefile.inc +++ b/lib/libc/arch/arm/gen/Makefile.inc @@ -1,8 +1,9 @@ -# $OpenBSD: Makefile.inc,v 1.8 2005/11/29 21:38:08 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.9 2008/07/24 09:31:06 martynas Exp $ # $NetBSD: Makefile.inc,v 1.6 2003/08/01 17:03:47 lukem Exp $ -SRCS+= byte_swap_2.S byte_swap_4.S divsi3.S fabs.c flt_rounds.c infinity.c -SRCS+= setjmp.S _setjmp.S sigsetjmp.S isinf.c isnan.c modf.c ldexp.c +SRCS+= byte_swap_2.S byte_swap_4.S divsi3.S fabs.c flt_rounds.c infinity.c \ + nan.c +SRCS+= setjmp.S _setjmp.S sigsetjmp.S modf.c ldexp.c SRCS+= alloca.S LSRCS+= alloca.c diff --git a/lib/libc/arch/arm/gen/isinf.c b/lib/libc/arch/arm/gen/isinf.c deleted file mode 100644 index 8b2c475d83e..00000000000 --- a/lib/libc/arch/arm/gen/isinf.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: isinf.c,v 1.2 2005/08/07 16:40:14 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include -#include - -int -isinf(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - p->dbl_frach == 0 && p->dbl_fracl == 0); -} diff --git a/lib/libc/arch/arm/gen/isnan.c b/lib/libc/arch/arm/gen/isnan.c deleted file mode 100644 index 61b2318ff58..00000000000 --- a/lib/libc/arch/arm/gen/isnan.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: isnan.c,v 1.2 2005/08/07 16:40:14 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include -#include - -int -isnan(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - (p->dbl_frach != 0 || p->dbl_fracl != 0)); -} diff --git a/lib/libc/arch/arm/gen/nan.c b/lib/libc/arch/arm/gen/nan.c new file mode 100644 index 00000000000..6c75f3060c2 --- /dev/null +++ b/lib/libc/arch/arm/gen/nan.c @@ -0,0 +1,15 @@ +/* $OpenBSD: nan.c,v 1.1 2008/07/24 09:31:06 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include +#include +#include + +/* bytes for qNaN on an arm (IEEE single format) */ +char __nan[] __attribute__((__aligned__(sizeof(float)))) = +#if BYTE_ORDER == BIG_ENDIAN + { 0x7f, 0xc0, 0, 0 }; +#else /* BYTE_ORDER == BIG_ENDIAN */ + { 0, 0, 0xc0, 0x7f }; +#endif /* BYTE_ORDER == BIG_ENDIAN */ diff --git a/lib/libc/arch/hppa/gen/Makefile.inc b/lib/libc/arch/hppa/gen/Makefile.inc index 895ddfdefff..dbe7648d951 100644 --- a/lib/libc/arch/hppa/gen/Makefile.inc +++ b/lib/libc/arch/hppa/gen/Makefile.inc @@ -1,8 +1,8 @@ -# $OpenBSD: Makefile.inc,v 1.8 2005/11/29 21:38:08 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.9 2008/07/24 09:31:06 martynas Exp $ SRCS+= setjmp.S SRCS+= fabs.c ldexp.c -SRCS+= isnan.c isinf.c infinity.c setjmp.S +SRCS+= infinity.c nan.c setjmp.S SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ fpsetround.c fpsetsticky.c SRCS+= modf.c diff --git a/lib/libc/arch/hppa/gen/isinf.c b/lib/libc/arch/hppa/gen/isinf.c deleted file mode 100644 index b5f4dbe7166..00000000000 --- a/lib/libc/arch/hppa/gen/isinf.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isinf.c,v 1.4 2005/08/07 16:40:14 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isinf(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - p->dbl_frach == 0 && p->dbl_fracl == 0); -} diff --git a/lib/libc/arch/hppa/gen/isnan.c b/lib/libc/arch/hppa/gen/isnan.c deleted file mode 100644 index 545e2592cfd..00000000000 --- a/lib/libc/arch/hppa/gen/isnan.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isnan.c,v 1.4 2005/08/07 16:40:14 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isnan(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - (p->dbl_frach != 0 || p->dbl_fracl != 0)); -} diff --git a/lib/libc/arch/hppa/gen/nan.c b/lib/libc/arch/hppa/gen/nan.c new file mode 100644 index 00000000000..aa2200eac9d --- /dev/null +++ b/lib/libc/arch/hppa/gen/nan.c @@ -0,0 +1,9 @@ +/* $OpenBSD: nan.c,v 1.1 2008/07/24 09:31:06 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include + +/* bytes for qNaN on a hppa (IEEE single format) */ +char __nan[] __attribute__((__aligned__(sizeof(float)))) = + { 0x7f, 0xa0, 0, 0 }; diff --git a/lib/libc/arch/hppa64/gen/Makefile.inc b/lib/libc/arch/hppa64/gen/Makefile.inc index 03943c9f2f3..91a4d2e8ffd 100644 --- a/lib/libc/arch/hppa64/gen/Makefile.inc +++ b/lib/libc/arch/hppa64/gen/Makefile.inc @@ -1,8 +1,8 @@ -# $OpenBSD: Makefile.inc,v 1.2 2005/11/29 21:38:09 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.3 2008/07/24 09:31:06 martynas Exp $ SRCS+= setjmp.S SRCS+= fabs.c frexp.c ldexp.c -SRCS+= isnan.c isinf.c infinity.c setjmp.S +SRCS+= infinity.c nan.c setjmp.S SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ fpsetround.c fpsetsticky.c SRCS+= modf.c diff --git a/lib/libc/arch/hppa64/gen/isinf.c b/lib/libc/arch/hppa64/gen/isinf.c deleted file mode 100644 index a26c4beb16b..00000000000 --- a/lib/libc/arch/hppa64/gen/isinf.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isinf.c,v 1.2 2005/08/07 16:40:14 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isinf(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - p->dbl_frach == 0 && p->dbl_fracl == 0); -} diff --git a/lib/libc/arch/hppa64/gen/isnan.c b/lib/libc/arch/hppa64/gen/isnan.c deleted file mode 100644 index 88f9b582b3d..00000000000 --- a/lib/libc/arch/hppa64/gen/isnan.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isnan.c,v 1.2 2005/08/07 16:40:14 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isnan(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - (p->dbl_frach != 0 || p->dbl_fracl != 0)); -} diff --git a/lib/libc/arch/hppa64/gen/nan.c b/lib/libc/arch/hppa64/gen/nan.c new file mode 100644 index 00000000000..7af3cb148f8 --- /dev/null +++ b/lib/libc/arch/hppa64/gen/nan.c @@ -0,0 +1,9 @@ +/* $OpenBSD: nan.c,v 1.1 2008/07/24 09:31:06 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include + +/* bytes for qNaN on a hppa64 (IEEE single format) */ +char __nan[] __attribute__((__aligned__(sizeof(float)))) = + { 0x7f, 0xa0, 0, 0 }; diff --git a/lib/libc/arch/i386/gen/Makefile.inc b/lib/libc/arch/i386/gen/Makefile.inc index fcde8b3176a..bafaa0e9d86 100644 --- a/lib/libc/arch/i386/gen/Makefile.inc +++ b/lib/libc/arch/i386/gen/Makefile.inc @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile.inc,v 1.5 2005/11/29 21:38:09 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.6 2008/07/24 09:31:06 martynas Exp $ -SRCS+= _setjmp.S alloca.S fabs.S infinity.c isinf.c isnan.c ldexp.c \ - modf.S setjmp.S sigsetjmp.S +SRCS+= _setjmp.S alloca.S fabs.S infinity.c ldexp.c \ + modf.S nan.c setjmp.S sigsetjmp.S SRCS+= flt_rounds.S fpgetmask.S fpgetround.S fpgetsticky.S fpsetmask.S \ fpsetround.S fpsetsticky.S SRCS+= divsi3.S fixdfsi.S fixunsdfsi.S udivsi3.S diff --git a/lib/libc/arch/i386/gen/isinf.c b/lib/libc/arch/i386/gen/isinf.c deleted file mode 100644 index a01c1f918fa..00000000000 --- a/lib/libc/arch/i386/gen/isinf.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: isinf.c,v 1.7 2005/08/07 11:30:38 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include -#include - -int -isinf(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - p->dbl_frach == 0 && p->dbl_fracl == 0); -} diff --git a/lib/libc/arch/i386/gen/isnan.c b/lib/libc/arch/i386/gen/isnan.c deleted file mode 100644 index 0f8ce1c8ab4..00000000000 --- a/lib/libc/arch/i386/gen/isnan.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: isnan.c,v 1.4 2005/08/07 11:30:38 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include -#include - -int -isnan(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - (p->dbl_frach != 0 || p->dbl_fracl != 0)); -} diff --git a/lib/libc/arch/i386/gen/nan.c b/lib/libc/arch/i386/gen/nan.c new file mode 100644 index 00000000000..622e73de172 --- /dev/null +++ b/lib/libc/arch/i386/gen/nan.c @@ -0,0 +1,9 @@ +/* $OpenBSD: nan.c,v 1.1 2008/07/24 09:31:06 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include + +/* bytes for qNaN on an i386 (IEEE single format) */ +char __nan[] __attribute__((__aligned__(sizeof(float)))) = + { 0, 0, 0xc0, 0x7f }; diff --git a/lib/libc/arch/m68k/gen/Makefile.inc b/lib/libc/arch/m68k/gen/Makefile.inc index 043307a71d2..698f4debf45 100644 --- a/lib/libc/arch/m68k/gen/Makefile.inc +++ b/lib/libc/arch/m68k/gen/Makefile.inc @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile.inc,v 1.5 2005/11/29 21:38:09 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.6 2008/07/24 09:31:06 martynas Exp $ -SRCS+= _setjmp.S fabs.S infinity.c isinf.c isnan.c ldexp.S \ - modf.S setjmp.S sigsetjmp.S +SRCS+= _setjmp.S fabs.S infinity.c ldexp.S \ + modf.S nan.c setjmp.S sigsetjmp.S SRCS+= flt_rounds.S fpgetmask.S fpgetround.S fpgetsticky.S fpsetmask.S \ fpsetround.S fpsetsticky.S SRCS+= adddf3.S addsf3.S ashlsi3.S ashrsi3.S cmpdf2.S cmpsf2.S divdf3.S \ diff --git a/lib/libc/arch/m68k/gen/isinf.c b/lib/libc/arch/m68k/gen/isinf.c deleted file mode 100644 index d9341ee86d4..00000000000 --- a/lib/libc/arch/m68k/gen/isinf.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isinf.c,v 1.6 2005/08/07 16:40:14 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isinf(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - p->dbl_frach == 0 && p->dbl_fracl == 0); -} diff --git a/lib/libc/arch/m68k/gen/isnan.c b/lib/libc/arch/m68k/gen/isnan.c deleted file mode 100644 index a54b25b8db0..00000000000 --- a/lib/libc/arch/m68k/gen/isnan.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isnan.c,v 1.3 2005/08/07 16:40:14 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isnan(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - (p->dbl_frach != 0 || p->dbl_fracl != 0)); -} diff --git a/lib/libc/arch/m68k/gen/nan.c b/lib/libc/arch/m68k/gen/nan.c new file mode 100644 index 00000000000..92a2910e63b --- /dev/null +++ b/lib/libc/arch/m68k/gen/nan.c @@ -0,0 +1,9 @@ +/* $OpenBSD: nan.c,v 1.1 2008/07/24 09:31:06 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include + +/* bytes for qNaN on a m68k (IEEE single format) */ +char __nan[] __attribute__((__aligned__(sizeof(float)))) = + { 0x7f, 0xc0, 0, 0 }; diff --git a/lib/libc/arch/m88k/gen/Makefile.inc b/lib/libc/arch/m88k/gen/Makefile.inc index 0daa09ea138..62bf28c6c51 100644 --- a/lib/libc/arch/m88k/gen/Makefile.inc +++ b/lib/libc/arch/m88k/gen/Makefile.inc @@ -1,12 +1,12 @@ -# $OpenBSD: Makefile.inc,v 1.5 2005/11/29 21:38:09 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.6 2008/07/24 09:31:06 martynas Exp $ # $NetBSD: Makefile.inc,v 1.3 1995/04/10 21:09:06 jtc Exp $ -#SRCS+= _setjmp.S fabs.S infinity.c isinf.c isnan.c ldexp.c modf.S +#SRCS+= _setjmp.S fabs.S infinity.c ldexp.c modf.S nan.c #SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ # fpsetround.c fpsetsticky.c #SRCS+= fixunsdfsi.S mul.S umul.S saveregs.S setjmp.S sigsetjmp.S -SRCS+= _setjmp.S fabs.S frexp.c infinity.c isinf.c isnan.c ldexp.c +SRCS+= _setjmp.S fabs.S frexp.c infinity.c ldexp.c nan.c SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ fpsetround.c fpsetsticky.c SRCS+= setjmp.S sigsetjmp.S diff --git a/lib/libc/arch/m88k/gen/isinf.c b/lib/libc/arch/m88k/gen/isinf.c deleted file mode 100644 index 9257021b5d5..00000000000 --- a/lib/libc/arch/m88k/gen/isinf.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isinf.c,v 1.5 2005/08/07 16:40:14 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isinf(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - p->dbl_frach == 0 && p->dbl_fracl == 0); -} diff --git a/lib/libc/arch/m88k/gen/isnan.c b/lib/libc/arch/m88k/gen/isnan.c deleted file mode 100644 index 78e721815b2..00000000000 --- a/lib/libc/arch/m88k/gen/isnan.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isnan.c,v 1.5 2005/08/07 16:40:14 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isnan(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - (p->dbl_frach != 0 || p->dbl_fracl != 0)); -} diff --git a/lib/libc/arch/m88k/gen/nan.c b/lib/libc/arch/m88k/gen/nan.c new file mode 100644 index 00000000000..69de592bae4 --- /dev/null +++ b/lib/libc/arch/m88k/gen/nan.c @@ -0,0 +1,9 @@ +/* $OpenBSD: nan.c,v 1.1 2008/07/24 09:31:06 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include + +/* bytes for qNaN on a m88k (IEEE single format) */ +char __nan[] __attribute__((__aligned__(sizeof(float)))) = + { 0x7f, 0xc0, 0, 0 }; diff --git a/lib/libc/arch/mips64/gen/Makefile.inc b/lib/libc/arch/mips64/gen/Makefile.inc index 2228c921ad1..46d871e0704 100644 --- a/lib/libc/arch/mips64/gen/Makefile.inc +++ b/lib/libc/arch/mips64/gen/Makefile.inc @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile.inc,v 1.3 2005/11/29 21:38:09 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.4 2008/07/24 09:31:06 martynas Exp $ -SRCS+= _setjmp.S fabs.S infinity.c isinf.S ldexp.S modf.S +SRCS+= _setjmp.S fabs.S infinity.c isinf.S isnan.S ldexp.S modf.S nan.c SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ fpsetround.c fpsetsticky.c SRCS+= setjmp.S sigsetjmp.S diff --git a/lib/libc/arch/mips64/gen/isinf.S b/lib/libc/arch/mips64/gen/isinf.S index 26a347b9c7a..5e5321406f0 100644 --- a/lib/libc/arch/mips64/gen/isinf.S +++ b/lib/libc/arch/mips64/gen/isinf.S @@ -1,4 +1,4 @@ -/* $OpenBSD: isinf.S,v 1.4 2005/08/07 16:40:15 espie Exp $ */ +/* $OpenBSD: isinf.S,v 1.5 2008/07/24 09:31:06 martynas Exp $ */ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. @@ -36,35 +36,12 @@ #define DEXP_INF 0x7ff /* - * isnan(x) - * double x; - * - * Return true if x is a NAN. - */ -LEAF(isnan, 0) - .set noreorder - dmfc1 t3, $f12 # get x - dsll t1, t3, 1 # get x exponent - dsrl t1, t1, 64 - 11 - bne t1, DEXP_INF, 1f # is it a finite number? - sll t2, t3, 64 - 52 # get x fraction - beq t2, zero, 1f # its infinity - nop - - j ra - li v0, 1 # x is a NAN -1: - j ra - move v0, zero # x is NOT a NAN -END(isnan) - -/* - * isinf(x) - * double x; + * int + * __isinf(double x) * * Return true if x is infinity. */ -LEAF(isinf, 0) +LEAF(__isinf, 0) .set noreorder dmfc1 t3, $f12 # get LSW of x dsll t1, t3, 1 # get x exponent @@ -78,4 +55,4 @@ LEAF(isinf, 0) 1: j ra move v0, zero # x is NOT infinity -END(isinf) +END(__isinf) diff --git a/lib/libc/arch/mips64/gen/isnan.S b/lib/libc/arch/mips64/gen/isnan.S new file mode 100644 index 00000000000..12487675cbe --- /dev/null +++ b/lib/libc/arch/mips64/gen/isnan.S @@ -0,0 +1,59 @@ +/* $OpenBSD: isnan.S,v 1.1 2008/07/24 09:31:06 martynas Exp $ */ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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 + +#define DEXP_INF 0x7ff + +/* + * int + * __isnan(double x) + * + * Return true if x is a NAN. + */ +LEAF(__isnan, 0) + .set noreorder + dmfc1 t3, $f12 # get x + dsll t1, t3, 1 # get x exponent + dsrl t1, t1, 64 - 11 + bne t1, DEXP_INF, 1f # is it a finite number? + sll t2, t3, 64 - 52 # get x fraction + beq t2, zero, 1f # its infinity + nop + + j ra + li v0, 1 # x is a NAN +1: + j ra + move v0, zero # x is NOT a NAN +END(__isnan) diff --git a/lib/libc/arch/mips64/gen/nan.c b/lib/libc/arch/mips64/gen/nan.c new file mode 100644 index 00000000000..62f2e1ad916 --- /dev/null +++ b/lib/libc/arch/mips64/gen/nan.c @@ -0,0 +1,15 @@ +/* $OpenBSD: nan.c,v 1.1 2008/07/24 09:31:06 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include +#include +#include + +/* bytes for qNaN on a mips64 (IEEE single format) */ +char __nan[] __attribute__((__aligned__(sizeof(float)))) = +#if BYTE_ORDER == BIG_ENDIAN + { 0x7f, 0xa0, 0, 0 }; +#else /* BYTE_ORDER == BIG_ENDIAN */ + { 0, 0, 0xa0, 0x7f }; +#endif /* BYTE_ORDER == BIG_ENDIAN */ diff --git a/lib/libc/arch/powerpc/gen/Makefile.inc b/lib/libc/arch/powerpc/gen/Makefile.inc index 67ab0d1377e..183826e016c 100644 --- a/lib/libc/arch/powerpc/gen/Makefile.inc +++ b/lib/libc/arch/powerpc/gen/Makefile.inc @@ -1,4 +1,4 @@ -SRCS+= isinf.c isnan.c infinity.c setjmp.S sigsetjmp.S flt_rounds.c modf.c +SRCS+= infinity.c setjmp.S sigsetjmp.S flt_rounds.c modf.c nan.c SRCS+= ldexp.c fabs.c SRCS+= fpgetmask.c fpsetmask.c SRCS+= fpgetround.c fpsetround.c diff --git a/lib/libc/arch/powerpc/gen/isinf.c b/lib/libc/arch/powerpc/gen/isinf.c deleted file mode 100644 index 5d909e25b64..00000000000 --- a/lib/libc/arch/powerpc/gen/isinf.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isinf.c,v 1.6 2005/08/07 16:40:15 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isinf(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - p->dbl_frach == 0 && p->dbl_fracl == 0); -} diff --git a/lib/libc/arch/powerpc/gen/isnan.c b/lib/libc/arch/powerpc/gen/isnan.c deleted file mode 100644 index ac8c066c4d3..00000000000 --- a/lib/libc/arch/powerpc/gen/isnan.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isnan.c,v 1.3 2005/08/07 16:40:15 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isnan(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - (p->dbl_frach != 0 || p->dbl_fracl != 0)); -} diff --git a/lib/libc/arch/powerpc/gen/nan.c b/lib/libc/arch/powerpc/gen/nan.c new file mode 100644 index 00000000000..26c10319f9b --- /dev/null +++ b/lib/libc/arch/powerpc/gen/nan.c @@ -0,0 +1,9 @@ +/* $OpenBSD: nan.c,v 1.1 2008/07/24 09:31:06 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include + +/* bytes for qNaN on a powerpc (IEEE single format) */ +char __nan[] __attribute__((__aligned__(sizeof(float)))) = + { 0x7f, 0xc0, 0, 0 }; diff --git a/lib/libc/arch/sh/gen/Makefile.inc b/lib/libc/arch/sh/gen/Makefile.inc index 8616cd7fff9..393c2fa35c1 100644 --- a/lib/libc/arch/sh/gen/Makefile.inc +++ b/lib/libc/arch/sh/gen/Makefile.inc @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile.inc,v 1.5 2007/03/02 06:11:54 miod Exp $ +# $OpenBSD: Makefile.inc,v 1.6 2008/07/24 09:31:06 martynas Exp $ -SRCS+= flt_rounds.c isinf.c isnan.c infinity.c setjmp.S _setjmp.S sigsetjmp.S \ +SRCS+= flt_rounds.c infinity.c nan.c setjmp.S _setjmp.S sigsetjmp.S \ modf.c ldexp.c SRCS+= fabs.c fpgetmask.c fpgetround.c fpgetsticky.c \ diff --git a/lib/libc/arch/sh/gen/isinf.c b/lib/libc/arch/sh/gen/isinf.c deleted file mode 100644 index 71654ea860b..00000000000 --- a/lib/libc/arch/sh/gen/isinf.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isinf.c,v 1.1.1.1 2006/10/10 22:07:10 miod Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isinf(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - p->dbl_frach == 0 && p->dbl_fracl == 0); -} diff --git a/lib/libc/arch/sh/gen/isnan.c b/lib/libc/arch/sh/gen/isnan.c deleted file mode 100644 index c4ac8dc077d..00000000000 --- a/lib/libc/arch/sh/gen/isnan.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isnan.c,v 1.1.1.1 2006/10/10 22:07:10 miod Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isnan(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - (p->dbl_frach != 0 || p->dbl_fracl != 0)); -} diff --git a/lib/libc/arch/sh/gen/nan.c b/lib/libc/arch/sh/gen/nan.c new file mode 100644 index 00000000000..c7a2be8ba66 --- /dev/null +++ b/lib/libc/arch/sh/gen/nan.c @@ -0,0 +1,15 @@ +/* $OpenBSD: nan.c,v 1.1 2008/07/24 09:31:06 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include +#include +#include + +/* bytes for qNaN on a sh (IEEE single format) */ +char __nan[] __attribute__((__aligned__(sizeof(float)))) = +#if BYTE_ORDER == BIG_ENDIAN + { 0x7f, 0xa0, 0, 0 }; +#else /* BYTE_ORDER == BIG_ENDIAN */ + { 0, 0, 0xa0, 0x7f }; +#endif /* BYTE_ORDER == BIG_ENDIAN */ diff --git a/lib/libc/arch/sparc/gen/Makefile.inc b/lib/libc/arch/sparc/gen/Makefile.inc index 3fc0ad70ded..85710859f3b 100644 --- a/lib/libc/arch/sparc/gen/Makefile.inc +++ b/lib/libc/arch/sparc/gen/Makefile.inc @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile.inc,v 1.5 2005/11/29 21:38:10 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.6 2008/07/24 09:31:06 martynas Exp $ -SRCS+= _setjmp.S fabs.S infinity.c isinf.c isnan.c ldexp.c modf.S +SRCS+= _setjmp.S fabs.S infinity.c ldexp.c modf.S nan.c SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ fpsetround.c fpsetsticky.c SRCS+= fixunsdfsi.S mul.S umul.S saveregs.S setjmp.S sigsetjmp.S diff --git a/lib/libc/arch/sparc/gen/isinf.c b/lib/libc/arch/sparc/gen/isinf.c deleted file mode 100644 index 5d909e25b64..00000000000 --- a/lib/libc/arch/sparc/gen/isinf.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isinf.c,v 1.6 2005/08/07 16:40:15 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isinf(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - p->dbl_frach == 0 && p->dbl_fracl == 0); -} diff --git a/lib/libc/arch/sparc/gen/isnan.c b/lib/libc/arch/sparc/gen/isnan.c deleted file mode 100644 index 1ca3f1c5b69..00000000000 --- a/lib/libc/arch/sparc/gen/isnan.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isnan.c,v 1.6 2005/08/07 16:40:15 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isnan(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - (p->dbl_frach != 0 || p->dbl_fracl != 0)); -} diff --git a/lib/libc/arch/sparc/gen/nan.c b/lib/libc/arch/sparc/gen/nan.c new file mode 100644 index 00000000000..28a6c300950 --- /dev/null +++ b/lib/libc/arch/sparc/gen/nan.c @@ -0,0 +1,9 @@ +/* $OpenBSD: nan.c,v 1.1 2008/07/24 09:31:06 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include + +/* bytes for qNaN on a sparc (IEEE single format) */ +char __nan[] __attribute__((__aligned__(sizeof(float)))) = + { 0x7f, 0xc0, 0, 0 }; diff --git a/lib/libc/arch/sparc64/gen/Makefile.inc b/lib/libc/arch/sparc64/gen/Makefile.inc index 6a23f1938c3..2fa31fd3071 100644 --- a/lib/libc/arch/sparc64/gen/Makefile.inc +++ b/lib/libc/arch/sparc64/gen/Makefile.inc @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile.inc,v 1.4 2005/11/29 21:38:10 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.5 2008/07/24 09:31:07 martynas Exp $ -SRCS+= _setjmp.S fabs.S infinity.c isinf.c isnan.c ldexp.c modf.S +SRCS+= _setjmp.S fabs.S infinity.c ldexp.c modf.S nan.c SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ fpsetround.c fpsetsticky.c SRCS+= fixunsdfsi.S mul.S umul.S saveregs.S setjmp.S sigsetjmp.S diff --git a/lib/libc/arch/sparc64/gen/isinf.c b/lib/libc/arch/sparc64/gen/isinf.c deleted file mode 100644 index f02d54ff8c0..00000000000 --- a/lib/libc/arch/sparc64/gen/isinf.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isinf.c,v 1.4 2005/08/07 16:40:15 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isinf(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - p->dbl_frach == 0 && p->dbl_fracl == 0); -} diff --git a/lib/libc/arch/sparc64/gen/isnan.c b/lib/libc/arch/sparc64/gen/isnan.c deleted file mode 100644 index 5817c710c52..00000000000 --- a/lib/libc/arch/sparc64/gen/isnan.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: isnan.c,v 1.4 2005/08/07 16:40:15 espie Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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 -#include - -int -isnan(d) - double d; -{ - struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - (p->dbl_frach != 0 || p->dbl_fracl != 0)); -} diff --git a/lib/libc/arch/sparc64/gen/nan.c b/lib/libc/arch/sparc64/gen/nan.c new file mode 100644 index 00000000000..2ed8560d7fb --- /dev/null +++ b/lib/libc/arch/sparc64/gen/nan.c @@ -0,0 +1,9 @@ +/* $OpenBSD: nan.c,v 1.1 2008/07/24 09:31:07 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include + +/* bytes for qNaN on a sparc64 (IEEE single format) */ +char __nan[] __attribute__((__aligned__(sizeof(float)))) = + { 0x7f, 0xc0, 0, 0 }; diff --git a/lib/libc/arch/vax/gen/Makefile.inc b/lib/libc/arch/vax/gen/Makefile.inc index 045740038a7..09a621fe65c 100644 --- a/lib/libc/arch/vax/gen/Makefile.inc +++ b/lib/libc/arch/vax/gen/Makefile.inc @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile.inc,v 1.5 2005/11/29 21:38:10 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.6 2008/07/24 09:31:07 martynas Exp $ -SRCS+= _setjmp.S fabs.S infinity.c isinf.c ldexp.S \ +SRCS+= _setjmp.S fabs.S infinity.c ldexp.S \ modf.S setjmp.S udiv.S urem.S sigsetjmp.S SRCS+= alloca.S diff --git a/lib/libc/arch/vax/gen/fpclassify.c b/lib/libc/arch/vax/gen/fpclassify.c new file mode 100644 index 00000000000..8c9e57d79e2 --- /dev/null +++ b/lib/libc/arch/vax/gen/fpclassify.c @@ -0,0 +1,43 @@ +/* $OpenBSD: fpclassify.c,v 1.1 2008/07/24 09:31:07 martynas Exp $ */ +/* + * Copyright (c) 2008 Martynas Venckus + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +int +__fpclassify(double d) +{ + struct vax_d_floating *p = (struct vax_d_floating *)&d; + + if (p->dflt_exp == 0) { + return FP_ZERO; + } + + return FP_NORMAL; +} + +int +__fpclassifyf(float f) +{ + struct vax_f_floating *p = (struct vax_f_floating *)&f; + + if (p->fflt_exp == 0) { + return FP_ZERO; + } + + return FP_NORMAL; +} diff --git a/lib/libc/arch/vax/gen/isfinite.c b/lib/libc/arch/vax/gen/isfinite.c new file mode 100644 index 00000000000..9e283e56e78 --- /dev/null +++ b/lib/libc/arch/vax/gen/isfinite.c @@ -0,0 +1,30 @@ +/* $OpenBSD: isfinite.c,v 1.1 2008/07/24 09:31:07 martynas Exp $ */ +/* + * Copyright (c) Martynas Venckus + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* ARGSUSED */ +int +__isfinite(double d) +{ + return(1); +} + +/* ARGSUSED */ +int +__isfinitef(float f) +{ + return(1); +} diff --git a/lib/libc/arch/vax/gen/isinf.c b/lib/libc/arch/vax/gen/isinf.c index 6f60b96b67f..c3a6cb7de54 100644 --- a/lib/libc/arch/vax/gen/isinf.c +++ b/lib/libc/arch/vax/gen/isinf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isinf.c,v 1.6 2005/08/07 16:40:15 espie Exp $ */ +/* $OpenBSD: isinf.c,v 1.7 2008/07/24 09:31:07 martynas Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -31,16 +31,14 @@ /* ARGSUSED */ int -isnan(d) - double d; +__isinf(double d) { return(0); } /* ARGSUSED */ int -isinf(d) - double d; +isinff(float f) { return(0); } diff --git a/lib/libc/arch/vax/gen/isnan.c b/lib/libc/arch/vax/gen/isnan.c new file mode 100644 index 00000000000..7a6450081a1 --- /dev/null +++ b/lib/libc/arch/vax/gen/isnan.c @@ -0,0 +1,30 @@ +/* $OpenBSD: isnan.c,v 1.1 2008/07/24 09:31:07 martynas Exp $ */ +/* + * Copyright (c) Martynas Venckus + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* ARGSUSED */ +int +__isnan(double d) +{ + return(0); +} + +/* ARGSUSED */ +int +isnanf(float f) +{ + return(0); +} diff --git a/lib/libc/arch/vax/gen/isnormal.c b/lib/libc/arch/vax/gen/isnormal.c new file mode 100644 index 00000000000..0e119d7de30 --- /dev/null +++ b/lib/libc/arch/vax/gen/isnormal.c @@ -0,0 +1,34 @@ +/* $OpenBSD: isnormal.c,v 1.1 2008/07/24 09:31:07 martynas Exp $ */ +/* + * Copyright (c) 2008 Martynas Venckus + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +int +__isnormal(double d) +{ + struct vax_d_floating *p = (struct vax_d_floating *)&d; + + return (p->dflt_exp != 0); +} + +int +__isnormalf(float f) +{ + struct vax_f_floating *p = (struct vax_f_floating *)&f; + + return (p->fflt_exp != 0); +} diff --git a/lib/libc/arch/vax/gen/signbit.c b/lib/libc/arch/vax/gen/signbit.c new file mode 100644 index 00000000000..9b31a7428a8 --- /dev/null +++ b/lib/libc/arch/vax/gen/signbit.c @@ -0,0 +1,34 @@ +/* $OpenBSD: signbit.c,v 1.1 2008/07/24 09:31:07 martynas Exp $ */ +/* + * Copyright (c) 2008 Martynas Venckus + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +int +__signbit(double d) +{ + struct vax_d_floating *p = (struct vax_d_floating *)&d; + + return p->dflt_sign; +} + +int +__signbitf(float f) +{ + struct vax_f_floating *p = (struct vax_f_floating *)&f; + + return p->fflt_sign; +} diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index e60c1bd8f2f..5c52fa86a42 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.41 2008/06/24 14:27:24 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.42 2008/07/24 09:31:07 martynas Exp $ # gen sources .PATH: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/gen ${LIBCSRCDIR}/gen @@ -6,12 +6,13 @@ SRCS+= alarm.c assert.c auth_subr.c authenticate.c \ basename.c clock.c closedir.c confstr.c ctermid.c ctype_.c \ daemon.c devname.c dirname.c disklabel.c elf_hash.c err.c \ - errx.c errlist.c errno.c exec.c fnmatch.c frexp.c fstab.c ftok.c \ - fts.c ftw.c getbsize.c getcap.c getcwd.c getdomainname.c \ - getgrent.c getgrouplist.c gethostname.c getloadavg.c \ - getlogin.c getmntinfo.c getnetgrent.c getpagesize.c getpwent.c \ - getttyent.c getusershell.c glob.c initgroups.c isatty.c \ - isctype.c isfdtype.c lockf.c login_cap.c nice.c nlist.c \ + errx.c errlist.c errno.c exec.c fnmatch.c fpclassify.c frexp.c \ + fstab.c ftok.c fts.c ftw.c getbsize.c getcap.c getcwd.c \ + getdomainname.c getgrent.c getgrouplist.c gethostname.c \ + getloadavg.c getlogin.c getmntinfo.c getnetgrent.c getpagesize.c \ + getpwent.c getttyent.c getusershell.c glob.c initgroups.c \ + isatty.c isctype.c isfdtype.c isfinite.c isinf.c isnan.c \ + isnormal.c signbit.c lockf.c login_cap.c nice.c nlist.c \ nftw.c opendir.c pause.c popen.c psignal.c pw_dup.c pwcache.c \ raise.c readdir.c readpassphrase.c rewinddir.c scandir.c \ seekdir.c setdomainname.c sethostname.c setjmperr.c setmode.c \ @@ -27,7 +28,7 @@ SRCS+= _sys_errlist.c _sys_nerr.c _sys_siglist.c # machine-dependent gen sources # m-d Makefile.inc must include sources for: -# _setjmp() fabs() frexp() infinity isinf() ldexp() modf() +# _setjmp() fabs() frexp() infinity ldexp() modf() nan # setjmp() sigsetjmp() .include "${LIBCSRCDIR}/arch/${MACHINE_ARCH}/gen/Makefile.inc" diff --git a/lib/libc/gen/fpclassify.c b/lib/libc/gen/fpclassify.c new file mode 100644 index 00000000000..f126935961f --- /dev/null +++ b/lib/libc/gen/fpclassify.c @@ -0,0 +1,90 @@ +/* $OpenBSD: fpclassify.c,v 1.1 2008/07/24 09:31:07 martynas Exp $ */ +/* + * Copyright (c) 2008 Martynas Venckus + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include + +int +__fpclassify(double d) +{ + struct ieee_double *p = (struct ieee_double *)&d; + + if (p->dbl_exp == 0) { + if (p->dbl_frach == 0 && p->dbl_fracl == 0) + return FP_ZERO; + else + return FP_SUBNORMAL; + } + + if (p->dbl_exp == DBL_EXP_INFNAN) { + if (p->dbl_frach == 0 && p->dbl_fracl == 0) + return FP_INFINITE; + else + return FP_NAN; + } + + return FP_NORMAL; +} + +int +__fpclassifyf(float f) +{ + struct ieee_single *p = (struct ieee_single *)&f; + + if (p->sng_exp == 0) { + if (p->sng_frac == 0) + return FP_ZERO; + else + return FP_SUBNORMAL; + } + + if (p->sng_exp == SNG_EXP_INFNAN) { + if (p->sng_frac == 0) + return FP_INFINITE; + else + return FP_NAN; + } + + return FP_NORMAL; +} + +#if 0 /* XXX */ +int +__fpclassifyl(long double e) +{ + struct ieee_ext *p = (struct ieee_ext *)&e; + + if (p->ext_exp == 0) { + if (p->ext_frach == 0 && p->ext_fracl == 0) + return FP_ZERO; + else + return FP_SUBNORMAL; + } + + p->ext_frach &= ~0x80000000; /* clear sign bit */ + + if (p->ext_exp == EXT_EXP_INFNAN) { + if (p->ext_frach == 0 && p->ext_fracl == 0) + return FP_INFINITE; + else + return FP_NAN; + } + + return FP_NORMAL; +} +#endif /* XXX */ diff --git a/lib/libc/gen/isfinite.c b/lib/libc/gen/isfinite.c new file mode 100644 index 00000000000..0af06c60696 --- /dev/null +++ b/lib/libc/gen/isfinite.c @@ -0,0 +1,45 @@ +/* $OpenBSD: isfinite.c,v 1.1 2008/07/24 09:31:07 martynas Exp $ */ +/* + * Copyright (c) 2008 Martynas Venckus + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +int +__isfinite(double d) +{ + struct ieee_double *p = (struct ieee_double *)&d; + + return (p->dbl_exp != DBL_EXP_INFNAN); +} + +int +__isfinitef(float f) +{ + struct ieee_single *p = (struct ieee_single *)&f; + + return (p->sng_exp != SNG_EXP_INFNAN); +} + +#if 0 /* XXX */ +int +__isfinitel(long double e) +{ + struct ieee_ext *p = (struct ieee_ext *)&e; + + return (p->ext_exp != EXT_EXP_INFNAN); +} +#endif /* XXX */ diff --git a/lib/libc/gen/isinf.c b/lib/libc/gen/isinf.c new file mode 100644 index 00000000000..f8dae2a5402 --- /dev/null +++ b/lib/libc/gen/isinf.c @@ -0,0 +1,49 @@ +/* $OpenBSD: isinf.c,v 1.1 2008/07/24 09:31:07 martynas Exp $ */ +/* + * Copyright (c) 2008 Martynas Venckus + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +int +__isinf(double d) +{ + struct ieee_double *p = (struct ieee_double *)&d; + + return (p->dbl_exp == DBL_EXP_INFNAN && + p->dbl_frach == 0 && p->dbl_fracl == 0); +} + +int +isinff(float f) +{ + struct ieee_single *p = (struct ieee_single *)&f; + + return (p->sng_exp == SNG_EXP_INFNAN && p->sng_frac == 0); +} + +#if 0 /* XXX */ +int +__isinfl(long double e) +{ + struct ieee_ext *p = (struct ieee_ext *)&e; + + p->ext_frach &= ~0x80000000; /* clear sign bit */ + + return (p->ext_exp == EXT_EXP_INFNAN && + p->ext_frach == 0 && p->ext_fracl == 0); +} +#endif /* XXX */ diff --git a/lib/libc/gen/isnan.c b/lib/libc/gen/isnan.c new file mode 100644 index 00000000000..29566c812b7 --- /dev/null +++ b/lib/libc/gen/isnan.c @@ -0,0 +1,49 @@ +/* $OpenBSD: isnan.c,v 1.1 2008/07/24 09:31:07 martynas Exp $ */ +/* + * Copyright (c) 2008 Martynas Venckus + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +int +__isnan(double d) +{ + struct ieee_double *p = (struct ieee_double *)&d; + + return (p->dbl_exp == DBL_EXP_INFNAN && + (p->dbl_frach != 0 || p->dbl_fracl != 0)); +} + +int +isnanf(float f) +{ + struct ieee_single *p = (struct ieee_single *)&f; + + return (p->sng_exp == SNG_EXP_INFNAN && p->sng_frac != 0); +} + +#if 0 /* XXX */ +int +__isnanl(long double e) +{ + struct ieee_ext *p = (struct ieee_ext *)&e; + + p->ext_frach &= ~0x80000000; /* clear sign bit */ + + return (p->ext_exp == EXT_EXP_INFNAN && + (p->ext_frach != 0 || p->ext_fracl != 0)); +} +#endif /* XXX */ diff --git a/lib/libc/gen/isnormal.c b/lib/libc/gen/isnormal.c new file mode 100644 index 00000000000..e35bddc2c35 --- /dev/null +++ b/lib/libc/gen/isnormal.c @@ -0,0 +1,45 @@ +/* $OpenBSD: isnormal.c,v 1.1 2008/07/24 09:31:07 martynas Exp $ */ +/* + * Copyright (c) 2008 Martynas Venckus + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +int +__isnormal(double d) +{ + struct ieee_double *p = (struct ieee_double *)&d; + + return (p->dbl_exp != 0 && p->dbl_exp != DBL_EXP_INFNAN); +} + +int +__isnormalf(float f) +{ + struct ieee_single *p = (struct ieee_single *)&f; + + return (p->sng_exp != 0 && p->sng_exp != SNG_EXP_INFNAN); +} + +#if 0 /* XXX */ +int +__isnormall(long double e) +{ + struct ieee_ext *p = (struct ieee_ext *)&e; + + return (p->ext_exp != 0 && p->ext_exp != EXT_EXP_INFNAN); +} +#endif /* XXX */ diff --git a/lib/libc/gen/signbit.c b/lib/libc/gen/signbit.c new file mode 100644 index 00000000000..426362c8288 --- /dev/null +++ b/lib/libc/gen/signbit.c @@ -0,0 +1,45 @@ +/* $OpenBSD: signbit.c,v 1.1 2008/07/24 09:31:07 martynas Exp $ */ +/* + * Copyright (c) 2008 Martynas Venckus + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +int +__signbit(double d) +{ + struct ieee_double *p = (struct ieee_double *)&d; + + return p->dbl_sign; +} + +int +__signbitf(float f) +{ + struct ieee_single *p = (struct ieee_single *)&f; + + return p->sng_sign; +} + +#if 0 /* XXX */ +int +__signbitl(long double e) +{ + struct ieee_ext *p = (struct ieee_ext *)&e; + + return p->ext_sign; +} +#endif /* XXX */ diff --git a/lib/libc/shlib_version b/lib/libc/shlib_version index f810fc908fe..3352bf6bc12 100644 --- a/lib/libc/shlib_version +++ b/lib/libc/shlib_version @@ -1,4 +1,4 @@ -major=47 +major=48 minor=0 # note: If changes were made to include/thread_private.h or if system # calls were added/changed then libpthread must also be updated.