Skip to content

Commit 43d09ce

Browse files
committed
Resolve llvm#114. Or at least, resolve the part of it that Fil-C can be used to resolve.
1 parent 4ee8e6a commit 43d09ce

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

filc/include/pizlonated_math.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ long double zmath_nearbyintl(long double value);
6464
unsigned zmath_getcw(void);
6565
void zmath_setcw(unsigned cw);
6666
void zmath_feclearexcept(int excepts);
67+
int zmath_feenableexcept(int excepts);
6768

6869
#ifdef __cplusplus
6970
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
#define _GNU_SOURCE
2+
13
#include <fenv.h>
24

35
int main()
46
{
57
feclearexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW);
8+
#ifdef __USE_GNU
9+
feenableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
10+
#endif
611
return 0;
712
}
813

libpas/src/libpas/filc_runtime.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13173,6 +13173,18 @@ void filc_native_zmath_feclearexcept(filc_thread* my_thread, int excepts)
1317313173
PAS_ASSERT(!feclearexcept(excepts));
1317413174
}
1317513175

13176+
int filc_native_zmath_feenableexcept(filc_thread* my_thread, int excepts)
13177+
{
13178+
PAS_UNUSED_PARAM(my_thread);
13179+
#ifdef __USE_GNU
13180+
return feenableexcept(excepts);
13181+
#else
13182+
PAS_UNUSED_PARAM(excepts);
13183+
filc_internal_panic(NULL, "feenableexcept not implemented.");
13184+
return 0;
13185+
#endif
13186+
}
13187+
1317613188
#endif /* PAS_ENABLE_FILC */
1317713189

1317813190
#endif /* LIBPAS_ENABLED */

libpas/src/libpas/generate_pizlonated_forwarders.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ def addOutSig(name, rets, *args)
558558
addSig "unsigned", "zmath_getcw"
559559
addSig "void", "zmath_setcw", "unsigned"
560560
addSig "void", "zmath_feclearexcept", "int"
561+
addSig "int", "zmath_feenableexcept", "int"
561562

562563
addOutSig "void_ptr_ptr", "void", "filc_ptr", "filc_ptr"
563564
addOutSig "main", "exception/int", "int", "filc_ptr", "filc_ptr"

projects/user-glibc-2.40/sysdeps/x86_64/fpu/feenablxcpt.c

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,10 @@
1717
<https://www.gnu.org/licenses/>. */
1818

1919
#include <fenv.h>
20+
#include <pizlonated_math.h>
2021

2122
int
2223
feenableexcept (int excepts)
2324
{
24-
unsigned short int new_exc, old_exc;
25-
unsigned int new;
26-
27-
excepts &= FE_ALL_EXCEPT;
28-
29-
/* Get the current control word of the x87 FPU. */
30-
__asm__ ("fstcw %0" : "=m" (*&new_exc));
31-
32-
old_exc = (~new_exc) & FE_ALL_EXCEPT;
33-
34-
new_exc &= ~excepts;
35-
__asm__ ("fldcw %0" : : "m" (*&new_exc));
36-
37-
/* And now the same for the SSE MXCSR register. */
38-
__asm__ ("stmxcsr %0" : "=m" (*&new));
39-
40-
/* The SSE exception masks are shifted by 7 bits. */
41-
new &= ~(excepts << 7);
42-
__asm__ ("ldmxcsr %0" : : "m" (*&new));
43-
44-
return old_exc;
25+
return zmath_feenableexcept(excepts);
4526
}

0 commit comments

Comments
 (0)