blob: 7090c7d086c3529170c9a4ee95fc84e43eaa1d80 [file] [log] [blame]
Dmitry V. Levin38a34c92015-12-17 17:56:48 +00001/*
2 * Copyright (c) 2002-2003 Roland McGrath <roland@redhat.com>
3 * Copyright (c) 2007-2008 Ulrich Drepper <drepper@redhat.com>
4 * Copyright (c) 2009 Andreas Schwab <schwab@redhat.com>
5 * Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
Dmitry V. Levine314f802014-12-11 19:25:02 +000031#include "defs.h"
32
33#ifdef HAVE_LINUX_FUTEX_H
34# include <linux/futex.h>
35#endif
36
Dmitry V. Levine314f802014-12-11 19:25:02 +000037#ifndef FUTEX_PRIVATE_FLAG
38# define FUTEX_PRIVATE_FLAG 128
39#endif
40#ifndef FUTEX_CLOCK_REALTIME
41# define FUTEX_CLOCK_REALTIME 256
42#endif
Dmitry V. Levin003cc9f2015-06-17 19:00:17 +000043
Dmitry V. Levine314f802014-12-11 19:25:02 +000044#include "xlat/futexops.h"
Dmitry V. Levine314f802014-12-11 19:25:02 +000045#include "xlat/futexwakeops.h"
46#include "xlat/futexwakecmps.h"
47
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000048SYS_FUNC(futex)
Dmitry V. Levine314f802014-12-11 19:25:02 +000049{
Dmitry V. Levinb5821092015-07-20 13:15:51 +000050 const long uaddr = tcp->u_arg[0];
51 const int op = tcp->u_arg[1];
52 const int cmd = op & 127;
53 const long timeout = tcp->u_arg[3];
54 const long uaddr2 = tcp->u_arg[4];
55 const unsigned int val = tcp->u_arg[2];
56 const unsigned int val2 = tcp->u_arg[3];
57 const unsigned int val3 = tcp->u_arg[5];
58
59 printaddr(uaddr);
60 tprints(", ");
61 printxval(futexops, op, "FUTEX_???");
62 tprintf(", %u", val);
63 switch (cmd) {
64 case FUTEX_WAIT:
65 case FUTEX_LOCK_PI:
66 tprints(", ");
Dmitry V. Levin59385262015-09-18 15:16:11 +000067 print_timespec(tcp, timeout);
Dmitry V. Levinb5821092015-07-20 13:15:51 +000068 break;
69 case FUTEX_WAIT_BITSET:
70 tprints(", ");
Dmitry V. Levin59385262015-09-18 15:16:11 +000071 print_timespec(tcp, timeout);
Dmitry V. Levinb5821092015-07-20 13:15:51 +000072 tprintf(", %x", val3);
73 break;
74 case FUTEX_WAKE_BITSET:
75 tprintf(", %x", val3);
76 break;
77 case FUTEX_REQUEUE:
78 tprintf(", %u, ", val2);
79 printaddr(uaddr2);
80 break;
81 case FUTEX_CMP_REQUEUE:
82 case FUTEX_CMP_REQUEUE_PI:
83 tprintf(", %u, ", val2);
84 printaddr(uaddr2);
85 tprintf(", %u", val3);
86 break;
87 case FUTEX_WAKE_OP:
88 tprintf(", %u, ", val2);
89 printaddr(uaddr2);
90 tprints(", {");
91 if ((val3 >> 28) & 8)
92 tprints("FUTEX_OP_OPARG_SHIFT|");
93 printxval(futexwakeops, (val3 >> 28) & 0x7, "FUTEX_OP_???");
94 tprintf(", %u, ", (val3 >> 12) & 0xfff);
95 if ((val3 >> 24) & 8)
96 tprints("FUTEX_OP_OPARG_SHIFT|");
97 printxval(futexwakecmps, (val3 >> 24) & 0x7, "FUTEX_OP_CMP_???");
98 tprintf(", %u}", val3 & 0xfff);
99 break;
100 case FUTEX_WAIT_REQUEUE_PI:
101 tprints(", ");
Dmitry V. Levin59385262015-09-18 15:16:11 +0000102 print_timespec(tcp, timeout);
Dmitry V. Levinb5821092015-07-20 13:15:51 +0000103 tprints(", ");
104 printaddr(uaddr2);
105 break;
106 case FUTEX_WAKE:
107 case FUTEX_UNLOCK_PI:
108 case FUTEX_TRYLOCK_PI:
109 break;
110 default:
111 tprintf(", %lx, %lx, %x", timeout, uaddr2, val3);
112 break;
Dmitry V. Levine314f802014-12-11 19:25:02 +0000113 }
Dmitry V. Levinb5821092015-07-20 13:15:51 +0000114
115 return RVAL_DECODED;
Dmitry V. Levine314f802014-12-11 19:25:02 +0000116}