diff options
Diffstat (limited to 'src/platform')
| -rw-r--r-- | src/platform/posix/posix_impl.h | 6 | ||||
| -rw-r--r-- | src/platform/posix/posix_thread.c | 2 | ||||
| -rw-r--r-- | src/platform/windows/win_impl.h | 6 | ||||
| -rw-r--r-- | src/platform/windows/win_thread.c | 2 |
4 files changed, 11 insertions, 5 deletions
diff --git a/src/platform/posix/posix_impl.h b/src/platform/posix/posix_impl.h index 234d1501..97924a45 100644 --- a/src/platform/posix/posix_impl.h +++ b/src/platform/posix/posix_impl.h @@ -58,10 +58,16 @@ struct nni_plat_mtx { pthread_mutex_t mtx; }; +#define NNI_MTX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER } + struct nni_rwlock { pthread_rwlock_t rwl; }; +#define NNI_RWLOCK_INITIALIZER { PTHREAD_RWLOCK_INITIALIZER } + +// 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; diff --git a/src/platform/posix/posix_thread.c b/src/platform/posix/posix_thread.c index c47bcec6..b7cd5e1e 100644 --- a/src/platform/posix/posix_thread.c +++ b/src/platform/posix/posix_thread.c @@ -34,7 +34,7 @@ #endif static pthread_mutex_t nni_plat_init_lock = PTHREAD_MUTEX_INITIALIZER; -static int nni_plat_inited = 0; +static volatile int nni_plat_inited = 0; static int nni_plat_forked = 0; pthread_condattr_t nni_cvattr; diff --git a/src/platform/windows/win_impl.h b/src/platform/windows/win_impl.h index 608a065e..b3c08edf 100644 --- a/src/platform/windows/win_impl.h +++ b/src/platform/windows/win_impl.h @@ -37,15 +37,17 @@ struct nni_plat_thr { struct nni_plat_mtx { SRWLOCK srl; - DWORD owner; - int init; }; +#define NNI_MTX_INITIALIZER { SRWLOCK_INIT } + struct nni_rwlock { SRWLOCK rwl; BOOLEAN exclusive; }; +#define NNI_RWLOCK_INITIALIZER { SRWLOCK_INIT } + struct nni_plat_cv { CONDITION_VARIABLE cv; PSRWLOCK srl; diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c index 31e783a3..b131c067 100644 --- a/src/platform/windows/win_thread.c +++ b/src/platform/windows/win_thread.c @@ -55,13 +55,11 @@ void nni_plat_mtx_init(nni_plat_mtx *mtx) { InitializeSRWLock(&mtx->srl); - mtx->init = 1; } void nni_plat_mtx_fini(nni_plat_mtx *mtx) { - mtx->init = 0; } void |
