2 * This file is part of timer_create 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 #ifdef __NR_timer_create
39 # include "sigevent.h"
44 syscall(__NR_timer_create, CLOCK_REALTIME, NULL, NULL);
45 printf("timer_create(CLOCK_REALTIME, NULL, NULL) = -1 %s (%m)\n",
49 struct_sigevent sev = {
50 .sigev_notify = 0xdefaced,
51 .sigev_signo = 0xfacefeed,
52 .sigev_value.sival_ptr = (unsigned long) 0xdeadbeefbadc0dedULL
55 syscall(__NR_timer_create, CLOCK_REALTIME, &sev, NULL);
56 printf("timer_create(CLOCK_REALTIME, {sigev_value={sival_int=%d, "
57 "sival_ptr=%#lx}, sigev_signo=%u, "
58 "sigev_notify=%#x /* SIGEV_??? */}, NULL) = -1 %s (%m)\n",
59 sev.sigev_value.sival_int,
60 sev.sigev_value.sival_ptr,
61 sev.sigev_signo, sev.sigev_notify,
64 sev.sigev_notify = SIGEV_NONE;
65 if (syscall(__NR_timer_create, CLOCK_REALTIME, &sev, &tid[0]))
66 perror_msg_and_skip("timer_create CLOCK_REALTIME");
67 printf("timer_create(CLOCK_REALTIME, {sigev_value={sival_int=%d, "
68 "sival_ptr=%#lx}, sigev_signo=%u, sigev_notify=SIGEV_NONE}, "
70 sev.sigev_value.sival_int,
71 sev.sigev_value.sival_ptr,
72 sev.sigev_signo, tid[0]);
74 sev.sigev_notify = SIGEV_SIGNAL;
75 sev.sigev_signo = SIGALRM;
76 if (syscall(__NR_timer_create, CLOCK_MONOTONIC, &sev, &tid[1]))
77 perror_msg_and_skip("timer_create CLOCK_MONOTONIC");
78 printf("timer_create(CLOCK_MONOTONIC, {sigev_value={sival_int=%d, "
79 "sival_ptr=%#lx}, sigev_signo=SIGALRM, "
80 "sigev_notify=SIGEV_SIGNAL}, [%d]) = 0\n",
81 sev.sigev_value.sival_int,
82 sev.sigev_value.sival_ptr, tid[1]);
84 sev.sigev_notify = SIGEV_THREAD;
85 sev.sigev_un.sigev_thread.function =
86 (unsigned long) 0xdeadbeefbadc0dedULL;
87 sev.sigev_un.sigev_thread.attribute =
88 (unsigned long) 0xcafef00dfacefeedULL;
89 if (syscall(__NR_timer_create, CLOCK_REALTIME, &sev, &tid[2]))
90 perror_msg_and_skip("timer_create CLOCK_REALTIME");
91 printf("timer_create(CLOCK_REALTIME, {sigev_value={sival_int=%d, "
92 "sival_ptr=%#lx}, sigev_signo=SIGALRM, sigev_notify=SIGEV_THREAD"
93 ", sigev_notify_function=%#lx, sigev_notify_attributes=%#lx}"
95 sev.sigev_value.sival_int,
96 sev.sigev_value.sival_ptr,
97 sev.sigev_un.sigev_thread.function,
98 sev.sigev_un.sigev_thread.attribute,
101 #ifndef SIGEV_THREAD_ID
102 # define SIGEV_THREAD_ID 4
104 sev.sigev_notify = SIGEV_THREAD_ID;
105 sev.sigev_un.tid = getpid();
106 if (syscall(__NR_timer_create, CLOCK_MONOTONIC, &sev, &tid[3]))
107 perror_msg_and_skip("timer_create CLOCK_MONOTONIC");
108 printf("timer_create(CLOCK_MONOTONIC, {sigev_value={sival_int=%d, "
109 "sival_ptr=%#lx}, sigev_signo=SIGALRM, "
110 "sigev_notify=SIGEV_THREAD_ID, sigev_notify_thread_id=%d}"
112 sev.sigev_value.sival_int,
113 sev.sigev_value.sival_ptr,
117 puts("+++ exited with 0 +++");
123 SKIP_MAIN_UNDEFINED("__NR_timer_create")