]> granicus.if.org Git - strace/blob - tests/rt_tgsigqueueinfo.c
Remove XLAT_END
[strace] / tests / rt_tgsigqueueinfo.c
1 /*
2  * This file is part of rt_tgsigqueueinfo strace test.
3  *
4  * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
5  * Copyright (c) 2016-2019 The strace developers.
6  * All rights reserved.
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10
11 #include "tests.h"
12 #include "scno.h"
13
14 #ifdef __NR_rt_tgsigqueueinfo
15
16 # include <errno.h>
17 # include <signal.h>
18 # include <stdio.h>
19 # include <string.h>
20 # include <unistd.h>
21
22 static long
23 k_tgsigqueueinfo(const pid_t pid, const int sig, const void *const info)
24 {
25         return syscall(__NR_rt_tgsigqueueinfo,
26                        F8ILL_KULONG_MASK | pid,
27                        F8ILL_KULONG_MASK | pid,
28                        F8ILL_KULONG_MASK | sig,
29                        info);
30 }
31
32 int
33 main(void)
34 {
35         const struct sigaction sa = {
36                 .sa_handler = SIG_IGN
37         };
38         if (sigaction(SIGUSR1, &sa, NULL))
39                 perror_msg_and_fail("sigaction");
40
41         TAIL_ALLOC_OBJECT_CONST_PTR(siginfo_t, info);
42         memset(info, 0, sizeof(*info));
43         info->si_signo = SIGUSR1;
44         info->si_errno = ENOENT;
45         info->si_code = SI_QUEUE;
46         info->si_pid = getpid();
47         info->si_uid = getuid();
48         info->si_value.sival_ptr =
49                 (void *) (unsigned long) 0xdeadbeeffacefeedULL;
50
51         if (k_tgsigqueueinfo(info->si_pid, SIGUSR1, info))
52                 (errno == ENOSYS ? perror_msg_and_skip : perror_msg_and_fail)(
53                         "rt_tgsigqueueinfo");
54
55         printf("rt_tgsigqueueinfo(%u, %u, %s, {si_signo=%s"
56                 ", si_code=SI_QUEUE, si_errno=ENOENT, si_pid=%u"
57                 ", si_uid=%u, si_value={int=%d, ptr=%p}}) = 0\n",
58                 info->si_pid, info->si_pid, "SIGUSR1", "SIGUSR1",
59                 info->si_pid, info->si_uid, info->si_value.sival_int,
60                 info->si_value.sival_ptr);
61
62         puts("+++ exited with 0 +++");
63         return 0;
64 }
65
66 #else
67
68 SKIP_MAIN_UNDEFINED("__NR_rt_tgsigqueueinfo")
69
70 #endif