1 /* Test if SSE valus are correctly propagated into and out of a signal handler
2 and also check that the same applies for uninitialised values and their
10 #include <sys/syscall.h>
17 /* x0 is always zero, but is visible to Valgrind as uninitialised. */
19 static upad128_t d0
= {0};
21 static void sighandler(int sig
, siginfo_t
*sip
, void *arg
)
23 ucontext_t
*ucp
= (ucontext_t
*) arg
;
28 ucp
->uc_mcontext
.fpregs
.fp_reg_set
.fpchip_state
.xmm
[0] = d0
;
29 ucp
->uc_mcontext
.fpregs
.fp_reg_set
.fpchip_state
.xmm
[1] = x0
;
39 #if defined(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE)
40 struct _fpchip_state
*fs
;
42 struct fpchip_state
*fs
;
44 fs
= &uc
.uc_mcontext
.fpregs
.fp_reg_set
.fpchip_state
;
46 /* Uninitialised, but we know px[0] is 0x0. */
47 upad128_t
*px
= malloc(sizeof(*px
));
50 /* Uninitialised, but we know py[0] is 0x0. */
51 upad128_t
*py
= malloc(sizeof(*py
));
54 sa
.sa_sigaction
= sighandler
;
55 sa
.sa_flags
= SA_SIGINFO
;
56 if (sigfillset(&sa
.sa_mask
)) {
60 if (sigaction(SIGUSR1
, &sa
, NULL
)) {
68 /* Set values in the SSE registers. */
69 "movups %[y0], %%xmm0\n"
70 "movups %[d0], %%xmm1\n"
71 "movups %[d0], %%xmm2\n"
72 "movups %[y0], %%xmm3\n"
73 "movups %[y0], %%xmm4\n"
74 "movups %[d0], %%xmm5\n"
75 "movups %[d0], %%xmm6\n"
76 "movups %[y0], %%xmm7\n"
78 /* Trigger the signal handler. */
80 "movups %%xmm0, 0x00 + %[out]\n"
81 "movups %%xmm1, 0x10 + %[out]\n"
82 "movups %%xmm2, 0x20 + %[out]\n"
83 "movups %%xmm3, 0x30 + %[out]\n"
84 "movups %%xmm4, 0x40 + %[out]\n"
85 "movups %%xmm5, 0x50 + %[out]\n"
86 "movups %%xmm6, 0x60 + %[out]\n"
87 "movups %%xmm7, 0x70 + %[out]\n"
89 : "a" (SYS_kill
), "D" (pid
), "S" (SIGUSR1
), [y0
] "m" (y0
), [d0
] "m" (d0
)
90 : "rdx", "cc", "memory");
92 printf("Values in the signal handler:\n");
93 printf(" xmm1=%Lf, xmm2=%Lf, xmm5=%Lf, xmm6=%Lf\n",
94 fs
->xmm
[1]._q
, fs
->xmm
[2]._q
, fs
->xmm
[5]._q
, fs
->xmm
[6]._q
);
95 /* Check that fs->xmm[0], fs->xmm[3], fs->xmm[4] and fs->xmm[7] contain
96 uninitialised values (origin is py[0]). */
97 if (fs
->xmm
[0]._q
|| fs
->xmm
[3]._q
|| fs
->xmm
[4]._q
|| fs
->xmm
[7]._q
)
100 printf("Values after the return from the signal handler:\n");
101 printf(" xmm0=%Lf, xmm2=%Lf, xmm5=%Lf, xmm6=%Lf\n",
102 out
[0]._q
, out
[2]._q
, out
[5]._q
, out
[6]._q
);
103 /* Check that out[1], out[3], out[4] and out[7] contain uninitialised
104 values (origin is px[0]). */
105 if (out
[1]._q
|| out
[3]._q
|| out
[4]._q
|| out
[7]._q
)