diff options
author | lloyd <[email protected]> | 2009-04-01 15:43:27 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-04-01 15:43:27 +0000 |
commit | 99e8c1a20700631103ec20386f8080eeee4df588 (patch) | |
tree | bc3ecc536cb98a39c2707dc8eba08e3a648a5c45 /src | |
parent | 855b569d25b5810213ae7e52c04df4e5e0cf8d46 (diff) |
Remove the mutex classes in favor of C++0x's std::mutex and std::lock_guard
Diffstat (limited to 'src')
25 files changed, 51 insertions, 545 deletions
diff --git a/src/algo_factory/algo_cache.h b/src/algo_factory/algo_cache.h index 17ea9964a..97e14f85a 100644 --- a/src/algo_factory/algo_cache.h +++ b/src/algo_factory/algo_cache.h @@ -5,8 +5,9 @@ #ifndef BOTAN_ALGORITHM_CACHE_TEMPLATE_H__ #define BOTAN_ALGORITHM_CACHE_TEMPLATE_H__ -#include <botan/mutex.h> +#include <botan/types.h> #include <botan/stl_util.h> +#include <mutex> #include <string> #include <vector> #include <map> @@ -47,7 +48,6 @@ class Algorithm_Cache */ std::vector<std::string> providers_of(const std::string& algo_name); - Algorithm_Cache(Mutex* m) : mutex(m) {} ~Algorithm_Cache(); private: typedef typename std::map<std::string, std::map<std::string, T*> >::iterator @@ -57,7 +57,7 @@ class Algorithm_Cache algorithms_iterator find_algorithm(const std::string& algo_spec); - Mutex* mutex; + std::mutex mutex; std::map<std::string, std::string> aliases; std::map<std::string, std::string> pref_providers; std::map<std::string, std::map<std::string, T*> > algorithms; @@ -93,7 +93,7 @@ template<typename T> const T* Algorithm_Cache<T>::get(const std::string& algo_spec, const std::string& requested_provider) { - Mutex_Holder lock(mutex); + std::lock_guard<std::mutex> lock(mutex); algorithms_iterator algo = find_algorithm(algo_spec); if(algo == algorithms.end()) // algo not found at all (no providers) @@ -145,7 +145,7 @@ void Algorithm_Cache<T>::add(T* algo, if(!algo) return; - Mutex_Holder lock(mutex); + std::lock_guard<std::mutex> lock(mutex); delete algorithms[algo->name()][provider]; algorithms[algo->name()][provider] = algo; @@ -163,7 +163,7 @@ void Algorithm_Cache<T>::add(T* algo, template<typename T> std::vector<std::string> Algorithm_Cache<T>::providers_of(const std::string& algo_name) { - Mutex_Holder lock(mutex); + std::lock_guard<std::mutex> lock(mutex); std::vector<std::string> providers; @@ -190,7 +190,7 @@ template<typename T> void Algorithm_Cache<T>::set_preferred_provider(const std::string& algo_spec, const std::string& provider) { - Mutex_Holder lock(mutex); + std::lock_guard<std::mutex> lock(mutex); pref_providers[algo_spec] = provider; } @@ -215,8 +215,6 @@ Algorithm_Cache<T>::~Algorithm_Cache() ++algo; } - - delete mutex; } } diff --git a/src/algo_factory/algo_factory.cpp b/src/algo_factory/algo_factory.cpp index 269c58c3b..71bd26827 100644 --- a/src/algo_factory/algo_factory.cpp +++ b/src/algo_factory/algo_factory.cpp @@ -80,15 +80,14 @@ const T* factory_prototype(const std::string& algo_spec, /** * Setup caches */ -Algorithm_Factory::Algorithm_Factory(const std::vector<Engine*>& engines_in, - Mutex_Factory& mf) +Algorithm_Factory::Algorithm_Factory(const std::vector<Engine*>& engines_in) { engines = engines_in; - block_cipher_cache = new Algorithm_Cache<BlockCipher>(mf.make()); - stream_cipher_cache = new Algorithm_Cache<StreamCipher>(mf.make()); - hash_cache = new Algorithm_Cache<HashFunction>(mf.make()); - mac_cache = new Algorithm_Cache<MessageAuthenticationCode>(mf.make()); + block_cipher_cache = new Algorithm_Cache<BlockCipher>(); + stream_cipher_cache = new Algorithm_Cache<StreamCipher>(); + hash_cache = new Algorithm_Cache<HashFunction>(); + mac_cache = new Algorithm_Cache<MessageAuthenticationCode>(); } /** diff --git a/src/algo_factory/algo_factory.h b/src/algo_factory/algo_factory.h index 73e592013..1f4b577ee 100644 --- a/src/algo_factory/algo_factory.h +++ b/src/algo_factory/algo_factory.h @@ -8,7 +8,7 @@ #ifndef BOTAN_ALGORITHM_FACTORY_H__ #define BOTAN_ALGORITHM_FACTORY_H__ -#include <botan/mutex.h> +#include <botan/types.h> #include <string> #include <vector> @@ -37,8 +37,7 @@ class BOTAN_DLL Algorithm_Factory * @param engines_in the list of engines to use * @param mf a mutex factory */ - Algorithm_Factory(const std::vector<Engine*>& engines_in, - Mutex_Factory& mf); + Algorithm_Factory(const std::vector<Engine*>& engines_in); /** * Destructor diff --git a/src/alloc/alloc_mmap/mmap_mem.h b/src/alloc/alloc_mmap/mmap_mem.h index bef166a16..30e6d9ebb 100644 --- a/src/alloc/alloc_mmap/mmap_mem.h +++ b/src/alloc/alloc_mmap/mmap_mem.h @@ -18,7 +18,6 @@ namespace Botan { class BOTAN_DLL MemoryMapping_Allocator : public Pooling_Allocator { public: - MemoryMapping_Allocator(Mutex* m) : Pooling_Allocator(m) {} std::string type() const { return "mmap"; } private: void* alloc_block(u32bit); diff --git a/src/alloc/mem_pool/mem_pool.cpp b/src/alloc/mem_pool/mem_pool.cpp index 38e0c3285..a3858add6 100644 --- a/src/alloc/mem_pool/mem_pool.cpp +++ b/src/alloc/mem_pool/mem_pool.cpp @@ -109,7 +109,7 @@ void Pooling_Allocator::Memory_Block::free(void* ptr, u32bit blocks) throw() /* * Pooling_Allocator Constructor */ -Pooling_Allocator::Pooling_Allocator(Mutex* m) : mutex(m) +Pooling_Allocator::Pooling_Allocator() { last_used = blocks.begin(); } @@ -119,7 +119,6 @@ Pooling_Allocator::Pooling_Allocator(Mutex* m) : mutex(m) */ Pooling_Allocator::~Pooling_Allocator() { - delete mutex; if(blocks.size()) throw Invalid_State("Pooling_Allocator: Never released memory"); } @@ -129,7 +128,7 @@ Pooling_Allocator::~Pooling_Allocator() */ void Pooling_Allocator::destroy() { - Mutex_Holder lock(mutex); + std::lock_guard<std::mutex> lock(mutex); blocks.clear(); @@ -146,7 +145,7 @@ void* Pooling_Allocator::allocate(u32bit n) const u32bit BITMAP_SIZE = Memory_Block::bitmap_size(); const u32bit BLOCK_SIZE = Memory_Block::block_size(); - Mutex_Holder lock(mutex); + std::lock_guard<std::mutex> lock(mutex); if(n <= BITMAP_SIZE * BLOCK_SIZE) { @@ -183,7 +182,7 @@ void Pooling_Allocator::deallocate(void* ptr, u32bit n) if(ptr == 0 && n == 0) return; - Mutex_Holder lock(mutex); + std::lock_guard<std::mutex> lock(mutex); if(n > BITMAP_SIZE * BLOCK_SIZE) dealloc_block(ptr, n); diff --git a/src/alloc/mem_pool/mem_pool.h b/src/alloc/mem_pool/mem_pool.h index a57800972..871f135bd 100644 --- a/src/alloc/mem_pool/mem_pool.h +++ b/src/alloc/mem_pool/mem_pool.h @@ -10,7 +10,7 @@ #include <botan/allocate.h> #include <botan/exceptn.h> -#include <botan/mutex.h> +#include <mutex> #include <utility> #include <vector> @@ -27,7 +27,7 @@ class BOTAN_DLL Pooling_Allocator : public Allocator void destroy(); - Pooling_Allocator(Mutex*); + Pooling_Allocator(); ~Pooling_Allocator(); private: void get_more_core(u32bit); @@ -66,7 +66,7 @@ class BOTAN_DLL Pooling_Allocator : public Allocator std::vector<Memory_Block> blocks; std::vector<Memory_Block>::iterator last_used; std::vector<std::pair<void*, u32bit> > allocated; - Mutex* mutex; + std::mutex mutex; }; } diff --git a/src/alloc/system_alloc/defalloc.h b/src/alloc/system_alloc/defalloc.h index 627e8df70..ed2682ec0 100644 --- a/src/alloc/system_alloc/defalloc.h +++ b/src/alloc/system_alloc/defalloc.h @@ -30,8 +30,6 @@ class BOTAN_DLL Malloc_Allocator : public Allocator class BOTAN_DLL Locking_Allocator : public Pooling_Allocator { public: - Locking_Allocator(Mutex* m) : Pooling_Allocator(m) {} - std::string type() const { return "locking"; } private: void* alloc_block(u32bit); diff --git a/src/libstate/init.cpp b/src/libstate/init.cpp index b908de6c7..0d9a2420c 100644 --- a/src/libstate/init.cpp +++ b/src/libstate/init.cpp @@ -1,12 +1,11 @@ /** * Default Initialization Function -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ #include <botan/init.h> -#include <botan/parsing.h> #include <botan/libstate.h> namespace Botan { @@ -14,36 +13,8 @@ namespace Botan { /* * Library Initialization */ -void LibraryInitializer::initialize(const std::string& arg_string) +void LibraryInitializer::initialize(const std::string&) { - bool thread_safe = false; - - const std::vector<std::string> arg_list = split_on(arg_string, ' '); - for(u32bit j = 0; j != arg_list.size(); ++j) - { - if(arg_list[j].size() == 0) - continue; - - std::string name, value; - - if(arg_list[j].find('=') == std::string::npos) - { - name = arg_list[j]; - value = "true"; - } - else - { - std::vector<std::string> name_and_value = split_on(arg_list[j], '='); - name = name_and_value[0]; - value = name_and_value[1]; - } - - bool is_on = - (value == "1" || value == "true" || value == "yes" || value == "on"); - - if(name == "thread_safe") - thread_safe = is_on; - } try { @@ -55,7 +26,7 @@ void LibraryInitializer::initialize(const std::string& arg_string) */ set_global_state(new Library_State); - global_state().initialize(thread_safe); + global_state().initialize(); } catch(...) { diff --git a/src/libstate/libstate.cpp b/src/libstate/libstate.cpp index 3275c6493..839d71d60 100644 --- a/src/libstate/libstate.cpp +++ b/src/libstate/libstate.cpp @@ -9,21 +9,12 @@ #include <botan/init.h> #include <botan/engine.h> #include <botan/stl_util.h> -#include <botan/mutex.h> #include <botan/mux_noop.h> #include <botan/charset.h> #include <botan/defalloc.h> #include <botan/def_eng.h> #include <algorithm> -#if defined(BOTAN_HAS_MUTEX_PTHREAD) - #include <botan/mux_pthr.h> -#elif defined(BOTAN_HAS_MUTEX_WIN32) - #include <botan/mux_win32.h> -#elif defined(BOTAN_HAS_MUTEX_QT) - #include <botan/mux_qt.h> -#endif - #if defined(BOTAN_HAS_ALLOC_MMAP) #include <botan/mmap_mem.h> #endif @@ -92,19 +83,11 @@ Library_State* swap_global_state(Library_State* new_state) } /* -* Get a new mutex object -*/ -Mutex* Library_State::get_mutex() const - { - return mutex_factory->make(); - } - -/* * Get an allocator by its name */ -Allocator* Library_State::get_allocator(const std::string& type) const +Allocator* Library_State::get_allocator(const std::string& type) { - Mutex_Holder lock(allocator_lock); + std::lock_guard<std::mutex> lock(allocator_lock); if(type != "") return search_map<std::string, Allocator*>(alloc_factory, type, 0); @@ -128,7 +111,7 @@ Allocator* Library_State::get_allocator(const std::string& type) const */ void Library_State::add_allocator(Allocator* allocator) { - Mutex_Holder lock(allocator_lock); + std::lock_guard<std::mutex> lock(allocator_lock); allocator->init(); @@ -141,7 +124,7 @@ void Library_State::add_allocator(Allocator* allocator) */ void Library_State::set_default_allocator(const std::string& type) { - Mutex_Holder lock(allocator_lock); + std::lock_guard<std::mutex> lock(allocator_lock); if(type == "") return; @@ -154,9 +137,9 @@ void Library_State::set_default_allocator(const std::string& type) * Get a configuration value */ std::string Library_State::get(const std::string& section, - const std::string& key) const + const std::string& key) { - Mutex_Holder lock(config_lock); + std::lock_guard<std::mutex> lock(config_lock); return search_map<std::string, std::string>(config, section + "/" + key, ""); @@ -166,9 +149,9 @@ std::string Library_State::get(const std::string& section, * See if a particular option has been set */ bool Library_State::is_set(const std::string& section, - const std::string& key) const + const std::string& key) { - Mutex_Holder lock(config_lock); + std::lock_guard<std::mutex> lock(config_lock); return search_map(config, section + "/" + key, false, true); } @@ -179,7 +162,7 @@ bool Library_State::is_set(const std::string& section, void Library_State::set(const std::string& section, const std::string& key, const std::string& value, bool overwrite) { - Mutex_Holder lock(config_lock); + std::lock_guard<std::mutex> lock(config_lock); std::string full_key = section + "/" + key; @@ -201,7 +184,7 @@ void Library_State::add_alias(const std::string& key, const std::string& value) /* * Dereference an alias to a fixed name */ -std::string Library_State::deref_alias(const std::string& key) const +std::string Library_State::deref_alias(const std::string& key) { std::string result = key; while(is_set("alias", result)) @@ -221,7 +204,7 @@ void Library_State::set_option(const std::string key, /* * Get an option value */ -std::string Library_State::option(const std::string& key) const +std::string Library_State::option(const std::string& key) { return get("conf", key); } @@ -239,38 +222,18 @@ Algorithm_Factory& Library_State::algorithm_factory() /* * Load a set of modules */ -void Library_State::initialize(bool thread_safe) +void Library_State::initialize() { - if(mutex_factory) + if(m_algorithm_factory) throw Invalid_State("Library_State has already been initialized"); - if(!thread_safe) - { - mutex_factory = new Noop_Mutex_Factory; - } - else - { -#if defined(BOTAN_HAS_MUTEX_PTHREAD) - mutex_factory = new Pthread_Mutex_Factory; -#elif defined(BOTAN_HAS_MUTEX_WIN32) - mutex_factory = new Win32_Mutex_Factory; -#elif defined(BOTAN_HAS_MUTEX_QT) - mutex_factory Qt_Mutex_Factory; -#else - throw Invalid_State("Could not find a thread-safe mutex object to use"); -#endif - } - - allocator_lock = mutex_factory->make(); - config_lock = mutex_factory->make(); - cached_default_allocator = 0; add_allocator(new Malloc_Allocator); - add_allocator(new Locking_Allocator(mutex_factory->make())); + add_allocator(new Locking_Allocator); #if defined(BOTAN_HAS_ALLOC_MMAP) - add_allocator(new MemoryMapping_Allocator(mutex_factory->make())); + add_allocator(new MemoryMapping_Allocator); #endif set_default_allocator("locking"); @@ -301,7 +264,7 @@ void Library_State::initialize(bool thread_safe) engines.push_back(new Default_Engine); - m_algorithm_factory = new Algorithm_Factory(engines, *mutex_factory); + m_algorithm_factory = new Algorithm_Factory(engines); } /* @@ -309,8 +272,6 @@ void Library_State::initialize(bool thread_safe) */ Library_State::Library_State() { - mutex_factory = 0; - allocator_lock = config_lock = 0; cached_default_allocator = 0; m_algorithm_factory = 0; } @@ -321,6 +282,7 @@ Library_State::Library_State() Library_State::~Library_State() { delete m_algorithm_factory; + m_algorithm_factory = 0; cached_default_allocator = 0; @@ -329,10 +291,6 @@ Library_State::~Library_State() allocators[j]->destroy(); delete allocators[j]; } - - delete allocator_lock; - delete mutex_factory; - delete config_lock; } } diff --git a/src/libstate/libstate.h b/src/libstate/libstate.h index 2493863a9..eb3b3b3be 100644 --- a/src/libstate/libstate.h +++ b/src/libstate/libstate.h @@ -12,6 +12,7 @@ #include <botan/allocate.h> #include <botan/algo_factory.h> +#include <mutex> #include <string> #include <vector> #include <map> @@ -27,11 +28,11 @@ class BOTAN_DLL Library_State Library_State(); ~Library_State(); - void initialize(bool thread_safe); + void initialize(); Algorithm_Factory& algorithm_factory(); - Allocator* get_allocator(const std::string& = "") const; + Allocator* get_allocator(const std::string& = ""); void add_allocator(Allocator*); void set_default_allocator(const std::string&); @@ -42,7 +43,7 @@ class BOTAN_DLL Library_State * @result the value of the parameter */ std::string get(const std::string& section, - const std::string& key) const; + const std::string& key); /** * Check whether a certain parameter is set @@ -52,7 +53,7 @@ class BOTAN_DLL Library_State * @result true if the parameters value is set, * false otherwise */ - bool is_set(const std::string& section, const std::string& key) const; + bool is_set(const std::string& section, const std::string& key); /** * Set a configuration parameter. @@ -70,7 +71,7 @@ class BOTAN_DLL Library_State * referred to as option). * @param key the desired keys name */ - std::string option(const std::string& key) const; + std::string option(const std::string& key); /** * Set an option. @@ -91,21 +92,17 @@ class BOTAN_DLL Library_State * @param alias the alias to resolve. * @return what the alias stands for */ - std::string deref_alias(const std::string&) const; - - class Mutex* get_mutex() const; + std::string deref_alias(const std::string&); private: void load_default_config(); Library_State(const Library_State&) {} Library_State& operator=(const Library_State&) { return (*this); } - class Mutex_Factory* mutex_factory; - + std::mutex config_lock; std::map<std::string, std::string> config; - class Mutex* config_lock; - class Mutex* allocator_lock; + std::mutex allocator_lock; std::map<std::string, Allocator*> alloc_factory; mutable Allocator* cached_default_allocator; std::vector<Allocator*> allocators; diff --git a/src/mutex/noop_mutex/info.txt b/src/mutex/noop_mutex/info.txt deleted file mode 100644 index 1f49f5e1c..000000000 --- a/src/mutex/noop_mutex/info.txt +++ /dev/null @@ -1,10 +0,0 @@ -realname "No-Op Mutex" - -load_on auto - -define MUTEX_NOOP - -<add> -mux_noop.cpp -mux_noop.h -</add> diff --git a/src/mutex/noop_mutex/mux_noop.cpp b/src/mutex/noop_mutex/mux_noop.cpp deleted file mode 100644 index 5c45084fe..000000000 --- a/src/mutex/noop_mutex/mux_noop.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* -* No-Op Mutex Factory -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/mux_noop.h> - -namespace Botan { - -/* -* No-Op Mutex Factory -*/ -Mutex* Noop_Mutex_Factory::make() - { - class Noop_Mutex : public Mutex - { - public: - class Mutex_State_Error : public Internal_Error - { - public: - Mutex_State_Error(const std::string& where) : - Internal_Error("Noop_Mutex::" + where + ": " + - "Mutex is already " + where + "ed") {} - }; - - void lock() - { - if(locked) - throw Mutex_State_Error("lock"); - locked = true; - } - - void unlock() - { - if(!locked) - throw Mutex_State_Error("unlock"); - locked = false; - } - - Noop_Mutex() { locked = false; } - private: - bool locked; - }; - - return new Noop_Mutex; - } - -} diff --git a/src/mutex/noop_mutex/mux_noop.h b/src/mutex/noop_mutex/mux_noop.h deleted file mode 100644 index 94201cb7c..000000000 --- a/src/mutex/noop_mutex/mux_noop.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -* No-Op Mutex Factory -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_NOOP_MUTEX_FACTORY_H__ -#define BOTAN_NOOP_MUTEX_FACTORY_H__ - -#include <botan/mutex.h> - -namespace Botan { - -/* -* No-Op Mutex Factory -*/ -class BOTAN_DLL Noop_Mutex_Factory : public Mutex_Factory - { - public: - Mutex* make(); - }; - -} - -#endif diff --git a/src/mutex/pthreads/info.txt b/src/mutex/pthreads/info.txt deleted file mode 100644 index 88de70de0..000000000 --- a/src/mutex/pthreads/info.txt +++ /dev/null @@ -1,29 +0,0 @@ -realname "Pthread Mutex" - -define MUTEX_PTHREAD - -load_on auto - -<add> -mux_pthr.cpp -mux_pthr.h -</add> - -<libs> -all!qnx,freebsd,openbsd,netbsd -> pthread -</libs> - -<os> -aix -cygwin -darwin -freebsd -hpux -irix -linux -netbsd -openbsd -qnx -solaris -tru64 -</os> diff --git a/src/mutex/pthreads/mux_pthr.cpp b/src/mutex/pthreads/mux_pthr.cpp deleted file mode 100644 index 9f1d9816e..000000000 --- a/src/mutex/pthreads/mux_pthr.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Pthread Mutex -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/mux_pthr.h> -#include <botan/exceptn.h> - -#ifndef _POSIX_C_SOURCE - #define _POSIX_C_SOURCE 199506 -#endif - -#include <pthread.h> - -namespace Botan { - -/* -* Pthread Mutex Factory -*/ -Mutex* Pthread_Mutex_Factory::make() - { - - class Pthread_Mutex : public Mutex - { - public: - void lock() - { - if(pthread_mutex_lock(&mutex) != 0) - throw Exception("Pthread_Mutex::lock: Error occured"); - } - - void unlock() - { - if(pthread_mutex_unlock(&mutex) != 0) - throw Exception("Pthread_Mutex::unlock: Error occured"); - } - - Pthread_Mutex() - { - if(pthread_mutex_init(&mutex, 0) != 0) - throw Exception("Pthread_Mutex: initialization failed"); - } - - ~Pthread_Mutex() - { - if(pthread_mutex_destroy(&mutex) != 0) - throw Invalid_State("~Pthread_Mutex: mutex is still locked"); - } - private: - pthread_mutex_t mutex; - }; - - return new Pthread_Mutex(); - } - -} diff --git a/src/mutex/pthreads/mux_pthr.h b/src/mutex/pthreads/mux_pthr.h deleted file mode 100644 index 118853947..000000000 --- a/src/mutex/pthreads/mux_pthr.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -* Pthread Mutex -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_MUTEX_PTHREAD_H__ -#define BOTAN_MUTEX_PTHREAD_H__ - -#include <botan/mutex.h> - -namespace Botan { - -/* -* Pthread Mutex Factory -*/ -class BOTAN_DLL Pthread_Mutex_Factory : public Mutex_Factory - { - public: - Mutex* make(); - }; - -} - -#endif diff --git a/src/mutex/qt_mutex/info.txt b/src/mutex/qt_mutex/info.txt deleted file mode 100644 index a21108c79..000000000 --- a/src/mutex/qt_mutex/info.txt +++ /dev/null @@ -1,18 +0,0 @@ -realname "Qt Mutex" - -define MUTEX_QT - -note "You'll probably have to add -I/-L flags to the Makefile to find Qt" - -load_on request - -<add> -mux_qt.cpp -mux_qt.h -</add> - -# I think we want to always use qt-mt, not qt -- not much point in supporting -# mutexes in a single threaded application, after all. -<libs> -all -> qt-mt -</libs> diff --git a/src/mutex/qt_mutex/mux_qt.cpp b/src/mutex/qt_mutex/mux_qt.cpp deleted file mode 100644 index 0f670c8b4..000000000 --- a/src/mutex/qt_mutex/mux_qt.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* -* Qt Thread Mutex -* (C) 2004-2007 Justin Karneges -* 2004-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/mux_qt.h> -#include <qmutex.h> - -#if !defined(QT_THREAD_SUPPORT) - #error Your version of Qt does not support threads or mutexes -#endif - -namespace Botan { - -/* -* Qt Mutex Factory -*/ -Mutex* Qt_Mutex_Factory::make() - { - class Qt_Mutex : public Mutex - { - public: - void lock() { mutex.lock(); } - void unlock() { mutex.unlock(); } - private: - QMutex mutex; - }; - - return new Qt_Mutex(); - } - -} diff --git a/src/mutex/qt_mutex/mux_qt.h b/src/mutex/qt_mutex/mux_qt.h deleted file mode 100644 index 5aed77f4b..000000000 --- a/src/mutex/qt_mutex/mux_qt.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -* Qt Mutex -* (C) 2004-2007 Justin Karneges -* 2004-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_MUTEX_QT_H__ -#define BOTAN_MUTEX_QT_H__ - -#include <botan/mutex.h> - -namespace Botan { - -/* -* Qt Mutex -*/ -class BOTAN_DLL Qt_Mutex_Factory : public Mutex_Factory - { - public: - Mutex* make(); - }; - -} - -#endif diff --git a/src/mutex/win32_crit_section/info.txt b/src/mutex/win32_crit_section/info.txt deleted file mode 100644 index a2d339c3b..000000000 --- a/src/mutex/win32_crit_section/info.txt +++ /dev/null @@ -1,17 +0,0 @@ -realname "Win32 Mutex" - -define MUTEX_WIN32 -modset win32 - -load_on auto - -<add> -mux_win32.cpp -mux_win32.h -</add> - -<os> -cygwin -windows -mingw -</os> diff --git a/src/mutex/win32_crit_section/mux_win32.cpp b/src/mutex/win32_crit_section/mux_win32.cpp deleted file mode 100644 index 2a967892b..000000000 --- a/src/mutex/win32_crit_section/mux_win32.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* -* Win32 Mutex -* (C) 2006 Luca Piccarreta -* 2006-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/mux_win32.h> -#include <windows.h> - -namespace Botan { - -/* -* Win32 Mutex Factory -*/ -Mutex* Win32_Mutex_Factory::make() - { - class Win32_Mutex : public Mutex - { - public: - void lock() { EnterCriticalSection(&mutex); } - void unlock() { LeaveCriticalSection(&mutex); } - - Win32_Mutex() { InitializeCriticalSection(&mutex); } - ~Win32_Mutex() { DeleteCriticalSection(&mutex); } - private: - CRITICAL_SECTION mutex; - }; - - return new Win32_Mutex(); - } - -} diff --git a/src/mutex/win32_crit_section/mux_win32.h b/src/mutex/win32_crit_section/mux_win32.h deleted file mode 100644 index a91850e71..000000000 --- a/src/mutex/win32_crit_section/mux_win32.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -* Win32 Mutex -* (C) 2006 Luca Piccarreta -* 2006-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_MUTEX_WIN32_H__ -#define BOTAN_MUTEX_WIN32_H__ - -#include <botan/mutex.h> - -namespace Botan { - -/* -* Win32 Mutex Factory -*/ -class BOTAN_DLL Win32_Mutex_Factory : public Mutex_Factory - { - public: - Mutex* make(); - }; -} - -#endif diff --git a/src/utils/info.txt b/src/utils/info.txt index ffc19c852..815ad4efc 100644 --- a/src/utils/info.txt +++ b/src/utils/info.txt @@ -27,7 +27,6 @@ exceptn.h loadstor.h mem_ops.h mlock.cpp -mutex.h parsing.cpp parsing.h rotate.h diff --git a/src/utils/mutex.h b/src/utils/mutex.h deleted file mode 100644 index a04ff83c9..000000000 --- a/src/utils/mutex.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -* Mutex -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_MUTEX_H__ -#define BOTAN_MUTEX_H__ - -#include <botan/exceptn.h> - -namespace Botan { - -/* -* Mutex Base Class -*/ -class BOTAN_DLL Mutex - { - public: - virtual void lock() = 0; - virtual void unlock() = 0; - virtual ~Mutex() {} - }; - -/* -* Mutex Factory -*/ -class BOTAN_DLL Mutex_Factory - { - public: - virtual Mutex* make() = 0; - virtual ~Mutex_Factory() {} - }; - -/* -* Mutex Holding Class -*/ -class BOTAN_DLL Mutex_Holder - { - public: - Mutex_Holder(Mutex* m) : mux(m) - { - if(!mux) - throw Invalid_Argument("Mutex_Holder: Argument was NULL"); - mux->lock(); - } - - ~Mutex_Holder() { mux->unlock(); } - private: - Mutex* mux; - }; - -} - -#endif diff --git a/src/utils/scan_name.cpp b/src/utils/scan_name.cpp index 3425425e2..92fded3c4 100644 --- a/src/utils/scan_name.cpp +++ b/src/utils/scan_name.cpp @@ -8,6 +8,7 @@ SCAN Name Abstraction #include <botan/scan_name.h> #include <botan/parsing.h> #include <botan/libstate.h> +#include <botan/exceptn.h> #include <stdexcept> #include <iostream> |