Fix mandatory SSE in 2.1[56]ish glibc's feraiseexcept
From: Alexandre Oliva <aoliva@redhat.com>
for fixincludes/ChangeLog
* inclhack.def (feraiseexcept_nosse_invalid): New.
(feraiseexcept_nosse_divbyzero): Likewise.
* fixincl.x: Rebuilt.
* tests/base/bits/fenv.h: New.
---
fixincludes/fixincl.x | 130 ++++++++++++++++++++++++++++++++++--
fixincludes/inclhack.def | 49 ++++++++++++++
fixincludes/tests/base/bits/fenv.h | 29 ++++++++
3 files changed, 200 insertions(+), 8 deletions(-)
create mode 100644 fixincludes/tests/base/bits/fenv.h
@@ -4815,4 +4815,53 @@ fix = {
test_text = "extern char *\tsprintf();";
};
+/*
+ * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
+ * that fails when compiling for SSE-less 32-bit x86.
+ */
+fix = {
+ hackname = feraiseexcept_nosse_invalid;
+ mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
+ files = bits/fenv.h;
+ select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
+ ": \"x\" \\(__f\\)\\);$";
+ bypass = "\"fdiv .*; fwait\"";
+
+ c_fix = format;
+ c_fix_arg = <<- _EOText_
+ # ifdef __SSE_MATH__
+ %0
+ # else
+ %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
+ %1 : "=t" (__f) : "0" (__f));
+ # endif
+ _EOText_;
+
+ test_text = <<- _EOText_
+ __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
+ _EOText_;
+};
+fix = {
+ hackname = feraiseexcept_nosse_divbyzero;
+ mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
+ files = bits/fenv.h;
+ select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
+ ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
+ bypass = "\"fdivp .*; fwait\"";
+
+ c_fix = format;
+ c_fix_arg = <<- _EOText_
+ # ifdef __SSE_MATH__
+ %0
+ # else
+ %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
+ %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
+ # endif
+ _EOText_;
+
+ test_text = <<- _EOText_
+ __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
+ _EOText_;
+};
+
/*EOF*/
new file mode 100644
@@ -0,0 +1,29 @@
+/* DO NOT EDIT THIS FILE.
+
+ It has been auto-edited by fixincludes from:
+
+ "fixinc/tests/inc/bits/fenv.h"
+
+ This had to be done to correct non-standard usages in the
+ original, manufacturer supplied header file. */
+
+
+
+#if defined( FERAISEEXCEPT_NOSSE_INVALID_CHECK )
+# ifdef __SSE_MATH__
+ __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
+# else
+ __asm__ __volatile__ ("fdiv %%st, %%st(0); fwait"
+ : "=t" (__f) : "0" (__f));
+# endif
+#endif /* FERAISEEXCEPT_NOSSE_INVALID_CHECK */
+
+
+#if defined( FERAISEEXCEPT_NOSSE_DIVBYZERO_CHECK )
+# ifdef __SSE_MATH__
+ __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
+# else
+ __asm__ __volatile__ ("fdivp %%st, %%st(1); fwait"
+ : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
+# endif
+#endif /* FERAISEEXCEPT_NOSSE_DIVBYZERO_CHECK */