Enable sys_adjtimex() on arm-linux. Fixes #412408.
[valgrind.git] / memcheck / tests / x86-solaris / context_eflags.c
blobc458756875d40985341e19001568d39511ba273c
1 /* x86 variant of the amd64-solaris/context_rflags.c test. */
3 #include <assert.h>
4 #include <signal.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <unistd.h>
8 #include <sys/regset.h>
9 #include <sys/syscall.h>
10 #include <sys/ucontext.h>
12 #define OBIT(eflags) (!!((eflags) & (1 << 11)))
13 #define SBIT(eflags) (!!((eflags) & (1 << 7)))
15 static siginfo_t si;
16 static ucontext_t uc;
18 static void sighandler(int sig, siginfo_t *sip, void *arg)
20 si = *sip;
21 uc = *((ucontext_t *) arg);
24 int main(void)
26 struct sigaction sa;
27 pid_t pid;
28 int eflags;
30 sa.sa_sigaction = sighandler;
31 sa.sa_flags = SA_SIGINFO;
32 if (sigfillset(&sa.sa_mask)) {
33 perror("sigfillset");
34 return 1;
36 if (sigaction(SIGUSR1, &sa, NULL)) {
37 perror("sigaction");
38 return 1;
41 pid = getpid();
43 __asm__ __volatile__(
44 /* Set overflow and sign flags. */
45 "movl $1, %%edx\n"
46 "addl $0x7fffffff, %%edx\n"
48 /* Prepare syscall parameters. */
49 "pushl %[sig]\n"
50 "pushl %[pid]\n"
51 "pushl $0xdeadbeef\n"
52 "movl %[scall], %%eax\n"
54 /* Trigger the signal handler. */
55 "int $0x91\n"
56 "pushfl\n"
57 "popl %%edx\n"
58 "addl $12, %%esp\n"
59 : "=d" (eflags)
60 : [scall] "i" (SYS_kill), [pid] "a" (pid), [sig] "i" (SIGUSR1)
61 : "cc", "memory");
63 printf("Values in the signal handler:\n");
64 printf(" overflow=%d, sign=%d\n",
65 OBIT(uc.uc_mcontext.gregs[EFL]), SBIT(uc.uc_mcontext.gregs[EFL]));
67 printf("Values after the return from the signal handler:\n");
68 printf(" overflow=%d, sign=%d\n", OBIT(eflags), SBIT(eflags));
70 return 0;