aboutsummaryrefslogtreecommitdiff
path: root/src/platform/posix/posix_impl.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2021-12-08 12:01:32 -0500
committerGarrett D'Amore <garrett@damore.org>2021-12-08 20:08:47 -0500
commitdc91bed46dd12fdc843b9e2c4ed9f3e570914ba3 (patch)
tree7bc1d46d7a4edeee347f3b3c6daca9c832e7a341 /src/platform/posix/posix_impl.h
parent317fdb2ff02c98d88a3950791e938b1db3cca1cd (diff)
downloadnng-dc91bed46dd12fdc843b9e2c4ed9f3e570914ba3.tar.gz
nng-dc91bed46dd12fdc843b9e2c4ed9f3e570914ba3.tar.bz2
nng-dc91bed46dd12fdc843b9e2c4ed9f3e570914ba3.zip
Could use GCC atomics for older versions of GCC.
This should help greatly with performance on older systems such as CentOS 7 and GCC 4.8. Though, such folks really should update to newer compilers. Folks running version of GCC earlier than 4.7 will still pay a rather significant performance penalty, as they still implement atomics with a global mutex.
Diffstat (limited to 'src/platform/posix/posix_impl.h')
-rw-r--r--src/platform/posix/posix_impl.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/platform/posix/posix_impl.h b/src/platform/posix/posix_impl.h
index 0ee7cb38..afbdce97 100644
--- a/src/platform/posix/posix_impl.h
+++ b/src/platform/posix/posix_impl.h
@@ -58,13 +58,19 @@ struct nni_plat_mtx {
pthread_mutex_t mtx;
};
-#define NNI_MTX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER }
+#define NNI_MTX_INITIALIZER \
+ { \
+ PTHREAD_MUTEX_INITIALIZER \
+ }
struct nni_rwlock {
pthread_rwlock_t rwl;
};
-#define NNI_RWLOCK_INITIALIZER { PTHREAD_RWLOCK_INITIALIZER }
+#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.
@@ -76,7 +82,10 @@ struct nni_plat_cv {
// 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, .cv = PTHREAD_COND_INITIALIZER \
+ }
struct nni_plat_thr {
pthread_t tid;
@@ -91,7 +100,6 @@ struct nni_plat_flock {
#define NNG_PLATFORM_DIR_SEP "/"
#ifdef NNG_HAVE_STDATOMIC
-
#include <stdatomic.h>
struct nni_atomic_flag {