From c3ac40611c339ff0a80598a1f0bf5ab3d2120d99 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Wed, 29 Aug 2018 22:18:36 +0200
Subject: [PATCH 065/293] futex: recognise FUTEX_BITSET_MATCH_ANY bitmask

* xlat/futexbitset.in: New file.
* futex.c: Include "xlat/futexbitset.h".
(futex) <FUTEX_WAIT_BITSET, FUTEX_WAKE_BITSET>: Decode val3 using
futexbitset xlat.
* tests/futex.c: Add checks for 0xffffffff bitset mask printing.

Closes: Linux commit v4.16-rc1~166^2^2~2
---
 futex.c             |  7 +++++--
 tests/futex.c       | 16 ++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/futex.c b/futex.c
index 9ce4ced..e4dfa08 100644
--- a/futex.c
+++ b/futex.c
@@ -41,6 +41,7 @@
 # define FUTEX_OP_OPARG_SHIFT 8
 #endif
 
+#include "xlat/futexbitset.h"
 #include "xlat/futexops.h"
 #include "xlat/futexwakeops.h"
 #include "xlat/futexwakecmps.h"
@@ -74,11 +75,13 @@ SYS_FUNC(futex)
 		tprintf(", %u", val);
 		tprints(", ");
 		print_timespec(tcp, timeout);
-		tprintf(", %#x", val3);
+		tprints(", ");
+		printxval(futexbitset, val3, NULL);
 		break;
 	case FUTEX_WAKE_BITSET:
 		tprintf(", %u", val);
-		tprintf(", %#x", val3);
+		tprints(", ");
+		printxval(futexbitset, val3, NULL);
 		break;
 	case FUTEX_REQUEUE:
 		tprintf(", %u", val);
diff --git a/tests/futex.c b/tests/futex.c
index 174100f..5250d60 100644
--- a/tests/futex.c
+++ b/tests/futex.c
@@ -166,6 +166,9 @@ void invalid_op(int *val, int op, uint32_t argmask, ...)
 # define VAL3     ((unsigned long) 0xbadda7a09caffee1LLU)
 # define VAL3_PR  ((unsigned) VAL3)
 
+# define VAL3A    ((unsigned long) 0xbadda7a0ffffffffLLU)
+# define VAL3A_PR "FUTEX_BITSET_MATCH_ANY"
+
 int
 main(int argc, char *argv[])
 {
@@ -288,6 +291,14 @@ main(int argc, char *argv[])
 	       zero_extend_signed_to_ull(tmout->tv_nsec), VAL3_PR,
 	       sprintrc(rc));
 
+	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_WAIT_BITSET, VAL, tmout, uaddr2 + 1,
+		VAL3A, (rc == -1) && (errno == EAGAIN));
+	printf("futex(%p, FUTEX_WAIT_BITSET, %u, {tv_sec=%lld, tv_nsec=%llu}"
+	       ", %s) = %s\n",
+	       uaddr, VAL_PR, (long long) tmout->tv_sec,
+	       zero_extend_signed_to_ull(tmout->tv_nsec), VAL3A_PR,
+	       sprintrc(rc));
+
 	/* val3 of 0 is invalid  */
 	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_WAIT_BITSET, VAL, tmout, uaddr2 + 1, 0,
 		(rc == -1) && (errno == EINVAL));
@@ -375,6 +386,11 @@ main(int argc, char *argv[])
 	printf("futex(%p, FUTEX_WAKE_BITSET, %u, %#x) = %s\n", uaddr, 10,
 		VAL3_PR, sprintrc(rc));
 
+	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_WAKE_BITSET, 10, NULL, NULL,
+		VAL3A, (rc == 0));
+	printf("futex(%p, FUTEX_WAKE_BITSET, %u, %s) = %s\n", uaddr, 10,
+		VAL3A_PR, sprintrc(rc));
+
 	/* bitset 0 is invalid */
 	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_WAKE_BITSET, 10, NULL, NULL, 0,
 		(rc == -1) && (errno == EINVAL));
-- 
1.7.12.4

