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 | 39 +++++++++++
fixincludes/tests/base/bits/fenv.h | 29 ++++++++
3 files changed, 190 insertions(+), 8 deletions(-)
create mode 100644 fixincludes/tests/base/bits/fenv.h
@@ -2,11 +2,11 @@
*
* DO NOT EDIT THIS FILE (fixincl.x)
*
- * It has been AutoGen-ed October 28, 2012 at 02:53:25 PM by AutoGen 5.17.0pre5
+ * It has been AutoGen-ed Saturday December 29, 2012 at 09:17:09 AM BRST
* From the definitions inclhack.def
* and the template file fixincl
*/
-/* DO NOT SVN-MERGE THIS FILE, EITHER Sun Oct 28 14:53:25 PDT 2012
+/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Dec 29 09:17:10 BRST 2012
*
* You must regenerate it. Use the ./genfixes script.
*
@@ -15,7 +15,7 @@
* certain ANSI-incompatible system header files which are fixed to work
* correctly with ANSI C and placed in a directory that GNU C will search.
*
- * This file contains 224 fixup descriptions.
+ * This file contains 226 fixup descriptions.
*
* See README for more information.
*
@@ -9158,14 +9158,116 @@ static const char* apzX11_SprintfPatch[] = {
#endif /* !defined __STDC__ */",
(char*)NULL };
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ * Description of Feraiseexcept_Nosse_Invalid fix
+ */
+tSCC zFeraiseexcept_Nosse_InvalidName[] =
+ "feraiseexcept_nosse_invalid";
+
+/*
+ * File name selection pattern
+ */
+tSCC zFeraiseexcept_Nosse_InvalidList[] =
+ "bits/fenv.h\0";
+/*
+ * Machine/OS name selection pattern
+ */
+tSCC* apzFeraiseexcept_Nosse_InvalidMachs[] = {
+ "i[34567]86-*-linux*",
+ "x86*-linux*",
+ "amd64-*-linux*",
+ (const char*)NULL };
+
+/*
+ * content selection pattern - do fix if pattern found
+ */
+tSCC zFeraiseexcept_Nosse_InvalidSelect0[] =
+ "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : : \"x\" \\(__f\\)\\);$";
+
+/*
+ * content bypass pattern - skip fix if pattern found
+ */
+tSCC zFeraiseexcept_Nosse_InvalidBypass0[] =
+ "\"fdiv .*; fwait\"";
+
+#define FERAISEEXCEPT_NOSSE_INVALID_TEST_CT 2
+static tTestDesc aFeraiseexcept_Nosse_InvalidTests[] = {
+ { TT_NEGREP, zFeraiseexcept_Nosse_InvalidBypass0, (regex_t*)NULL },
+ { TT_EGREP, zFeraiseexcept_Nosse_InvalidSelect0, (regex_t*)NULL }, };
+
+/*
+ * Fix Command Arguments for Feraiseexcept_Nosse_Invalid
+ */
+static const char* apzFeraiseexcept_Nosse_InvalidPatch[] = {
+ "format",
+ "# ifdef __SSE_MATH__\n\
+%0\n\
+# else\n\
+%1__asm__ __volatile__ (\"fdiv %%%%st, %%%%st(0); fwait\"\n\
+%1\t\t\t: \"=t\" (__f) : \"0\" (__f));\n\
+# endif",
+ (char*)NULL };
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ * Description of Feraiseexcept_Nosse_Divbyzero fix
+ */
+tSCC zFeraiseexcept_Nosse_DivbyzeroName[] =
+ "feraiseexcept_nosse_divbyzero";
+
+/*
+ * File name selection pattern
+ */
+tSCC zFeraiseexcept_Nosse_DivbyzeroList[] =
+ "bits/fenv.h\0";
+/*
+ * Machine/OS name selection pattern
+ */
+tSCC* apzFeraiseexcept_Nosse_DivbyzeroMachs[] = {
+ "i[34567]86-*-linux*",
+ "x86*-linux*",
+ "amd64-*-linux*",
+ (const char*)NULL };
+
+/*
+ * content selection pattern - do fix if pattern found
+ */
+tSCC zFeraiseexcept_Nosse_DivbyzeroSelect0[] =
+ "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : : \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
+
+/*
+ * content bypass pattern - skip fix if pattern found
+ */
+tSCC zFeraiseexcept_Nosse_DivbyzeroBypass0[] =
+ "\"fdivp .*; fwait\"";
+
+#define FERAISEEXCEPT_NOSSE_DIVBYZERO_TEST_CT 2
+static tTestDesc aFeraiseexcept_Nosse_DivbyzeroTests[] = {
+ { TT_NEGREP, zFeraiseexcept_Nosse_DivbyzeroBypass0, (regex_t*)NULL },
+ { TT_EGREP, zFeraiseexcept_Nosse_DivbyzeroSelect0, (regex_t*)NULL }, };
+
+/*
+ * Fix Command Arguments for Feraiseexcept_Nosse_Divbyzero
+ */
+static const char* apzFeraiseexcept_Nosse_DivbyzeroPatch[] = {
+ "format",
+ "# ifdef __SSE_MATH__\n\
+%0\n\
+# else\n\
+%1__asm__ __volatile__ (\"fdivp %%%%st, %%%%st(1); fwait\"\n\
+%1\t\t\t: \"=t\" (__f) : \"0\" (__f), \"u\" (__g) : \"st(1)\");\n\
+# endif",
+ (char*)NULL };
+
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* List of all fixes
*/
-#define REGEX_COUNT 260
-#define MACH_LIST_SIZE_LIMIT 181
-#define FIX_COUNT 224
+#define REGEX_COUNT 264
+#define MACH_LIST_SIZE_LIMIT 187
+#define FIX_COUNT 226
/*
* Enumerate the fixes
@@ -9394,7 +9496,9 @@ typedef enum {
X11_CLASS_FIXIDX,
X11_CLASS_USAGE_FIXIDX,
X11_NEW_FIXIDX,
- X11_SPRINTF_FIXIDX
+ X11_SPRINTF_FIXIDX,
+ FERAISEEXCEPT_NOSSE_INVALID_FIXIDX,
+ FERAISEEXCEPT_NOSSE_DIVBYZERO_FIXIDX
} t_fixinc_idx;
tFixDesc fixDescList[ FIX_COUNT ] = {
@@ -10516,5 +10620,15 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
{ zX11_SprintfName, zX11_SprintfList,
apzX11_SprintfMachs,
X11_SPRINTF_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
- aX11_SprintfTests, apzX11_SprintfPatch, 0 }
+ aX11_SprintfTests, apzX11_SprintfPatch, 0 },
+
+ { zFeraiseexcept_Nosse_InvalidName, zFeraiseexcept_Nosse_InvalidList,
+ apzFeraiseexcept_Nosse_InvalidMachs,
+ FERAISEEXCEPT_NOSSE_INVALID_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+ aFeraiseexcept_Nosse_InvalidTests, apzFeraiseexcept_Nosse_InvalidPatch, 0 },
+
+ { zFeraiseexcept_Nosse_DivbyzeroName, zFeraiseexcept_Nosse_DivbyzeroList,
+ apzFeraiseexcept_Nosse_DivbyzeroMachs,
+ FERAISEEXCEPT_NOSSE_DIVBYZERO_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+ aFeraiseexcept_Nosse_DivbyzeroTests, apzFeraiseexcept_Nosse_DivbyzeroPatch, 0 }
};
@@ -4815,4 +4815,43 @@ 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 = "# ifdef __SSE_MATH__\n%0\n"
+ "# else\n%1__asm__ __volatile__ (\"fdiv %%%%st, %%%%st(0); fwait\"\n"
+ "%1\t\t\t: \"=t\" (__f) : \"0\" (__f));\n"
+ "# endif";
+
+ test_text = "\t __asm__ __volatile__ (\"divss %0, %0\" : "
+ ": \"x\" (__f));";
+};
+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 = "# ifdef __SSE_MATH__\n%0\n"
+ "# else\n%1__asm__ __volatile__ (\"fdivp %%%%st, %%%%st(1); fwait\"\n"
+ "%1\t\t\t: \"=t\" (__f) : \"0\" (__f), \"u\" (__g) : \"st(1)\");\n"
+ "# endif";
+
+ test_text = "\t __asm__ __volatile__ (\"divss %1, %0\" : "
+ ": \"x\" (__f), \"x\" (__g));";
+};
+
/*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 */