Debian Codegraph @

testsuite/systemtap.syscall/itimer.c

raw
1 /* COVERAGE: getitimer setitimer */
2 #include <sys/types.h>
3 #include <unistd.h>
4 #include <sys/time.h>
5 #include <string.h>
6 #include <signal.h>
7
8 static void
9 alarm_handler(int signo, siginfo_t *info, void *context)
10 {
11 }
12
13 int main()
14 {
15 struct sigaction act;
16 struct itimerval itv, old_itv;
17
18 memset(&act, 0, sizeof(act));
19 act.sa_handler = (void *)alarm_handler;
20 sigaction(SIGALRM, &act, NULL);
21 sigaction(SIGVTALRM, &act, NULL);
22 sigaction(SIGPROF, &act, NULL);
23
24
25 memset(&itv, 0, sizeof(itv));
26 itv.it_interval.tv_sec = 0;
27 itv.it_interval.tv_usec = 500000;
28 itv.it_value.tv_sec = 1;
29 itv.it_value.tv_usec = 0;
30 setitimer(ITIMER_REAL, &itv, &old_itv);
31 //staptest// setitimer (ITIMER_REAL, \[0.500000,1.000000\], XXXX) = 0
32
33 itv.it_value.tv_sec = 0;
34 itv.it_value.tv_usec = 0;
35 setitimer(ITIMER_REAL, &itv, NULL);
36 //staptest// setitimer (ITIMER_REAL, \[0.500000,0.000000\], 0x[0]+) = 0
37
38 setitimer(ITIMER_VIRTUAL, &itv, NULL);
39 //staptest// setitimer (ITIMER_VIRTUAL, \[0.500000,0.000000\], 0x[0]+) = 0
40
41 setitimer(ITIMER_PROF, &itv, NULL);
42 //staptest// setitimer (ITIMER_PROF, \[0.500000,0.000000\], 0x[0]+) = 0
43
44 getitimer(ITIMER_REAL, &itv);
45 //staptest// getitimer (ITIMER_REAL, XXXX) = 0
46
47 getitimer(ITIMER_VIRTUAL, &itv);
48 //staptest// getitimer (ITIMER_VIRTUAL, XXXX) = 0
49
50 getitimer(ITIMER_PROF, &itv);
51 //staptest// getitimer (ITIMER_PROF, XXXX) = 0
52
53 /* Limit testing. */
54
55 itv.it_interval.tv_sec = 0;
56 itv.it_interval.tv_usec = 500000;
57 itv.it_value.tv_sec = 1;
58 itv.it_value.tv_usec = 0;
59 setitimer(-1, &itv, &old_itv);
60 //staptest// setitimer (0xffffffff, \[0.500000,1.000000\], XXXX) = -NNNN
61
62 // The following SEGVs if compiled as a 32-on-64 bit binary on x86_64 in valid_timeval_to_timeval64()
63 #if __WORDSIZE == 64
64 setitimer(ITIMER_REAL, (struct itimerval *)-1, &old_itv);
65 #ifdef __s390__
66 //staptest// setitimer (ITIMER_REAL, 0x[7]?[f]+, XXXX) = -NNNN
67 #else
68 //staptest// setitimer (ITIMER_REAL, 0x[f]+, XXXX) = -NNNN
69 #endif
70 #endif
71
72 // The following SEGVs if compiled as a 32-on-64 bit binary on x86_64 in valid_timeval_to_timeval64()
73 #if __WORDSIZE == 64
74 setitimer(ITIMER_REAL, &itv, (struct itimerval *)-1);
75 #ifdef __s390__
76 //staptest// setitimer (ITIMER_REAL, \[0.500000,1.000000\], 0x[7]?[f]+) = -NNNN
77 #else
78 //staptest// setitimer (ITIMER_REAL, \[0.500000,1.000000\], 0x[f]+) = -NNNN
79 #endif
80 #endif
81
82 getitimer(-1, &itv);
83 //staptest// getitimer (0xffffffff, XXXX) = -NNNN
84
85 // The following SEGVs if compiled as a 32-on-64 bit binary on x86_64 in valid_timeval_to_timeval64()
86 #if __WORDSIZE == 64
87 getitimer(ITIMER_REAL, (struct itimerval *)-1);
88 #ifdef __s390__
89 //staptest// getitimer (ITIMER_REAL, 0x[7]?[f]+) = -NNNN
90 #else
91 //staptest// getitimer (ITIMER_REAL, 0x[f]+) = -NNNN
92 #endif
93 #endif
94
95 return 0;
96 }
97