Files
packages/core/glibc/glibc-sfp-handle-exceptions-fix.patch
T
2026-03-21 12:43:00 -05:00

155 lines
5.1 KiB
Diff

--- a/sysdeps/x86/fpu/sfp-machine.h
+++ b/sysdeps/x86/fpu/sfp-machine.h
@@ -2,6 +2,7 @@
libgcc, with soft-float and other irrelevant parts removed. */
#include <math-inline-asm.h>
+#include <fenv.h>
#if HAVE_X86_LIBGCC_CMP_RETURN_ATTR
/* The type of the result of a floating point comparison. This must
@@ -65,76 +66,82 @@
# define _FP_WS_TYPE signed long int
# define _FP_I_TYPE long int
+# ifdef __clang__
+# define __SFP_REG(x) (x)
+# else
+# define __SFP_REG(x) ((USItype) (x))
+# endif
+
# define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \
__asm__ ("add{l} {%11,%3|%3,%11}\n\t" \
"adc{l} {%9,%2|%2,%9}\n\t" \
"adc{l} {%7,%1|%1,%7}\n\t" \
"adc{l} {%5,%0|%0,%5}" \
- : "=r" ((USItype) (r3)), \
- "=&r" ((USItype) (r2)), \
- "=&r" ((USItype) (r1)), \
- "=&r" ((USItype) (r0)) \
- : "%0" ((USItype) (x3)), \
- "g" ((USItype) (y3)), \
- "%1" ((USItype) (x2)), \
- "g" ((USItype) (y2)), \
- "%2" ((USItype) (x1)), \
- "g" ((USItype) (y1)), \
- "%3" ((USItype) (x0)), \
- "g" ((USItype) (y0)))
+ : "=r" (__SFP_REG (r3)), \
+ "=&r" (__SFP_REG (r2)), \
+ "=&r" (__SFP_REG (r1)), \
+ "=&r" (__SFP_REG (r0)) \
+ : "%0" (__SFP_REG (x3)), \
+ "g" (__SFP_REG (y3)), \
+ "%1" (__SFP_REG (x2)), \
+ "g" (__SFP_REG (y2)), \
+ "%2" (__SFP_REG (x1)), \
+ "g" (__SFP_REG (y1)), \
+ "%3" (__SFP_REG (x0)), \
+ "g" (__SFP_REG (y0)))
# define __FP_FRAC_ADD_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) \
__asm__ ("add{l} {%8,%2|%2,%8}\n\t" \
"adc{l} {%6,%1|%1,%6}\n\t" \
"adc{l} {%4,%0|%0,%4}" \
- : "=r" ((USItype) (r2)), \
- "=&r" ((USItype) (r1)), \
- "=&r" ((USItype) (r0)) \
- : "%0" ((USItype) (x2)), \
- "g" ((USItype) (y2)), \
- "%1" ((USItype) (x1)), \
- "g" ((USItype) (y1)), \
- "%2" ((USItype) (x0)), \
- "g" ((USItype) (y0)))
+ : "=r" (__SFP_REG (r2)), \
+ "=&r" (__SFP_REG (r1)), \
+ "=&r" (__SFP_REG (r0)) \
+ : "%0" (__SFP_REG (x2)), \
+ "g" (__SFP_REG (y2)), \
+ "%1" (__SFP_REG (x1)), \
+ "g" (__SFP_REG (y1)), \
+ "%2" (__SFP_REG (x0)), \
+ "g" (__SFP_REG (y0)))
# define __FP_FRAC_SUB_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \
__asm__ ("sub{l} {%11,%3|%3,%11}\n\t" \
"sbb{l} {%9,%2|%2,%9}\n\t" \
"sbb{l} {%7,%1|%1,%7}\n\t" \
"sbb{l} {%5,%0|%0,%5}" \
- : "=r" ((USItype) (r3)), \
- "=&r" ((USItype) (r2)), \
- "=&r" ((USItype) (r1)), \
- "=&r" ((USItype) (r0)) \
- : "0" ((USItype) (x3)), \
- "g" ((USItype) (y3)), \
- "1" ((USItype) (x2)), \
- "g" ((USItype) (y2)), \
- "2" ((USItype) (x1)), \
- "g" ((USItype) (y1)), \
- "3" ((USItype) (x0)), \
- "g" ((USItype) (y0)))
+ : "=r" (__SFP_REG (r3)), \
+ "=&r" (__SFP_REG (r2)), \
+ "=&r" (__SFP_REG (r1)), \
+ "=&r" (__SFP_REG (r0)) \
+ : "0" (__SFP_REG (x3)), \
+ "g" (__SFP_REG (y3)), \
+ "1" (__SFP_REG (x2)), \
+ "g" (__SFP_REG (y2)), \
+ "2" (__SFP_REG (x1)), \
+ "g" (__SFP_REG (y1)), \
+ "3" (__SFP_REG (x0)), \
+ "g" (__SFP_REG (y0)))
# define __FP_FRAC_SUB_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) \
__asm__ ("sub{l} {%8,%2|%2,%8}\n\t" \
"sbb{l} {%6,%1|%1,%6}\n\t" \
"sbb{l} {%4,%0|%0,%4}" \
- : "=r" ((USItype) (r2)), \
- "=&r" ((USItype) (r1)), \
- "=&r" ((USItype) (r0)) \
- : "0" ((USItype) (x2)), \
- "g" ((USItype) (y2)), \
- "1" ((USItype) (x1)), \
- "g" ((USItype) (y1)), \
- "2" ((USItype) (x0)), \
- "g" ((USItype) (y0)))
+ : "=r" (__SFP_REG (r2)), \
+ "=&r" (__SFP_REG (r1)), \
+ "=&r" (__SFP_REG (r0)) \
+ : "0" (__SFP_REG (x2)), \
+ "g" (__SFP_REG (y2)), \
+ "1" (__SFP_REG (x1)), \
+ "g" (__SFP_REG (y1)), \
+ "2" (__SFP_REG (x0)), \
+ "g" (__SFP_REG (y0)))
# define __FP_FRAC_ADDI_4(x3,x2,x1,x0,i) \
__asm__ ("add{l} {%4,%3|%3,%4}\n\t" \
"adc{l} {$0,%2|%2,0}\n\t" \
"adc{l} {$0,%1|%1,0}\n\t" \
"adc{l} {$0,%0|%0,0}" \
- : "+r" ((USItype) (x3)), \
- "+&r" ((USItype) (x2)), \
- "+&r" ((USItype) (x1)), \
- "+&r" ((USItype) (x0)) \
- : "g" ((USItype) (i)))
+ : "+r" (__SFP_REG (x3)), \
+ "+&r" (__SFP_REG (x2)), \
+ "+&r" (__SFP_REG (x1)), \
+ "+&r" (__SFP_REG (x0)) \
+ : "g" (__SFP_REG (i)))
# define _FP_MUL_MEAT_S(R,X,Y) \
@@ -210,12 +217,10 @@
(FP_EX_INVALID | FP_EX_DENORM | FP_EX_DIVZERO | FP_EX_OVERFLOW \
| FP_EX_UNDERFLOW | FP_EX_INEXACT)
-void __sfp_handle_exceptions (int);
-
#define FP_HANDLE_EXCEPTIONS \
do { \
if (__builtin_expect (_fex, 0)) \
- __sfp_handle_exceptions (_fex); \
+ __feraiseexcept (_fex & FE_ALL_EXCEPT); \
} while (0);
#define FP_TRAPPING_EXCEPTIONS ((~_fcw >> FP_EX_SHIFT) & FP_EX_ALL)