]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
crtfastmath.c: Include <signal.h>, <ucontext.h>.
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Wed, 1 Jun 2011 14:49:21 +0000 (14:49 +0000)
committerRainer Orth <ro@gcc.gnu.org>
Wed, 1 Jun 2011 14:49:21 +0000 (14:49 +0000)
gcc:
* config/i386/crtfastmath.c [!__x86_64__ && __sun__ && __svr4__]:
Include <signal.h>, <ucontext.h>.
(sigill_caught): Define.
(sigill_hdlr): New function.
(set_fast_math) [!__x86_64__ && __sun__ && __svr4__]: Check if SSE
insns can be executed.
* config/sol2.h (ENDFILE_SPEC): Use crtfastmath.o if -ffast-math
etc.
* config/sparc/sol2.h (ENDFILE_SPEC): Remove.

libgcc:
* config.host (i[34567]86-*-solaris2*): Add i386/t-crtfm to
tmake_file.
Add crtfastmath.o to extra_parts.

From-SVN: r174532

gcc/ChangeLog
gcc/config/i386/crtfastmath.c
gcc/config/sol2.h
gcc/config/sparc/sol2.h
libgcc/ChangeLog
libgcc/config.host

index 72fc84bbc1c3f6658d0df363fd1cfe9ea876800f..db9ecb4296d2206abc1c2db96ff9d33e28242ef9 100644 (file)
@@ -1,3 +1,15 @@
+2011-06-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * config/i386/crtfastmath.c [!__x86_64__ && __sun__ && __svr4__]:
+       Include <signal.h>, <ucontext.h>.
+       (sigill_caught): Define.
+       (sigill_hdlr): New function.
+       (set_fast_math) [!__x86_64__ && __sun__ && __svr4__]: Check if SSE
+       insns can be executed.
+       * config/sol2.h (ENDFILE_SPEC): Use crtfastmath.o if -ffast-math
+       etc.
+       * config/sparc/sol2.h (ENDFILE_SPEC): Remove.
+
 2011-06-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * config/t-slibgcc-darwin: Move to ...
index 1c1ce2c78607d263742e6b89684442b6e0635ddc..a80e2ede3ee77c418c81760808ca4f113d910614 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
+ * Copyright (C) 2005, 2007, 2009, 2011 Free Software Foundation, Inc.
  *
  * This file is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
 #include "cpuid.h"
 #endif
 
+#if !defined __x86_64 && defined __sun__ && defined __svr4__
+#include <signal.h>
+#include <ucontext.h>
+
+static volatile sig_atomic_t sigill_caught;
+
+static void
+sigill_hdlr (int sig __attribute((unused)),
+            siginfo_t *sip __attribute__((unused)),
+            ucontext_t *ucp)
+{
+  sigill_caught = 1;
+  /* Set PC to the instruction after the faulting one to skip over it,
+     otherwise we enter an infinite loop.  4 is the size of the stmxcsr
+     instruction.  */
+  ucp->uc_mcontext.gregs[EIP] += 4;
+  setcontext (ucp);
+}
+#endif
+
 static void __attribute__((constructor))
 #ifndef __x86_64__
 /* The i386 ABI only requires 4-byte stack alignment, so this is necessary
@@ -47,9 +67,31 @@ set_fast_math (void)
 
   if (edx & bit_SSE)
     {
-      unsigned int mxcsr = __builtin_ia32_stmxcsr ();
+      unsigned int mxcsr;
   
-      mxcsr |= MXCSR_FTZ;
+#if defined __sun__ && defined __svr4__
+      /* Solaris 2 before Solaris 9 4/04 cannot execute SSE instructions even
+        if the CPU supports them.  Programs receive SIGILL instead, so check
+        for that at runtime.  */
+      struct sigaction act, oact;
+
+      act.sa_handler = sigill_hdlr;
+      sigemptyset (&act.sa_mask);
+      /* Need to set SA_SIGINFO so a ucontext_t * is passed to the handler.  */
+      act.sa_flags = SA_SIGINFO;
+      sigaction (SIGILL, &act, &oact);
+
+      /* We need a single SSE instruction here so the handler can safely skip
+        over it.  */
+      __asm__ volatile ("movss %xmm2,%xmm1");
+
+      sigaction (SIGILL, &oact, NULL);
+
+      if (sigill_caught)
+       return;
+#endif /* __sun__ && __svr4__ */
+
+      mxcsr = __builtin_ia32_stmxcsr () | MXCSR_FTZ;
 
       if (edx & bit_FXSAVE)
        {
index cf7574830f0e06285e2d2a93f365ffcb03a3e79e..3d539d7ec5b3d3218d9bc7016924e903fe0bbe44 100644 (file)
@@ -141,7 +141,9 @@ along with GCC; see the file COPYING3.  If not see
      %{p|pg:-ldl} -lc}"
 
 #undef  ENDFILE_SPEC
-#define ENDFILE_SPEC "crtend.o%s crtn.o%s"
+#define ENDFILE_SPEC \
+  "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
+   crtend.o%s crtn.o%s"
 
 /* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us.  */
 #undef STARTFILE_SPEC
index a53b82a8e95d6b6ac9a22618c7e5edca3286f3d9..ddc7c4db68af08146d1525ad32eab222532db795 100644 (file)
@@ -117,11 +117,6 @@ along with GCC; see the file COPYING3.  If not see
 #define NO_DBX_BNSYM_ENSYM 1
 \f
 
-#undef  ENDFILE_SPEC
-#define ENDFILE_SPEC \
-  "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
-   crtend.o%s crtn.o%s"
-
 /* Select a format to encode pointers in exception handling data.  CODE
    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
    true if the symbol may be affected by dynamic relocations.
index 7aa390477b97566af8be3cc301829b886ae67868..d4d87a5e990883d949b526b81016dd66d970e746 100644 (file)
@@ -1,3 +1,9 @@
+2011-06-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * config.host (i[34567]86-*-solaris2*): Add i386/t-crtfm to
+       tmake_file.
+       Add crtfastmath.o to extra_parts.
+
 2011-06-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * config/gmon-sol2.c: Reindent.
index 8b1113b9067dbd12d428a933d4496b65b6c1e23f..f064952485d6ab5fc989fcbb88ada624be23492c 100644 (file)
@@ -338,6 +338,8 @@ i[34567]86-*-rtems*)
        tmake_file="${tmake_file} t-crtin i386/t-softfp i386/t-crtstuff t-rtems"
        ;;
 i[34567]86-*-solaris2*)
+       tmake_file="$tmake_file i386/t-crtfm"
+       extra_parts="$extra_parts crtfastmath.o"
        ;;
 i[4567]86-wrs-vxworks|i[4567]86-wrs-vxworksae)
        ;;