diff options
| author | Garrett D'Amore <garrett@damore.org> | 2016-12-22 01:57:10 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2016-12-22 01:57:10 -0800 |
| commit | 101c1b6a946d9f2f48c6dd89940ae669141e0511 (patch) | |
| tree | 4da688859d87526d03d724ab1a729c6846650eae /src/platform/posix/posix_synch.c | |
| parent | b92672e20420683e73bfc017956ac6ef2b6b793b (diff) | |
| download | nng-101c1b6a946d9f2f48c6dd89940ae669141e0511.tar.gz nng-101c1b6a946d9f2f48c6dd89940ae669141e0511.tar.bz2 nng-101c1b6a946d9f2f48c6dd89940ae669141e0511.zip | |
Use C99 structure initializers FTW. Various other changes.
Diffstat (limited to 'src/platform/posix/posix_synch.c')
| -rw-r--r-- | src/platform/posix/posix_synch.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/platform/posix/posix_synch.c b/src/platform/posix/posix_synch.c index 555da36b..13147573 100644 --- a/src/platform/posix/posix_synch.c +++ b/src/platform/posix/posix_synch.c @@ -26,14 +26,27 @@ #include <pthread.h> #include <time.h> -struct nni_mutex { - pthread_mutex_t mx; -}; +int +nni_mutex_init(nni_mutex *mp) +{ + // pthrad_mutex_attr_t attr; + if (pthread_mutex_init(&mp->mx, NULL) != NULL) { + return (NNG_ENOMEM); + } + return (0); +} + + +void +nni_mutex_fini(nni_mutex *mp) +{ + int rv; + + if ((rv = pthread_mutex_destroy(&mp-- > mx)) != 0) { + nni_panic("pthread_mutex_destroy failed: %s", strerror(rv)); + } +} -struct nni_cond { - pthread_cond_t cv; - pthread_mutex_t * mx; -}; int nni_mutex_create(nni_mutex_t *mp) @@ -109,8 +122,8 @@ nni_mutex_tryenter(nni_mutex_t m) } -int -cond_attr(pthread_condattr_t **attrpp) +static int +nni_cond_attr(pthread_condattr_t **attrpp) { #if defined(NNG_USE_GETTIMEOFDAY) || NNG_USE_CLOCKID == CLOCK_REALTIME *attrpp = NULL; |
