svn commit: r300971 - head/lib/libthr/thread
Konstantin Belousov
kib at FreeBSD.org
Sun May 29 19:35:56 UTC 2016
Author: kib
Date: Sun May 29 19:35:55 2016
New Revision: 300971
URL: https://svnweb.freebsd.org/changeset/base/300971
Log:
Stop inlining the struct ucond definition into struct pthread_cond.
This avoids unneccessary casts and make the calls to _thr_ucond_*()
functions less questionable.
The c_spare field was not included into struct pthread_cond, so the
change modifies libthr ABI for shared condvars. But since an off-page
does not legitimately contains any other data past the struct
pthread_cond, the change keeps shared condvars from pre- and post-
changed libthr compatible. Also note that the whole struct ucond was
never copied in or out by kernel.
For private condvars, the privately allocated memory was never exposed
outside libthr.
Sponsored by: The FreeBSD Foundation
Modified:
head/lib/libthr/thread/thr_cond.c
head/lib/libthr/thread/thr_private.h
Modified: head/lib/libthr/thread/thr_cond.c
==============================================================================
--- head/lib/libthr/thread/thr_cond.c Sun May 29 18:25:11 2016 (r300970)
+++ head/lib/libthr/thread/thr_cond.c Sun May 29 19:35:55 2016 (r300971)
@@ -69,18 +69,18 @@ __weak_reference(_pthread_cond_destroy,
__weak_reference(_pthread_cond_signal, pthread_cond_signal);
__weak_reference(_pthread_cond_broadcast, pthread_cond_broadcast);
-#define CV_PSHARED(cvp) (((cvp)->__flags & USYNC_PROCESS_SHARED) != 0)
+#define CV_PSHARED(cvp) (((cvp)->kcond.c_flags & USYNC_PROCESS_SHARED) != 0)
static void
cond_init_body(struct pthread_cond *cvp, const struct pthread_cond_attr *cattr)
{
if (cattr == NULL) {
- cvp->__clock_id = CLOCK_REALTIME;
+ cvp->kcond.c_clockid = CLOCK_REALTIME;
} else {
if (cattr->c_pshared)
- cvp->__flags |= USYNC_PROCESS_SHARED;
- cvp->__clock_id = cattr->c_clockid;
+ cvp->kcond.c_flags |= USYNC_PROCESS_SHARED;
+ cvp->kcond.c_clockid = cattr->c_clockid;
}
}
@@ -205,9 +205,8 @@ cond_wait_kernel(struct pthread_cond *cv
if (cancel)
_thr_cancel_enter2(curthread, 0);
- error = _thr_ucond_wait((struct ucond *)&cvp->__has_kern_waiters,
- (struct umutex *)&mp->m_lock, abstime, CVWAIT_ABSTIME |
- CVWAIT_CLOCKID);
+ error = _thr_ucond_wait(&cvp->kcond, &mp->m_lock, abstime,
+ CVWAIT_ABSTIME | CVWAIT_CLOCKID);
if (cancel)
_thr_cancel_leave(curthread, 0);
@@ -292,7 +291,7 @@ cond_wait_user(struct pthread_cond *cvp,
if (cancel)
_thr_cancel_enter2(curthread, 0);
- error = _thr_sleep(curthread, cvp->__clock_id, abstime);
+ error = _thr_sleep(curthread, cvp->kcond.c_clockid, abstime);
if (cancel)
_thr_cancel_leave(curthread, 0);
@@ -349,8 +348,7 @@ cond_wait_common(pthread_cond_t *cond, p
if (curthread->attr.sched_policy != SCHED_OTHER ||
(mp->m_lock.m_flags & (UMUTEX_PRIO_PROTECT | UMUTEX_PRIO_INHERIT |
- USYNC_PROCESS_SHARED)) != 0 ||
- (cvp->__flags & USYNC_PROCESS_SHARED) != 0)
+ USYNC_PROCESS_SHARED)) != 0 || CV_PSHARED(cvp))
return (cond_wait_kernel(cvp, mp, abstime, cancel));
else
return (cond_wait_user(cvp, mp, abstime, cancel));
@@ -413,7 +411,7 @@ cond_signal_common(pthread_cond_t *cond)
pshared = CV_PSHARED(cvp);
- _thr_ucond_signal((struct ucond *)&cvp->__has_kern_waiters);
+ _thr_ucond_signal(&cvp->kcond);
if (pshared || cvp->__has_user_waiters == 0)
return (0);
@@ -496,7 +494,7 @@ cond_broadcast_common(pthread_cond_t *co
pshared = CV_PSHARED(cvp);
- _thr_ucond_broadcast((struct ucond *)&cvp->__has_kern_waiters);
+ _thr_ucond_broadcast(&cvp->kcond);
if (pshared || cvp->__has_user_waiters == 0)
return (0);
Modified: head/lib/libthr/thread/thr_private.h
==============================================================================
--- head/lib/libthr/thread/thr_private.h Sun May 29 18:25:11 2016 (r300970)
+++ head/lib/libthr/thread/thr_private.h Sun May 29 19:35:55 2016 (r300971)
@@ -190,9 +190,7 @@ struct pthread_mutex_attr {
struct pthread_cond {
__uint32_t __has_user_waiters;
- __uint32_t __has_kern_waiters;
- __uint32_t __flags;
- __uint32_t __clock_id;
+ struct ucond kcond;
};
struct pthread_cond_attr {
More information about the svn-src-head
mailing list