ports/lang/flang/libpgmath/patches/patch-lib_common_fltfenv_c

83 lines
1.5 KiB
Text
Raw Normal View History

2023-08-16 22:26:55 +00:00
Work around glibc stuff (use standard functions for this stuff)
Index: lib/common/fltfenv.c
--- lib/common/fltfenv.c.orig
+++ lib/common/fltfenv.c
@@ -560,7 +560,7 @@ __fenv_feupdateenv(fenv_t *env)
* __fenv_mask_fz() and __fenv_restore_fz().
*/
-#include <fpu_control.h>
+#include <fenv.h>
/** \brief Set (flush to zero) underflow mode
*
@@ -570,14 +570,14 @@ __fenv_feupdateenv(fenv_t *env)
int
__fenv_fesetzerodenorm(int uflow)
{
- uint64_t cw;
+ fenv_t cw;
- _FPU_GETCW(cw);
+ fegetenv(&cw);
if (uflow)
cw |= (1ULL << 24);
else
cw &= ~(1ULL << 24);
- _FPU_SETCW(cw);
+ fesetenv(&cw);
return 0;
}
@@ -588,9 +588,9 @@ __fenv_fesetzerodenorm(int uflow)
int
__fenv_fegetzerodenorm(void)
{
- uint64_t cw;
+ fenv_t cw;
- _FPU_GETCW(cw);
+ fegetenv(&cw);
return (cw & (1ULL << 24)) ? 1 : 0;
}
@@ -605,16 +605,16 @@ __fenv_fegetzerodenorm(void)
void
__fenv_mask_fz(int mask, int *psv)
{
- uint64_t tmp;
+ fenv_t tmp;
- _FPU_GETCW(tmp);
+ fegetenv(&tmp);
if (psv)
*psv = ((tmp & (1ULL << 24)) ? 1 : 0);
if (mask)
tmp |= (1ULL << 24);
else
tmp &= ~(1ULL << 24);
- _FPU_SETCW(tmp);
+ fesetenv(&tmp);
}
/** \brief
@@ -623,14 +623,14 @@ __fenv_mask_fz(int mask, int *psv)
void
__fenv_restore_fz(int sv)
{
- uint64_t tmp;
+ fenv_t tmp;
- _FPU_GETCW(tmp);
+ fegetenv(&tmp);
if (sv)
tmp |= (1ULL << 24);
else
tmp &= ~(1ULL << 24);
- _FPU_SETCW(tmp);
+ fesetenv(&tmp);
}
#else