aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/i386/sse-os-support.h
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gcc.target/i386/sse-os-support.h
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.target/i386/sse-os-support.h')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/i386/sse-os-support.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/i386/sse-os-support.h b/gcc-4.9/gcc/testsuite/gcc.target/i386/sse-os-support.h
new file mode 100644
index 000000000..a2b4e2d3c
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/i386/sse-os-support.h
@@ -0,0 +1,55 @@
+#if defined(__sun__) && defined(__svr4__)
+/* Make sure sigaction() is declared even with -std=c99. */
+#define __EXTENSIONS__
+#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. */
+ ucp->uc_mcontext.gregs[EIP] += 4;
+ setcontext (ucp);
+}
+#endif
+
+/* Check if the OS supports executing SSE instructions. This function is
+ only used in sse-check.h, sse2-check.h, and sse3-check.h so far since
+ Solaris 8 and 9 won't run on newer CPUs anyway. */
+
+static int
+sse_os_support (void)
+{
+#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)
+ exit (0);
+ else
+ return 1;
+#else
+ return 1;
+#endif /* __sun__ && __svr4__ */
+}