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={int=%d, ptr=%#lx}"
57 ", sigev_signo=%u, sigev_notify=%#x /* SIGEV_??? */}"
58 ", 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={int=%d, ptr=%#lx}"
68 ", sigev_signo=%u, sigev_notify=SIGEV_NONE}, [%d]) = 0\n",
69 sev.sigev_value.sival_int,
70 sev.sigev_value.sival_ptr,
71 sev.sigev_signo, tid[0]);
73 sev.sigev_notify = SIGEV_SIGNAL;
74 sev.sigev_signo = SIGALRM;
75 if (syscall(__NR_timer_create, CLOCK_MONOTONIC, &sev, &tid[1]))
76 perror_msg_and_skip("timer_create CLOCK_MONOTONIC");
77 printf("timer_create(CLOCK_MONOTONIC, {sigev_value={int=%d, ptr=%#lx}"
78 ", sigev_signo=SIGALRM, sigev_notify=SIGEV_SIGNAL}"
80 sev.sigev_value.sival_int,
81 sev.sigev_value.sival_ptr, tid[1]);
83 sev.sigev_notify = SIGEV_THREAD;
84 sev.sigev_un.sigev_thread.function =
85 (unsigned long) 0xdeadbeefbadc0dedULL;
86 sev.sigev_un.sigev_thread.attribute =
87 (unsigned long) 0xcafef00dfacefeedULL;
88 if (syscall(__NR_timer_create, CLOCK_REALTIME, &sev, &tid[2]))
89 perror_msg_and_skip("timer_create CLOCK_REALTIME");
90 printf("timer_create(CLOCK_REALTIME, {sigev_value={int=%d, ptr=%#lx}"
91 ", sigev_signo=SIGALRM, sigev_notify=SIGEV_THREAD"
92 ", sigev_notify_function=%#lx, sigev_notify_attributes=%#lx}"
94 sev.sigev_value.sival_int,
95 sev.sigev_value.sival_ptr,
96 sev.sigev_un.sigev_thread.function,
97 sev.sigev_un.sigev_thread.attribute,
100 #ifndef SIGEV_THREAD_ID
101 # define SIGEV_THREAD_ID 4
103 sev.sigev_notify = SIGEV_THREAD_ID;
104 sev.sigev_un.tid = getpid();
105 if (syscall(__NR_timer_create, CLOCK_MONOTONIC, &sev, &tid[3]))
106 perror_msg_and_skip("timer_create CLOCK_MONOTONIC");
107 printf("timer_create(CLOCK_MONOTONIC, {sigev_value={int=%d, ptr=%#lx}"
108 ", sigev_signo=SIGALRM, sigev_notify=SIGEV_THREAD_ID"
109 ", sigev_notify_thread_id=%d}"
111 sev.sigev_value.sival_int,
112 sev.sigev_value.sival_ptr,
116 puts("+++ exited with 0 +++");
122 SKIP_MAIN_UNDEFINED("__NR_timer_create")