Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.target / i386 / sse-os-support.h
bloba2b4e2d3c7e2bc879a9bbe41f7258ef828cb0d01
1 #if defined(__sun__) && defined(__svr4__)
2 /* Make sure sigaction() is declared even with -std=c99. */
3 #define __EXTENSIONS__
4 #include <signal.h>
5 #include <ucontext.h>
7 static volatile sig_atomic_t sigill_caught;
9 static void
10 sigill_hdlr (int sig __attribute((unused)),
11 siginfo_t *sip __attribute__((unused)),
12 ucontext_t *ucp)
14 sigill_caught = 1;
15 /* Set PC to the instruction after the faulting one to skip over it,
16 otherwise we enter an infinite loop. */
17 ucp->uc_mcontext.gregs[EIP] += 4;
18 setcontext (ucp);
20 #endif
22 /* Check if the OS supports executing SSE instructions. This function is
23 only used in sse-check.h, sse2-check.h, and sse3-check.h so far since
24 Solaris 8 and 9 won't run on newer CPUs anyway. */
26 static int
27 sse_os_support (void)
29 #if defined(__sun__) && defined(__svr4__)
30 /* Solaris 2 before Solaris 9 4/04 cannot execute SSE instructions
31 even if the CPU supports them. Programs receive SIGILL instead, so
32 check for that at runtime. */
34 struct sigaction act, oact;
36 act.sa_handler = sigill_hdlr;
37 sigemptyset (&act.sa_mask);
38 /* Need to set SA_SIGINFO so a ucontext_t * is passed to the handler. */
39 act.sa_flags = SA_SIGINFO;
40 sigaction (SIGILL, &act, &oact);
42 /* We need a single SSE instruction here so the handler can safely skip
43 over it. */
44 __asm__ volatile ("movss %xmm2,%xmm1");
46 sigaction (SIGILL, &oact, NULL);
48 if (sigill_caught)
49 exit (0);
50 else
51 return 1;
52 #else
53 return 1;
54 #endif /* __sun__ && __svr4__ */