1 /* Test if rflags values are correctly propagated in and out of a signal
2 handler. Note that we actually test only the propagation of the overflow
10 #include <sys/regset.h>
11 #include <sys/syscall.h>
14 #define OBIT(rflags) (!!((rflags) & (1 << 11)))
15 #define SBIT(rflags) (!!((rflags) & (1 << 7)))
20 static void sighandler(int sig
, siginfo_t
*sip
, void *arg
)
23 uc
= *((ucontext_t
*) arg
);
32 sa
.sa_sigaction
= sighandler
;
33 sa
.sa_flags
= SA_SIGINFO
;
34 if (sigfillset(&sa
.sa_mask
)) {
38 if (sigaction(SIGUSR1
, &sa
, NULL
)) {
46 /* Set overflow and sign flags. */
48 "addl $0x7fffffff, %%edx\n"
50 /* Trigger the signal handler. */
55 : "a" (SYS_kill
), "D" (pid
), "S" (SIGUSR1
)
58 printf("Values in the signal handler:\n");
59 printf(" overflow=%d, sign=%d\n",
60 OBIT(uc
.uc_mcontext
.gregs
[REG_RFL
]),
61 SBIT(uc
.uc_mcontext
.gregs
[REG_RFL
]));
63 printf("Values after the return from the signal handler:\n");
64 printf(" overflow=%d, sign=%d\n", OBIT(rflags
), SBIT(rflags
));