From c9bbe8eb574fe10ff16cc71a23fcc9b31fb8ed04 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 5 Dec 2021 22:11:24 -0500 Subject: Use static initialization for lists and mutexes. This eliminates some run-time initialization, moving it to compile time. Additional follow up work will expand on this to simplify initialization and reduce the need for certain locks. --- src/platform/posix/posix_impl.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/platform/posix/posix_impl.h') 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; -- cgit v1.2.3-70-g09d2