blob: d1b5a42cc1958a5e232c5dbaafa526b1930cbf3f [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
Dmitry V. Levine314f802014-12-11 19:25:02 +000033#ifndef FUTEX_PRIVATE_FLAG
34# define FUTEX_PRIVATE_FLAG 128
35#endif
36#ifndef FUTEX_CLOCK_REALTIME
37# define FUTEX_CLOCK_REALTIME 256
38#endif
Dmitry V. Levin003cc9f2015-06-17 19:00:17 +000039
Dmitry V. Levine314f802014-12-11 19:25:02 +000040#include "xlat/futexops.h"
Dmitry V. Levine314f802014-12-11 19:25:02 +000041#include "xlat/futexwakeops.h"
42#include "xlat/futexwakecmps.h"
43
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000044SYS_FUNC(futex)
Dmitry V. Levine314f802014-12-11 19:25:02 +000045{
Dmitry V. Levinb5821092015-07-20 13:15:51 +000046 const long uaddr = tcp->u_arg[0];
47 const int op = tcp->u_arg[1];
48 const int cmd = op & 127;
49 const long timeout = tcp->u_arg[3];
50 const long uaddr2 = tcp->u_arg[4];
51 const unsigned int val = tcp->u_arg[2];
52 const unsigned int val2 = tcp->u_arg[3];
53 const unsigned int val3 = tcp->u_arg[5];
54
55 printaddr(uaddr);
56 tprints(", ");
57 printxval(futexops, op, "FUTEX_???");
Dmitry V. Levinb5821092015-07-20 13:15:51 +000058 switch (cmd) {
59 case FUTEX_WAIT:
Eugene Syromyatnikov110da332016-08-30 00:01:45 +030060 tprintf(", %u", val);
61 tprints(", ");
62 print_timespec(tcp, timeout);
63 break;
Dmitry V. Levinb5821092015-07-20 13:15:51 +000064 case FUTEX_LOCK_PI:
65 tprints(", ");
Dmitry V. Levin59385262015-09-18 15:16:11 +000066 print_timespec(tcp, timeout);
Dmitry V. Levinb5821092015-07-20 13:15:51 +000067 break;
68 case FUTEX_WAIT_BITSET:
Eugene Syromyatnikov110da332016-08-30 00:01:45 +030069 tprintf(", %u", val);
Dmitry V. Levinb5821092015-07-20 13:15:51 +000070 tprints(", ");
Dmitry V. Levin59385262015-09-18 15:16:11 +000071 print_timespec(tcp, timeout);
Eugene Syromyatnikova3e1ad32016-08-30 00:00:58 +030072 tprintf(", %#x", val3);
Dmitry V. Levinb5821092015-07-20 13:15:51 +000073 break;
74 case FUTEX_WAKE_BITSET:
Eugene Syromyatnikov110da332016-08-30 00:01:45 +030075 tprintf(", %u", val);
Eugene Syromyatnikova3e1ad32016-08-30 00:00:58 +030076 tprintf(", %#x", val3);
Dmitry V. Levinb5821092015-07-20 13:15:51 +000077 break;
78 case FUTEX_REQUEUE:
Eugene Syromyatnikov110da332016-08-30 00:01:45 +030079 tprintf(", %u", val);
Dmitry V. Levinb5821092015-07-20 13:15:51 +000080 tprintf(", %u, ", val2);
81 printaddr(uaddr2);
82 break;
83 case FUTEX_CMP_REQUEUE:
84 case FUTEX_CMP_REQUEUE_PI:
Eugene Syromyatnikov110da332016-08-30 00:01:45 +030085 tprintf(", %u", val);
Dmitry V. Levinb5821092015-07-20 13:15:51 +000086 tprintf(", %u, ", val2);
87 printaddr(uaddr2);
88 tprintf(", %u", val3);
89 break;
90 case FUTEX_WAKE_OP:
Eugene Syromyatnikov110da332016-08-30 00:01:45 +030091 tprintf(", %u", val);
Dmitry V. Levinb5821092015-07-20 13:15:51 +000092 tprintf(", %u, ", val2);
93 printaddr(uaddr2);
94 tprints(", {");
95 if ((val3 >> 28) & 8)
96 tprints("FUTEX_OP_OPARG_SHIFT|");
97 printxval(futexwakeops, (val3 >> 28) & 0x7, "FUTEX_OP_???");
98 tprintf(", %u, ", (val3 >> 12) & 0xfff);
Eugene Syromyatnikovbfa22a52016-08-29 23:56:24 +030099 printxval(futexwakecmps, (val3 >> 24) & 0xf, "FUTEX_OP_CMP_???");
Dmitry V. Levinb5821092015-07-20 13:15:51 +0000100 tprintf(", %u}", val3 & 0xfff);
101 break;
102 case FUTEX_WAIT_REQUEUE_PI:
Eugene Syromyatnikov110da332016-08-30 00:01:45 +0300103 tprintf(", %u", val);
Dmitry V. Levinb5821092015-07-20 13:15:51 +0000104 tprints(", ");
Dmitry V. Levin59385262015-09-18 15:16:11 +0000105 print_timespec(tcp, timeout);
Dmitry V. Levinb5821092015-07-20 13:15:51 +0000106 tprints(", ");
107 printaddr(uaddr2);
108 break;
Eugene Syromyatnikov3e0e1052016-08-29 23:57:38 +0300109 case FUTEX_FD:
Dmitry V. Levinb5821092015-07-20 13:15:51 +0000110 case FUTEX_WAKE:
Eugene Syromyatnikov110da332016-08-30 00:01:45 +0300111 tprintf(", %u", val);
112 break;
Dmitry V. Levinb5821092015-07-20 13:15:51 +0000113 case FUTEX_UNLOCK_PI:
114 case FUTEX_TRYLOCK_PI:
115 break;
116 default:
Eugene Syromyatnikov110da332016-08-30 00:01:45 +0300117 tprintf(", %u", val);
Eugene Syromyatnikovebeae242016-08-29 23:59:01 +0300118 tprintf(", %#lx", timeout);
119 tprints(", ");
120 printaddr(uaddr2);
121 tprintf(", %#x", val3);
Dmitry V. Levinb5821092015-07-20 13:15:51 +0000122 break;
Dmitry V. Levine314f802014-12-11 19:25:02 +0000123 }
Dmitry V. Levinb5821092015-07-20 13:15:51 +0000124
125 return RVAL_DECODED;
Dmitry V. Levine314f802014-12-11 19:25:02 +0000126}