[Midnightbsd-cvs] src [12329] trunk/sys/sys/umtx.h: sync with FreeBSD 11-stable
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Feb 8 14:56:27 EST 2020
Revision: 12329
http://svnweb.midnightbsd.org/src/?rev=12329
Author: laffer1
Date: 2020-02-08 14:56:26 -0500 (Sat, 08 Feb 2020)
Log Message:
-----------
sync with FreeBSD 11-stable
Modified Paths:
--------------
trunk/sys/sys/umtx.h
Modified: trunk/sys/sys/umtx.h
===================================================================
--- trunk/sys/sys/umtx.h 2020-02-08 19:55:14 UTC (rev 12328)
+++ trunk/sys/sys/umtx.h 2020-02-08 19:56:26 UTC (rev 12329)
@@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: stable/10/sys/sys/umtx.h 233912 2012-04-05 02:24:08Z davidxu $
+ * $FreeBSD: stable/11/sys/sys/umtx.h 331722 2018-03-29 02:50:57Z eadler $
*
*/
@@ -32,20 +32,28 @@
#define _SYS_UMTX_H_
#include <sys/_umtx.h>
-#include <sys/limits.h>
-#define UMTX_UNOWNED 0x0
-#define UMTX_CONTESTED LONG_MIN
-
+/* Common lock flags */
#define USYNC_PROCESS_SHARED 0x0001 /* Process shared sync objs */
+/* umutex flags */
+#define UMUTEX_PRIO_INHERIT 0x0004 /* Priority inherited mutex */
+#define UMUTEX_PRIO_PROTECT 0x0008 /* Priority protect mutex */
+#define UMUTEX_ROBUST 0x0010 /* Robust mutex */
+#define UMUTEX_NONCONSISTENT 0x0020 /* Robust locked but not consistent */
+
+/*
+ * The umutex.m_lock values and bits. The m_owner is the word which
+ * serves as the lock. Its high bit is the contention indicator and
+ * rest of bits records the owner TID. TIDs values start with PID_MAX
+ * + 2 and end by INT32_MAX. The low range [1..PID_MAX] is guaranteed
+ * to be useable as the special markers.
+ */
#define UMUTEX_UNOWNED 0x0
#define UMUTEX_CONTESTED 0x80000000U
+#define UMUTEX_RB_OWNERDEAD (UMUTEX_CONTESTED | 0x10)
+#define UMUTEX_RB_NOTRECOV (UMUTEX_CONTESTED | 0x11)
-#define UMUTEX_ERROR_CHECK 0x0002 /* Error-checking mutex */
-#define UMUTEX_PRIO_INHERIT 0x0004 /* Priority inherited mutex */
-#define UMUTEX_PRIO_PROTECT 0x0008 /* Priority protect mutex */
-
/* urwlock flags */
#define URWLOCK_PREFER_READER 0x0002
@@ -58,9 +66,14 @@
/* _usem flags */
#define SEM_NAMED 0x0002
+/* _usem2 count field */
+#define USEM_HAS_WAITERS 0x80000000U
+#define USEM_MAX_COUNT 0x7fffffffU
+#define USEM_COUNT(c) ((c) & USEM_MAX_COUNT)
+
/* op code for _umtx_op */
-#define UMTX_OP_LOCK 0
-#define UMTX_OP_UNLOCK 1
+#define UMTX_OP_RESERVED0 0
+#define UMTX_OP_RESERVED1 1
#define UMTX_OP_WAIT 2
#define UMTX_OP_WAKE 3
#define UMTX_OP_MUTEX_TRYLOCK 4
@@ -78,11 +91,14 @@
#define UMTX_OP_WAKE_PRIVATE 16
#define UMTX_OP_MUTEX_WAIT 17
#define UMTX_OP_MUTEX_WAKE 18 /* deprecated */
-#define UMTX_OP_SEM_WAIT 19
-#define UMTX_OP_SEM_WAKE 20
+#define UMTX_OP_SEM_WAIT 19 /* deprecated */
+#define UMTX_OP_SEM_WAKE 20 /* deprecated */
#define UMTX_OP_NWAKE_PRIVATE 21
#define UMTX_OP_MUTEX_WAKE2 22
-#define UMTX_OP_MAX 23
+#define UMTX_OP_SEM2_WAIT 23
+#define UMTX_OP_SEM2_WAKE 24
+#define UMTX_OP_SHM 25
+#define UMTX_OP_ROBUST_LISTS 26
/* Flags for UMTX_OP_CV_WAIT */
#define CVWAIT_CHECK_UNPARKING 0x01
@@ -93,86 +109,26 @@
#define UMTX_CHECK_UNPARKING CVWAIT_CHECK_UNPARKING
-#ifndef _KERNEL
+/* Flags for UMTX_OP_SHM */
+#define UMTX_SHM_CREAT 0x0001
+#define UMTX_SHM_LOOKUP 0x0002
+#define UMTX_SHM_DESTROY 0x0004
+#define UMTX_SHM_ALIVE 0x0008
-int _umtx_op(void *obj, int op, u_long val, void *uaddr, void *uaddr2);
+struct umtx_robust_lists_params {
+ uintptr_t robust_list_offset;
+ uintptr_t robust_priv_list_offset;
+ uintptr_t robust_inact_offset;
+};
-/*
- * Old (deprecated) userland mutex system calls.
- */
-int _umtx_lock(struct umtx *mtx);
-int _umtx_unlock(struct umtx *mtx);
+#ifndef _KERNEL
-/*
- * Standard api. Try uncontested acquire/release and asks the
- * kernel to resolve failures.
- */
-static __inline void
-umtx_init(struct umtx *umtx)
-{
- umtx->u_owner = UMTX_UNOWNED;
-}
+__BEGIN_DECLS
-static __inline u_long
-umtx_owner(struct umtx *umtx)
-{
- return (umtx->u_owner & ~LONG_MIN);
-}
+int _umtx_op(void *obj, int op, u_long val, void *uaddr, void *uaddr2);
-static __inline int
-umtx_lock(struct umtx *umtx, u_long id)
-{
- if (atomic_cmpset_acq_long(&umtx->u_owner, UMTX_UNOWNED, id) == 0)
- if (_umtx_lock(umtx) == -1)
- return (errno);
- return (0);
-}
+__END_DECLS
-static __inline int
-umtx_trylock(struct umtx *umtx, u_long id)
-{
- if (atomic_cmpset_acq_long(&umtx->u_owner, UMTX_UNOWNED, id) == 0)
- return (EBUSY);
- return (0);
-}
-
-static __inline int
-umtx_timedlock(struct umtx *umtx, u_long id, const struct timespec *timeout)
-{
- if (atomic_cmpset_acq_long(&umtx->u_owner, UMTX_UNOWNED, id) == 0)
- if (_umtx_op(umtx, UMTX_OP_LOCK, id, 0,
- __DECONST(void *, timeout)) == -1)
- return (errno);
- return (0);
-}
-
-static __inline int
-umtx_unlock(struct umtx *umtx, u_long id)
-{
- if (atomic_cmpset_rel_long(&umtx->u_owner, id, UMTX_UNOWNED) == 0)
- if (_umtx_unlock(umtx) == -1)
- return (errno);
- return (0);
-}
-
-static __inline int
-umtx_wait(u_long *p, long val, const struct timespec *timeout)
-{
- if (_umtx_op(p, UMTX_OP_WAIT, val, 0,
- __DECONST(void *, timeout)) == -1)
- return (errno);
- return (0);
-}
-
-/* Wake threads waiting on a user address. */
-static __inline int
-umtx_wake(u_long *p, int nr_wakeup)
-{
- if (_umtx_op(p, UMTX_OP_WAKE, nr_wakeup, 0, 0) == -1)
- return (errno);
- return (0);
-}
-
#else
/*
@@ -189,7 +145,10 @@
TYPE_PI_UMUTEX,
TYPE_PP_UMUTEX,
TYPE_RWLOCK,
- TYPE_FUTEX
+ TYPE_FUTEX,
+ TYPE_SHM,
+ TYPE_PI_ROBUST_UMUTEX,
+ TYPE_PP_ROBUST_UMUTEX,
};
/* Key to represent a unique userland synchronous object */
@@ -228,7 +187,7 @@
}
int umtx_copyin_timeout(const void *, struct timespec *);
-int umtx_key_get(void *, int, int, struct umtx_key *);
+int umtx_key_get(const void *, int, int, struct umtx_key *);
void umtx_key_release(struct umtx_key *);
struct umtx_q *umtxq_alloc(void);
void umtxq_free(struct umtx_q *);
More information about the Midnightbsd-cvs
mailing list