diff options
author | Jack Lloyd <[email protected]> | 2018-01-12 11:21:09 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-01-12 12:10:34 -0500 |
commit | e5c7809ae0734715f4c1ab5fe476e0b04c4b2a59 (patch) | |
tree | 3a236b0356d05869b43add9ae8b1bf25e1fbe8d4 /src/lib | |
parent | 3099e920495c8e881387363de8e1b0bf7d1d5292 (diff) |
Move thread utils (barrier and semaphore) to a subpackage of util
They are not needed except by the filter code so being able to
easily remove them from the build is nice; utils is always compiled
in so that should be as small as possible.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/filters/basefilt.h | 2 | ||||
-rw-r--r-- | src/lib/filters/threaded_fork.cpp | 2 | ||||
-rw-r--r-- | src/lib/utils/info.txt | 2 | ||||
-rw-r--r-- | src/lib/utils/thread_utils/barrier.cpp (renamed from src/lib/utils/barrier.cpp) | 6 | ||||
-rw-r--r-- | src/lib/utils/thread_utils/barrier.h (renamed from src/lib/utils/barrier.h) | 9 | ||||
-rw-r--r-- | src/lib/utils/thread_utils/info.txt | 12 | ||||
-rw-r--r-- | src/lib/utils/thread_utils/semaphore.cpp (renamed from src/lib/utils/semaphore.cpp) | 4 | ||||
-rw-r--r-- | src/lib/utils/thread_utils/semaphore.h (renamed from src/lib/utils/semaphore.h) | 7 |
8 files changed, 17 insertions, 27 deletions
diff --git a/src/lib/filters/basefilt.h b/src/lib/filters/basefilt.h index c3a45e28c..922d35669 100644 --- a/src/lib/filters/basefilt.h +++ b/src/lib/filters/basefilt.h @@ -82,7 +82,7 @@ class BOTAN_PUBLIC_API(2,0) Fork : public Fanout_Filter Fork(Filter* filter_arr[], size_t length); }; -#if defined(BOTAN_TARGET_OS_HAS_THREADS) +#if defined(BOTAN_HAS_THREAD_UTILS) /** * This class is a threaded version of the Fork filter. While this uses diff --git a/src/lib/filters/threaded_fork.cpp b/src/lib/filters/threaded_fork.cpp index d379eacda..35ea94109 100644 --- a/src/lib/filters/threaded_fork.cpp +++ b/src/lib/filters/threaded_fork.cpp @@ -8,7 +8,7 @@ #include <botan/basefilt.h> -#if defined(BOTAN_TARGET_OS_HAS_THREADS) +#if defined(BOTAN_HAS_THREAD_UTILS) #include <botan/internal/semaphore.h> #include <botan/internal/barrier.h> diff --git a/src/lib/utils/info.txt b/src/lib/utils/info.txt index 60a10b058..c9b419dcc 100644 --- a/src/lib/utils/info.txt +++ b/src/lib/utils/info.txt @@ -25,7 +25,6 @@ stl_compatibility.h </header:public> <header:internal> -barrier.h bit_ops.h ct_utils.h donna128.h @@ -34,7 +33,6 @@ os_utils.h prefetch.h rounding.h safeint.h -semaphore.h stl_util.h </header:internal> diff --git a/src/lib/utils/barrier.cpp b/src/lib/utils/thread_utils/barrier.cpp index ed3878d18..a5df95101 100644 --- a/src/lib/utils/barrier.cpp +++ b/src/lib/utils/thread_utils/barrier.cpp @@ -7,8 +7,6 @@ #include <botan/internal/barrier.h> -#if defined(BOTAN_TARGET_OS_HAS_THREADS) - namespace Botan { void Barrier::wait(size_t delta) @@ -20,7 +18,7 @@ void Barrier::wait(size_t delta) void Barrier::sync() { std::unique_lock<mutex_type> lock(m_mutex); - + if(m_value > 1) { --m_value; @@ -36,5 +34,3 @@ void Barrier::sync() } } - -#endif diff --git a/src/lib/utils/barrier.h b/src/lib/utils/thread_utils/barrier.h index 943d10b0c..874aa8abd 100644 --- a/src/lib/utils/barrier.h +++ b/src/lib/utils/thread_utils/barrier.h @@ -9,15 +9,10 @@ #define BOTAN_UTIL_BARRIER_H_ #include <botan/mutex.h> - -#if defined(BOTAN_TARGET_OS_HAS_THREADS) - #include <condition_variable> -#endif +#include <condition_variable> namespace Botan { -#if defined(BOTAN_TARGET_OS_HAS_THREADS) - /** Barrier implements a barrier synchronization primitive. wait() will indicate how many threads to synchronize; each thread needing @@ -42,8 +37,6 @@ class Barrier final std::condition_variable m_cond; }; -#endif - } #endif diff --git a/src/lib/utils/thread_utils/info.txt b/src/lib/utils/thread_utils/info.txt new file mode 100644 index 000000000..826a9d734 --- /dev/null +++ b/src/lib/utils/thread_utils/info.txt @@ -0,0 +1,12 @@ +<defines> +THREAD_UTILS -> 20180112 +</defines> + +<header:internal> +barrier.h +semaphore.h +</header:internal> + +<os_features> +threads +</os_features> diff --git a/src/lib/utils/semaphore.cpp b/src/lib/utils/thread_utils/semaphore.cpp index e990ded41..9a7af188a 100644 --- a/src/lib/utils/semaphore.cpp +++ b/src/lib/utils/thread_utils/semaphore.cpp @@ -7,8 +7,6 @@ #include <botan/internal/semaphore.h> -#if defined(BOTAN_TARGET_OS_HAS_THREADS) - // Based on code by Pierre Gaston (http://p9as.blogspot.com/2012/06/c11-semaphores.html) namespace Botan { @@ -38,5 +36,3 @@ void Semaphore::acquire() } } - -#endif diff --git a/src/lib/utils/semaphore.h b/src/lib/utils/thread_utils/semaphore.h index 431680cb3..9db34826a 100644 --- a/src/lib/utils/semaphore.h +++ b/src/lib/utils/thread_utils/semaphore.h @@ -9,14 +9,10 @@ #define BOTAN_SEMAPHORE_H_ #include <botan/mutex.h> - -#if defined(BOTAN_TARGET_OS_HAS_THREADS) - #include <condition_variable> -#endif +#include <condition_variable> namespace Botan { -#if defined(BOTAN_TARGET_OS_HAS_THREADS) class Semaphore final { public: @@ -32,7 +28,6 @@ class Semaphore final mutex_type m_mutex; std::condition_variable m_cond; }; -#endif } |