Index: head/lib/libc/powerpcspe/gen/fpgetmask.c =================================================================== --- head/lib/libc/powerpcspe/gen/fpgetmask.c (revision 336687) +++ head/lib/libc/powerpcspe/gen/fpgetmask.c (revision 336688) @@ -1,49 +1,49 @@ /* $NetBSD: fpgetmask.c,v 1.3 2002/01/13 21:45:47 thorpej Exp $ */ /* * Copyright (c) 2016 Justin Hibbits * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Dan Winship. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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 __FBSDID("$FreeBSD$"); #include #include #include #ifndef _SOFT_FLOAT fp_except_t fpgetmask() { uint32_t fpscr; __asm__ __volatile("mfspr %0, %1" : "=r"(fpscr) : "K"(SPR_SPEFSCR)); - return ((fp_except_t)((fpscr >> 3) & 0x1f)); + return ((fp_except_t)((fpscr >> 2) & 0x1f)); } #endif Index: head/lib/libc/powerpcspe/gen/fpsetmask.c =================================================================== --- head/lib/libc/powerpcspe/gen/fpsetmask.c (revision 336687) +++ head/lib/libc/powerpcspe/gen/fpsetmask.c (revision 336688) @@ -1,53 +1,53 @@ /* $NetBSD: fpsetmask.c,v 1.3 2002/01/13 21:45:48 thorpej Exp $ */ /* * Copyright (c) 2016 Justin Hibbits * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Dan Winship. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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 __FBSDID("$FreeBSD$"); #include #include #include #ifndef _SOFT_FLOAT fp_except_t fpsetmask(fp_except_t mask) { uint32_t fpscr; fp_rnd_t old; __asm__ __volatile("mfspr %0, %1" : "=r"(fpscr) : "K"(SPR_SPEFSCR)); - old = (fp_rnd_t)((fpscr >> 3) & 0x1f); - fpscr = (fpscr & 0xffffff07) | (mask << 3); + old = (fp_rnd_t)((fpscr >> 2) & 0x1f); + fpscr = (fpscr & 0xffffff83) | (mask << 2); __asm__ __volatile("mtspr %1,%0" :: "r"(fpscr), "K"(SPR_SPEFSCR)); return (old); } #endif Index: head/sys/powerpc/include/ieeefp.h =================================================================== --- head/sys/powerpc/include/ieeefp.h (revision 336687) +++ head/sys/powerpc/include/ieeefp.h (revision 336688) @@ -1,35 +1,43 @@ /* - * Written by J.T. Conklin, Apr 6, 1995 * Public domain. * $NetBSD: ieeefp.h,v 1.2 1999/07/07 01:52:26 danw Exp $ * $FreeBSD$ */ #ifndef _MACHINE_IEEEFP_H_ #define _MACHINE_IEEEFP_H_ /* Deprecated historical FPU control interface */ typedef int fp_except_t; +#ifdef __SPE__ +#define FP_X_OFL 0x01 /* overflow exception */ +#define FP_X_UFL 0x02 /* underflow exception */ +#define FP_X_DZ 0x04 /* divide-by-zero exception */ +#define FP_X_INV 0x08 /* invalid operation exception */ +#define FP_X_IMP 0x10 /* imprecise (loss of precision) */ +#else #define FP_X_IMP 0x01 /* imprecise (loss of precision) */ #define FP_X_DZ 0x02 /* divide-by-zero exception */ #define FP_X_UFL 0x04 /* underflow exception */ #define FP_X_OFL 0x08 /* overflow exception */ #define FP_X_INV 0x10 /* invalid operation exception */ +#endif typedef enum { FP_RN=0, /* round to nearest representable number */ FP_RZ=1, /* round to zero (truncate) */ FP_RP=2, /* round toward positive infinity */ FP_RM=3 /* round toward negative infinity */ } fp_rnd_t; __BEGIN_DECLS extern fp_rnd_t fpgetround(void); extern fp_rnd_t fpsetround(fp_rnd_t); extern fp_except_t fpgetmask(void); extern fp_except_t fpsetmask(fp_except_t); extern fp_except_t fpgetsticky(void); __END_DECLS #endif /* _MACHINE_IEEEFP_H_ */