1 /* x86 variant of the amd64-solaris/context_fpu.c test. */
8 #include <sys/syscall.h>
9 #include <sys/ucontext.h>
13 static float inhandler
[8];
15 static void sighandler(int sig
, siginfo_t
*sip
, void *arg
)
18 ucontext_t
*ucp
= (ucontext_t
*) arg
;
23 /* Reset the FP stack so it's possible to push other values onto it. (It
24 is fully filled in main() before triggering the signal handler). Note
25 that VEX also clears all FP values when the finit instruction is
26 executed. This provides another level of validation that the restore
31 /* Convert 80b values in mcontext to 32b values in the inhandler array. */
32 for (i
= 0; i
< 8; i
++) {
36 : [out
] "=m" (inhandler
[i
])
37 : [in
] "m" (*((char*)&ucp
->uc_mcontext
.fpregs
.fp_reg_set
.fpchip_state
49 /* Uninitialised, but we know px[0] is 0x0. */
50 float *px
= malloc(sizeof(*px
));
53 sa
.sa_sigaction
= sighandler
;
54 sa
.sa_flags
= SA_SIGINFO
;
55 if (sigfillset(&sa
.sa_mask
)) {
59 if (sigaction(SIGUSR1
, &sa
, NULL
)) {
67 /* Set values in the FP stack. */
77 /* Prepare syscall parameters. */
81 "movl %[scall], %%eax\n"
83 /* Trigger the signal handler. */
86 "fstps 0x00 + %[out]\n"
87 "fstps 0x04 + %[out]\n"
88 "fstps 0x08 + %[out]\n"
89 "fstps 0x0c + %[out]\n"
90 "fstps 0x10 + %[out]\n"
91 "fstps 0x14 + %[out]\n"
92 "fstps 0x18 + %[out]\n"
93 "fstps 0x1c + %[out]\n"
95 : [scall
] "i" (SYS_kill
), [pid
] "a" (pid
), [sig
] "i" (SIGUSR1
),
97 : "edx", "cc", "memory");
99 printf("Values in the signal handler:\n");
100 printf(" fp[0]=%f, fp[2]=%f, fp[4]=%f, fp[6]=%f\n",
101 inhandler
[0], inhandler
[2], inhandler
[4], inhandler
[6]);
102 /* Check that inhandler[1], inhandler[3], inhandler[5] and inhandler[7]
103 contain uninitialised values (origin is px[0]). */
104 if (inhandler
[1] || inhandler
[3] || inhandler
[5] || inhandler
[7])
107 printf("Values after the return from the signal handler:\n");
108 printf(" fp[0]=%f, fp[2]=%f, fp[4]=%f, fp[6]=%f\n",
109 out
[0], out
[2], out
[4], out
[6]);
110 /* Check that out[1], out[3], out[5] and out[7] contain uninitialised
111 values (origin is px[0]). */
112 if (out
[1] || out
[3] || out
[5] || out
[7])