Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: gcc/libgfortran/config/fpu-387.h

Issue 3050029: [gcc] GCC 4.5.0=>4.5.1 (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/nacl-toolchain.git
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gcc/libgfortran/config.h.in ('k') | gcc/libgfortran/fmain.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gcc/libgfortran/config/fpu-387.h
diff --git a/gcc/libgfortran/config/fpu-387.h b/gcc/libgfortran/config/fpu-387.h
index 573fabcac6dead395928394089ab11b82dc44333..5fe51b2d20959b4acaaacf608d286bf5e66db978 100644
--- a/gcc/libgfortran/config/fpu-387.h
+++ b/gcc/libgfortran/config/fpu-387.h
@@ -1,5 +1,5 @@
/* FPU-related code for x86 and x86_64 processors.
- Copyright 2005, 2007, 2009 Free Software Foundation, Inc.
+ Copyright 2005, 2007, 2009, 2010 Free Software Foundation, Inc.
Contributed by Francois-Xavier Coudert <coudert@clipper.ens.fr>
This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -27,6 +27,26 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "cpuid.h"
#endif
+#if 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 int
has_sse (void)
{
@@ -36,6 +56,31 @@ has_sse (void)
if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
return 0;
+#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. */
+
+ if (edx & bit_SSE)
+ {
+ struct sigaction act, oact;
+ unsigned int cw_sse;
+
+ 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);
+
+ asm volatile ("stmxcsr %0" : "=m" (cw_sse));
+
+ sigaction (SIGILL, &oact, NULL);
+
+ if (sigill_caught)
+ return 0;
+ }
+#endif /* __sun__ && __svr4__ */
+
return edx & bit_SSE;
#else
return 1;
« no previous file with comments | « gcc/libgfortran/config.h.in ('k') | gcc/libgfortran/fmain.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698