diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-08-08 15:50:29 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-08-08 15:50:29 -0400 |
commit | 26f1167e7151791a04a2c8584360f37602320779 (patch) | |
tree | 0eb3173a5cba9213b7db0ee35ae0917e1489391b /src/lib/thread | |
parent | 7787150521fda0370331dab80d043294e05e1598 (diff) | |
parent | b66386865e68d8df0f228187781fcd5bc2dbf184 (diff) | |
download | tor-26f1167e7151791a04a2c8584360f37602320779.tar.gz tor-26f1167e7151791a04a2c8584360f37602320779.zip |
Merge branch 'bug26779_033' into bug26779_035
Diffstat (limited to 'src/lib/thread')
-rw-r--r-- | src/lib/thread/compat_threads.c | 4 | ||||
-rw-r--r-- | src/lib/thread/threads.h | 18 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/lib/thread/compat_threads.c b/src/lib/thread/compat_threads.c index 24129946b2..7f1970af45 100644 --- a/src/lib/thread/compat_threads.c +++ b/src/lib/thread/compat_threads.c @@ -57,7 +57,7 @@ in_main_thread(void) return main_thread_id == tor_get_thread_id(); } -#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) @@ -108,4 +108,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/lib/thread/threads.h b/src/lib/thread/threads.h index 89d2a9d93e..4d5191124c 100644 --- a/src/lib/thread/threads.h +++ b/src/lib/thread/threads.h @@ -16,7 +16,11 @@ #include "lib/testsupport/testsupport.h" #include "lib/lock/compat_mutex.h" -#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 @@ -98,18 +102,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); @@ -120,7 +124,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) @@ -158,7 +162,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) */ |