Tue Nov 3 16:05:51 2020 UTC ()
Add definitions for FUTEX_NETBSD_RW_WAIT and FUTEX_NETBSD_RW_HANDOFF.
(Forgot to commit this file previously.)


(thorpej)
diff -r1.4 -r1.4.2.1 src/sys/sys/futex.h

cvs diff -r1.4 -r1.4.2.1 src/sys/sys/futex.h (expand / switch to unified diff)

--- src/sys/sys/futex.h 2020/05/05 15:25:18 1.4
+++ src/sys/sys/futex.h 2020/11/03 16:05:51 1.4.2.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: futex.h,v 1.4 2020/05/05 15:25:18 riastradh Exp $ */ 1/* $NetBSD: futex.h,v 1.4.2.1 2020/11/03 16:05:51 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2018, 2019 The NetBSD Foundation, Inc. 4 * Copyright (c) 2018, 2019 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Taylor R. Campbell and Jason R. Thorpe. 8 * by Taylor R. Campbell and Jason R. Thorpe.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -76,26 +76,30 @@ @@ -76,26 +76,30 @@
76#define FUTEX_WAKE 1 76#define FUTEX_WAKE 1
77#define FUTEX_FD 2 77#define FUTEX_FD 2
78#define FUTEX_REQUEUE 3 78#define FUTEX_REQUEUE 3
79#define FUTEX_CMP_REQUEUE 4 79#define FUTEX_CMP_REQUEUE 4
80#define FUTEX_WAKE_OP 5 80#define FUTEX_WAKE_OP 5
81#define FUTEX_LOCK_PI 6 81#define FUTEX_LOCK_PI 6
82#define FUTEX_UNLOCK_PI 7 82#define FUTEX_UNLOCK_PI 7
83#define FUTEX_TRYLOCK_PI 8 83#define FUTEX_TRYLOCK_PI 8
84#define FUTEX_WAIT_BITSET 9 84#define FUTEX_WAIT_BITSET 9
85#define FUTEX_WAKE_BITSET 10 85#define FUTEX_WAKE_BITSET 10
86#define FUTEX_WAIT_REQUEUE_PI 11 86#define FUTEX_WAIT_REQUEUE_PI 11
87#define FUTEX_CMP_REQUEUE_PI 12 87#define FUTEX_CMP_REQUEUE_PI 12
88 88
 89/* These futex operations are NetBSD extensions. */
 90#define FUTEX_NETBSD_RW_WAIT 64
 91#define FUTEX_NETBSD_RW_HANDOFF 65
 92
89#define FUTEX_PRIVATE_FLAG __BIT(7) 93#define FUTEX_PRIVATE_FLAG __BIT(7)
90#define FUTEX_CLOCK_REALTIME __BIT(8) 94#define FUTEX_CLOCK_REALTIME __BIT(8)
91 95
92#define FUTEX_CMD_MASK \ 96#define FUTEX_CMD_MASK \
93 (~(FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME)) 97 (~(FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME))
94 98
95#define FUTEX_OP_OP_MASK __BITS(28,31) 99#define FUTEX_OP_OP_MASK __BITS(28,31)
96#define FUTEX_OP_CMP_MASK __BITS(24,27) 100#define FUTEX_OP_CMP_MASK __BITS(24,27)
97#define FUTEX_OP_OPARG_MASK __BITS(12,23) 101#define FUTEX_OP_OPARG_MASK __BITS(12,23)
98#define FUTEX_OP_CMPARG_MASK __BITS(0,11) 102#define FUTEX_OP_CMPARG_MASK __BITS(0,11)
99 103
100#define FUTEX_OP(op, oparg, cmp, cmparg) \ 104#define FUTEX_OP(op, oparg, cmp, cmparg) \
101 (__SHIFTIN(op, FUTEX_OP_OP_MASK) |\ 105 (__SHIFTIN(op, FUTEX_OP_OP_MASK) |\
@@ -123,26 +127,38 @@ @@ -123,26 +127,38 @@
123 * to define information specific to that synchronzation object. 127 * to define information specific to that synchronzation object.
124 * Note that as a result there is a system-wide upper limit of 128 * Note that as a result there is a system-wide upper limit of
125 * 268,435,455 threads (as opposed to 1,073,741,823). 129 * 268,435,455 threads (as opposed to 1,073,741,823).
126 */ 130 */
127#define FUTEX_WAITERS ((int)__BIT(31)) 131#define FUTEX_WAITERS ((int)__BIT(31))
128#define FUTEX_OWNER_DIED ((int)__BIT(30)) 132#define FUTEX_OWNER_DIED ((int)__BIT(30))
129#define FUTEX_SYNCOBJ_1 ((int)__BIT(29)) 133#define FUTEX_SYNCOBJ_1 ((int)__BIT(29))
130#define FUTEX_SYNCOBJ_0 ((int)__BIT(28)) 134#define FUTEX_SYNCOBJ_0 ((int)__BIT(28))
131#define FUTEX_TID_MASK ((int)__BITS(0,27)) 135#define FUTEX_TID_MASK ((int)__BITS(0,27))
132 136
133#define FUTEX_BITSET_MATCH_ANY ((int)__BITS(0,31)) 137#define FUTEX_BITSET_MATCH_ANY ((int)__BITS(0,31))
134 138
135/* 139/*
 140 * The FUTEX_NETBSD_RW_WAIT and FUTEX_NETBSD_RW_HANDOFF operations
 141 * define specific meanings for some of the futex word bits and val3.
 142 *
 143 * (futex & FUTEX_TID_MASK) is the owner in the write-locked case,
 144 * and the count of readers in the read-locked case.
 145 */
 146#define FUTEX_RW_WRITE_LOCKED FUTEX_SYNCOBJ_1
 147#define FUTEX_RW_WRITE_WANTED FUTEX_SYNCOBJ_0
 148#define FUTEX_RW_READER 0
 149#define FUTEX_RW_WRITER 1
 150
 151/*
136 * The robust futex ABI consists of an array of 3 longwords, the address 152 * The robust futex ABI consists of an array of 3 longwords, the address
137 * of which is registered with the kernel on a per-thread basis: 153 * of which is registered with the kernel on a per-thread basis:
138 * 154 *
139 * 0: A pointer to a singly-linked list of "lock entries". If the 155 * 0: A pointer to a singly-linked list of "lock entries". If the
140 * list is empty, this points back to the list itself. 156 * list is empty, this points back to the list itself.
141 * 157 *
142 * 1: An offset from address of the "lock entry" to the 32-bit futex 158 * 1: An offset from address of the "lock entry" to the 32-bit futex
143 * word associated with that lock entry (may be negative). 159 * word associated with that lock entry (may be negative).
144 * 160 *
145 * 2: A "pending" pointer, for locks that are in the process of being 161 * 2: A "pending" pointer, for locks that are in the process of being
146 * acquired or released. 162 * acquired or released.
147 * 163 *
148 * PI futexes are handled slightly differently. User-space indicates 164 * PI futexes are handled slightly differently. User-space indicates