diff --git a/lib/libc/powerpcspe/gen/fpgetmask.c b/lib/libc/powerpcspe/gen/fpgetmask.c index 3103e05ba41..d2314c65258 100644 --- a/lib/libc/powerpcspe/gen/fpgetmask.c +++ b/lib/libc/powerpcspe/gen/fpgetmask.c @@ -44,6 +44,6 @@ 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 diff --git a/lib/libc/powerpcspe/gen/fpsetmask.c b/lib/libc/powerpcspe/gen/fpsetmask.c index 24c0b3828b7..9763b78a091 100644 --- a/lib/libc/powerpcspe/gen/fpsetmask.c +++ b/lib/libc/powerpcspe/gen/fpsetmask.c @@ -45,8 +45,8 @@ fpsetmask(fp_except_t mask) 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); } diff --git a/sys/powerpc/include/ieeefp.h b/sys/powerpc/include/ieeefp.h index 58a4fe85a85..59816da8027 100644 --- a/sys/powerpc/include/ieeefp.h +++ b/sys/powerpc/include/ieeefp.h @@ -11,11 +11,19 @@ /* 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 */