2 * This file is part of timer_xettime strace test.
4 * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <asm/unistd.h>
33 #if defined __NR_timer_create \
34 && defined __NR_timer_gettime \
35 && defined __NR_timer_settime
46 syscall(__NR_timer_settime, 0xdefaced, TIMER_ABSTIME, NULL, NULL);
47 printf("timer_settime(%d, TIMER_ABSTIME, NULL, NULL)"
48 " = -1 EINVAL (%m)\n", 0xdefaced);
51 struct sigevent sev = { .sigev_notify = SIGEV_NONE };
53 if (syscall(__NR_timer_create, CLOCK_MONOTONIC, &sev, &tid))
54 perror_msg_and_skip("timer_create");
55 printf("timer_create(CLOCK_MONOTONIC, {sigev_signo=0"
56 ", sigev_notify=SIGEV_NONE}, [%d]) = 0\n", tid);
59 struct itimerspec its;
63 .it_interval = { 0xdeface5, 0xdeface6 },
64 .it_value = { 0xdeface7, 0xdeface8 }
66 .pad = { 0xdeadbeef, 0xbadc0ded, 0xdeadbeef, 0xbadc0ded }
69 .it_interval = { 0xdeface1, 0xdeface2 },
70 .it_value = { 0xdeface3, 0xdeface4 }
72 .pad = { 0xdeadbeef, 0xbadc0ded, 0xdeadbeef, 0xbadc0ded }
75 if (syscall(__NR_timer_settime, tid, 0, &new.its, &old.its))
76 perror_msg_and_skip("timer_settime");
77 printf("timer_settime(%d, 0"
78 ", {it_interval={tv_sec=%jd, tv_nsec=%jd}"
79 ", it_value={tv_sec=%jd, tv_nsec=%jd}}"
80 ", {it_interval={tv_sec=%jd, tv_nsec=%jd}"
81 ", it_value={tv_sec=%jd, tv_nsec=%jd}}"
84 (intmax_t) new.its.it_interval.tv_sec,
85 (intmax_t) new.its.it_interval.tv_nsec,
86 (intmax_t) new.its.it_value.tv_sec,
87 (intmax_t) new.its.it_value.tv_nsec,
88 (intmax_t) old.its.it_interval.tv_sec,
89 (intmax_t) old.its.it_interval.tv_nsec,
90 (intmax_t) old.its.it_value.tv_sec,
91 (intmax_t) old.its.it_value.tv_nsec);
93 if (syscall(__NR_timer_gettime, tid, &old.its))
94 perror_msg_and_skip("timer_gettime");
95 printf("timer_gettime(%d"
96 ", {it_interval={tv_sec=%jd, tv_nsec=%jd}"
97 ", it_value={tv_sec=%jd, tv_nsec=%jd}}) = 0\n",
99 (intmax_t) old.its.it_interval.tv_sec,
100 (intmax_t) old.its.it_interval.tv_nsec,
101 (intmax_t) old.its.it_value.tv_sec,
102 (intmax_t) old.its.it_value.tv_nsec);
104 puts("+++ exited with 0 +++");
110 SKIP_MAIN_UNDEFINED("__NR_timer_create && __NR_timer_gettime && __NR_timer_settime")