diff options
Diffstat (limited to 'src/lib/thread')
-rw-r--r-- | src/lib/thread/compat_pthreads.c | 2 | ||||
-rw-r--r-- | src/lib/thread/compat_threads.c | 6 | ||||
-rw-r--r-- | src/lib/thread/compat_winthreads.c | 2 | ||||
-rw-r--r-- | src/lib/thread/numcpus.c | 7 | ||||
-rw-r--r-- | src/lib/thread/numcpus.h | 5 | ||||
-rw-r--r-- | src/lib/thread/threads.h | 23 |
6 files changed, 32 insertions, 13 deletions
diff --git a/src/lib/thread/compat_pthreads.c b/src/lib/thread/compat_pthreads.c index 246c6254bb..934067e4c1 100644 --- a/src/lib/thread/compat_pthreads.c +++ b/src/lib/thread/compat_pthreads.c @@ -12,7 +12,7 @@ #include "orconfig.h" #include "lib/thread/threads.h" -#include "lib/log/torlog.h" +#include "lib/log/log.h" #include "lib/log/util_bug.h" #include <sys/time.h> diff --git a/src/lib/thread/compat_threads.c b/src/lib/thread/compat_threads.c index 972960e242..7f1970af45 100644 --- a/src/lib/thread/compat_threads.c +++ b/src/lib/thread/compat_threads.c @@ -15,7 +15,7 @@ #include <stdlib.h> #include "lib/thread/threads.h" -#include "lib/log/torlog.h" +#include "lib/log/log.h" #include "lib/log/util_bug.h" #include <string.h> @@ -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/compat_winthreads.c b/src/lib/thread/compat_winthreads.c index 7f9877d21e..799eeda1b4 100644 --- a/src/lib/thread/compat_winthreads.c +++ b/src/lib/thread/compat_winthreads.c @@ -15,7 +15,7 @@ #include <windows.h> #include <process.h> #include "lib/thread/threads.h" -#include "lib/log/torlog.h" +#include "lib/log/log.h" #include "lib/log/util_bug.h" #include "lib/log/win32err.h" diff --git a/src/lib/thread/numcpus.c b/src/lib/thread/numcpus.c index 534b0570f8..cca15eb7aa 100644 --- a/src/lib/thread/numcpus.c +++ b/src/lib/thread/numcpus.c @@ -3,9 +3,14 @@ * Copyright (c) 2007-2018, The Tor Project, Inc. */ /* See LICENSE for licensing information */ +/** + * \file numcpus.c + * \brief Compute the number of CPUs configured on this system. + **/ + #include "orconfig.h" #include "lib/thread/numcpus.h" -#include "lib/log/torlog.h" +#include "lib/log/log.h" #include "lib/log/util_bug.h" #ifdef HAVE_UNISTD_H diff --git a/src/lib/thread/numcpus.h b/src/lib/thread/numcpus.h index 2899a9ec8a..0b026e4249 100644 --- a/src/lib/thread/numcpus.h +++ b/src/lib/thread/numcpus.h @@ -3,6 +3,11 @@ * Copyright (c) 2007-2018, The Tor Project, Inc. */ /* See LICENSE for licensing information */ +/** + * \file numcpus.h + * \brief Header for numcpus.c + **/ + #ifndef TOR_NUMCPUS_H #define TOR_NUMCPUS_H diff --git a/src/lib/thread/threads.h b/src/lib/thread/threads.h index fcccc643d5..4d5191124c 100644 --- a/src/lib/thread/threads.h +++ b/src/lib/thread/threads.h @@ -3,6 +3,11 @@ * Copyright (c) 2007-2018, The Tor Project, Inc. */ /* See LICENSE for licensing information */ +/** + * \file threads.h + * \brief Header for threads.c + **/ + #ifndef TOR_COMPAT_THREADS_H #define TOR_COMPAT_THREADS_H @@ -11,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 @@ -93,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); @@ -115,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) @@ -153,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) */ |