2 * Copyright (c) 1993 Ulrich Pegelow <pegelow@moorea.uni-muenster.de>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6 * Copyright (c) 2003-2006 Roland McGrath <roland@redhat.com>
7 * Copyright (c) 2006-2015 Dmitry V. Levin <ldv@altlinux.org>
8 * Copyright (c) 2015-2019 The strace developers.
11 * SPDX-License-Identifier: LGPL-2.1-or-later
19 #elif defined HAVE_LINUX_SEM_H
20 # include <linux/sem.h>
23 #include "xlat/semctl_flags.h"
24 #include "xlat/semop_flags.h"
26 #if defined HAVE_SYS_SEM_H || defined HAVE_LINUX_SEM_H
28 print_sembuf(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
30 const struct sembuf *sb = elem_buf;
32 tprintf("{%u, %d, ", sb->sem_num, sb->sem_op);
33 printflags(semop_flags, (unsigned short) sb->sem_flg, "SEM_???");
41 tprint_sembuf_array(struct tcb *const tcp, const kernel_ulong_t addr,
42 const unsigned int count)
44 #if defined HAVE_SYS_SEM_H || defined HAVE_LINUX_SEM_H
46 print_array(tcp, addr, count, &sb, sizeof(sb),
47 tfetch_mem, print_sembuf, 0);
51 tprintf(", %u", count);
56 tprintf("%d, ", (int) tcp->u_arg[0]);
57 if (indirect_ipccall(tcp)) {
58 tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]);
60 tprint_sembuf_array(tcp, tcp->u_arg[1], tcp->u_arg[2]);
66 do_semtimedop(struct tcb *const tcp, const print_obj_by_addr_fn print_ts)
68 tprintf("%d, ", (int) tcp->u_arg[0]);
69 if (indirect_ipccall(tcp)) {
70 tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]);
72 #if defined(S390) || defined(S390X)
73 print_ts(tcp, tcp->u_arg[2]);
75 print_ts(tcp, tcp->u_arg[4]);
78 tprint_sembuf_array(tcp, tcp->u_arg[1], tcp->u_arg[2]);
80 print_ts(tcp, tcp->u_arg[3]);
85 #if HAVE_ARCH_TIME32_SYSCALLS
86 SYS_FUNC(semtimedop_time32)
88 return do_semtimedop(tcp, print_timespec32);
92 SYS_FUNC(semtimedop_time64)
94 return do_semtimedop(tcp, print_timespec64);
99 printxval(ipc_private, (unsigned int) tcp->u_arg[0], NULL);
100 tprintf(", %d, ", (int) tcp->u_arg[1]);
101 if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
103 print_numeric_umode_t(tcp->u_arg[2] & 0777);
109 tprintf("%d, %d, ", (int) tcp->u_arg[0], (int) tcp->u_arg[1]);
110 PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
112 if (indirect_ipccall(tcp)
114 && current_personality != 0
117 printnum_ptr(tcp, tcp->u_arg[3]);
119 printaddr(tcp->u_arg[3]);