diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-08-15 02:16:23 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-08-15 02:16:23 -0400 |
commit | 6c1d2549df546b6d2628582c9b078753eecd16f4 (patch) | |
tree | 4b0fbbc37f61ee5170292e32aef3dd9b3e8c44df /src | |
parent | b4362b99cf1857f2fdf4390796bbf64ac9f204f3 (diff) | |
parent | 1868982de6c538b75ab599b332fa896492608620 (diff) | |
download | tor-6c1d2549df546b6d2628582c9b078753eecd16f4.tar.gz tor-6c1d2549df546b6d2628582c9b078753eecd16f4.zip |
Merge branch 'maint-0.3.3' into maint-0.3.4
Diffstat (limited to 'src')
-rw-r--r-- | src/common/compat_threads.c | 5 | ||||
-rw-r--r-- | src/common/compat_threads.h | 19 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/common/compat_threads.c b/src/common/compat_threads.c index 3171c4b2f2..9f64c06342 100644 --- a/src/common/compat_threads.c +++ b/src/common/compat_threads.c @@ -352,7 +352,7 @@ alert_sockets_close(alert_sockets_t *socks) socks->read_fd = socks->write_fd = -1; } -#ifndef HAVE_STDATOMIC_H +#ifndef HAVE_WORKING_STDATOMIC /** Initialize a new atomic counter with the value 0 */ void atomic_counter_init(atomic_counter_t *counter) @@ -403,5 +403,4 @@ atomic_counter_exchange(atomic_counter_t *counter, size_t newval) tor_mutex_release(&counter->mutex); return oldval; } -#endif /* !defined(HAVE_STDATOMIC_H) */ - +#endif /* !defined(HAVE_WORKING_STDATOMIC) */ diff --git a/src/common/compat_threads.h b/src/common/compat_threads.h index c93e601ec5..8bf8225689 100644 --- a/src/common/compat_threads.h +++ b/src/common/compat_threads.h @@ -14,7 +14,11 @@ #include <pthread.h> #endif -#ifdef HAVE_STDATOMIC_H +#if defined(HAVE_STDATOMIC_H) && defined(STDATOMIC_WORKS) +#define HAVE_WORKING_STDATOMIC +#endif + +#ifdef HAVE_WORKING_STDATOMIC #include <stdatomic.h> #endif @@ -156,18 +160,18 @@ void tor_threadlocal_set(tor_threadlocal_t *threadlocal, void *value); /** * Atomic counter type; holds a size_t value. */ -#ifdef HAVE_STDATOMIC_H +#ifdef HAVE_WORKING_STDATOMIC typedef struct atomic_counter_t { atomic_size_t val; } atomic_counter_t; #define ATOMIC_LINKAGE static -#else /* !(defined(HAVE_STDATOMIC_H)) */ +#else /* !(defined(HAVE_WORKING_STDATOMIC)) */ typedef struct atomic_counter_t { tor_mutex_t mutex; size_t val; } atomic_counter_t; #define ATOMIC_LINKAGE -#endif /* defined(HAVE_STDATOMIC_H) */ +#endif /* defined(HAVE_WORKING_STDATOMIC) */ ATOMIC_LINKAGE void atomic_counter_init(atomic_counter_t *counter); ATOMIC_LINKAGE void atomic_counter_destroy(atomic_counter_t *counter); @@ -178,7 +182,7 @@ ATOMIC_LINKAGE size_t atomic_counter_exchange(atomic_counter_t *counter, size_t newval); #undef ATOMIC_LINKAGE -#ifdef HAVE_STDATOMIC_H +#ifdef HAVE_WORKING_STDATOMIC /** Initialize a new atomic counter with the value 0 */ static inline void atomic_counter_init(atomic_counter_t *counter) @@ -216,8 +220,7 @@ atomic_counter_exchange(atomic_counter_t *counter, size_t newval) return atomic_exchange(&counter->val, newval); } -#else /* !(defined(HAVE_STDATOMIC_H)) */ -#endif /* defined(HAVE_STDATOMIC_H) */ +#else /* !(defined(HAVE_WORKING_STDATOMIC)) */ +#endif /* defined(HAVE_WORKING_STDATOMIC) */ #endif /* !defined(TOR_COMPAT_THREADS_H) */ - |