1 /*
2 * Copyright (c) 2003, 2004 Ulrich Drepper <drepper@redhat.com>
3 * Copyright (c) 2005-2021 Dmitry V. Levin <ldv@strace.io>
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: LGPL-2.1-or-later
7 */
8
9 #include "defs.h"
10
11 #include DEF_MPERS_TYPE(struct_sigevent)
12 #include "sigevent.h"
13 #include MPERS_DEFS
14
15 #include <signal.h>
16 #include "xlat/sigev_value.h"
17
18 static void
19 print_sigev_value(const typeof_field(struct_sigevent, sigev_value) v)
20 {
21 tprint_struct_begin();
22 PRINT_FIELD_D(v, sival_int);
23 tprint_struct_next();
24 PRINT_FIELD_PTR(v, sival_ptr);
25 tprint_struct_end();
26 }
27
28 MPERS_PRINTER_DECL(void, print_sigevent,
29 struct tcb *const tcp, const kernel_ulong_t addr)
30 {
31 struct_sigevent sev;
32
33 if (umove_or_printaddr(tcp, addr, &sev))
34 return;
35
36 tprint_struct_begin();
37 if (sev.sigev_value.sival_ptr) {
38 PRINT_FIELD_OBJ_VAL(sev, sigev_value, print_sigev_value);
39 tprint_struct_next();
40 }
41
42 switch (sev.sigev_notify) {
43 case SIGEV_SIGNAL:
44 case SIGEV_THREAD:
45 case SIGEV_THREAD_ID:
46 PRINT_FIELD_OBJ_VAL(sev, sigev_signo, printsignal);
47 break;
48 default:
49 PRINT_FIELD_U(sev, sigev_signo);
50 }
51
52 tprint_struct_next();
53 PRINT_FIELD_XVAL(sev, sigev_notify, sigev_value, "SIGEV_???");
54
55 switch (sev.sigev_notify) {
56 case SIGEV_THREAD_ID:
57 #undef sigev_notify_thread_id
58 #define sigev_notify_thread_id sigev_un.tid
59 tprint_struct_next();
60 PRINT_FIELD_D(sev, sigev_notify_thread_id);
61 break;
62 case SIGEV_THREAD:
63 #undef sigev_notify_function
64 #define sigev_notify_function sigev_un.sigev_thread.function
65 tprint_struct_next();
66 PRINT_FIELD_PTR(sev, sigev_notify_function);
67 #undef sigev_notify_attributes
68 #define sigev_notify_attributes sigev_un.sigev_thread.attribute
69 tprint_struct_next();
70 PRINT_FIELD_PTR(sev, sigev_notify_attributes);
71 break;
72 }
73 tprint_struct_end();
74 }