aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/platform/posix/posix_impl.h10
-rw-r--r--src/platform/posix/posix_thread.c8
2 files changed, 9 insertions, 9 deletions
diff --git a/src/platform/posix/posix_impl.h b/src/platform/posix/posix_impl.h
index a0bb3217..4cac6beb 100644
--- a/src/platform/posix/posix_impl.h
+++ b/src/platform/posix/posix_impl.h
@@ -77,16 +77,16 @@ struct nni_rwlock {
// No static form of CV initialization because of the need to use
// attributes to set the clock type.
struct nni_plat_cv {
- pthread_cond_t cv;
- nni_plat_mtx *mtx;
+ pthread_cond_t cv;
+ pthread_mutex_t *mtx;
};
// NOTE: condition variables initialized with this should *NOT*
// be used with nni_cv_until -- the clock attributes are not passed
// and the wake-up times will not be correct.
-#define NNI_CV_INITIALIZER(mxp) \
- { \
- .mtx = mxp, .cv = PTHREAD_COND_INITIALIZER \
+#define NNI_CV_INITIALIZER(mxp) \
+ { \
+ .mtx = &((mxp)->mtx), .cv = PTHREAD_COND_INITIALIZER \
}
struct nni_plat_thr {
diff --git a/src/platform/posix/posix_thread.c b/src/platform/posix/posix_thread.c
index 5238d624..e8c9036c 100644
--- a/src/platform/posix/posix_thread.c
+++ b/src/platform/posix/posix_thread.c
@@ -1,5 +1,5 @@
//
-// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -211,7 +211,7 @@ nni_plat_cv_init(nni_plat_cv *cv, nni_plat_mtx *mtx)
while (pthread_cond_init(&cv->cv, &nni_cvattr) != 0) {
nni_msleep(10);
}
- cv->mtx = mtx;
+ cv->mtx = &mtx->mtx;
}
void
@@ -229,7 +229,7 @@ nni_plat_cv_wake1(nni_plat_cv *cv)
void
nni_plat_cv_wait(nni_plat_cv *cv)
{
- nni_pthread_cond_wait(&cv->cv, &cv->mtx->mtx);
+ nni_pthread_cond_wait(&cv->cv, cv->mtx);
}
int
@@ -241,7 +241,7 @@ nni_plat_cv_until(nni_plat_cv *cv, nni_time until)
ts.tv_sec = until / 1000;
ts.tv_nsec = (until % 1000) * 1000000;
- return (nni_pthread_cond_timedwait(&cv->cv, &cv->mtx->mtx, &ts));
+ return (nni_pthread_cond_timedwait(&cv->cv, cv->mtx, &ts));
}
void