Kill unused _wait() and use *_PRIVATE in both places.
Using the non-private version of this interface means an extra
uvm_map lookup is done. This isn't required for threads of the
same process.
Ok?
Index: lib/libc/thread/synch.h
===================================================================
RCS file: /cvs/src/lib/libc/thread/synch.h,v
retrieving revision 1.3
diff -u -p -r1.3 synch.h
--- lib/libc/thread/synch.h 4 Jun 2018 22:08:56 -0000 1.3
+++ lib/libc/thread/synch.h 21 Sep 2019 19:25:45 -0000
@@ -25,13 +25,6 @@ _wake(volatile uint32_t *p, int n)
return futex(p, FUTEX_WAKE_PRIVATE, n, NULL, NULL);
}
-static inline void
-_wait(volatile uint32_t *p, int val)
-{
- while (*p != (uint32_t)val)
- futex(p, FUTEX_WAIT_PRIVATE, val, NULL, NULL);
-}
-
static inline int
_twait(volatile uint32_t *p, int val, clockid_t clockid, const struct timespec
*abs)
{
Index: lib/librthread/synch.h
===================================================================
RCS file: /cvs/src/lib/librthread/synch.h,v
retrieving revision 1.4
diff -u -p -r1.4 synch.h
--- lib/librthread/synch.h 8 Jun 2018 13:53:01 -0000 1.4
+++ lib/librthread/synch.h 21 Sep 2019 19:25:46 -0000
@@ -22,14 +22,7 @@
static inline int
_wake(volatile uint32_t *p, int n)
{
- return futex(p, FUTEX_WAKE, n, NULL, NULL);
-}
-
-static inline void
-_wait(volatile uint32_t *p, int val)
-{
- while (*p != (uint32_t)val)
- futex(p, FUTEX_WAIT, val, NULL, NULL);
+ return futex(p, FUTEX_WAKE_PRIVATE, n, NULL, NULL);
}
static inline int
@@ -38,7 +31,7 @@ _twait(volatile uint32_t *p, int val, cl
struct timespec rel;
if (abs == NULL)
- return futex(p, FUTEX_WAIT, val, NULL, NULL);
+ return futex(p, FUTEX_WAIT_PRIVATE, val, NULL, NULL);
if (abs->tv_nsec >= 1000000000 || clock_gettime(clockid, &rel))
return (EINVAL);
@@ -51,11 +44,11 @@ _twait(volatile uint32_t *p, int val, cl
if (rel.tv_sec < 0)
return (ETIMEDOUT);
- return futex(p, FUTEX_WAIT, val, &rel, NULL);
+ return futex(p, FUTEX_WAIT_PRIVATE, val, &rel, NULL);
}
static inline int
_requeue(volatile uint32_t *p, int n, int m, volatile uint32_t *q)
{
- return futex(p, FUTEX_REQUEUE, n, (void *)(long)m, q);
+ return futex(p, FUTEX_REQUEUE_PRIVATE, n, (void *)(long)m, q);
}