From 99e8c1a20700631103ec20386f8080eeee4df588 Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 1 Apr 2009 15:43:27 +0000 Subject: Remove the mutex classes in favor of C++0x's std::mutex and std::lock_guard --- src/mutex/noop_mutex/info.txt | 10 ------ src/mutex/noop_mutex/mux_noop.cpp | 50 -------------------------- src/mutex/noop_mutex/mux_noop.h | 26 -------------- src/mutex/pthreads/info.txt | 29 --------------- src/mutex/pthreads/mux_pthr.cpp | 58 ------------------------------ src/mutex/pthreads/mux_pthr.h | 26 -------------- src/mutex/qt_mutex/info.txt | 18 ---------- src/mutex/qt_mutex/mux_qt.cpp | 35 ------------------ src/mutex/qt_mutex/mux_qt.h | 27 -------------- src/mutex/win32_crit_section/info.txt | 17 --------- src/mutex/win32_crit_section/mux_win32.cpp | 34 ------------------ src/mutex/win32_crit_section/mux_win32.h | 26 -------------- 12 files changed, 356 deletions(-) delete mode 100644 src/mutex/noop_mutex/info.txt delete mode 100644 src/mutex/noop_mutex/mux_noop.cpp delete mode 100644 src/mutex/noop_mutex/mux_noop.h delete mode 100644 src/mutex/pthreads/info.txt delete mode 100644 src/mutex/pthreads/mux_pthr.cpp delete mode 100644 src/mutex/pthreads/mux_pthr.h delete mode 100644 src/mutex/qt_mutex/info.txt delete mode 100644 src/mutex/qt_mutex/mux_qt.cpp delete mode 100644 src/mutex/qt_mutex/mux_qt.h delete mode 100644 src/mutex/win32_crit_section/info.txt delete mode 100644 src/mutex/win32_crit_section/mux_win32.cpp delete mode 100644 src/mutex/win32_crit_section/mux_win32.h (limited to 'src/mutex') 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 - - -mux_noop.cpp -mux_noop.h - 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 - -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 - -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 - - -mux_pthr.cpp -mux_pthr.h - - - -all!qnx,freebsd,openbsd,netbsd -> pthread - - - -aix -cygwin -darwin -freebsd -hpux -irix -linux -netbsd -openbsd -qnx -solaris -tru64 - 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 -#include - -#ifndef _POSIX_C_SOURCE - #define _POSIX_C_SOURCE 199506 -#endif - -#include - -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 - -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 - - -mux_qt.cpp -mux_qt.h - - -# I think we want to always use qt-mt, not qt -- not much point in supporting -# mutexes in a single threaded application, after all. - -all -> qt-mt - 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 -#include - -#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 - -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 - - -mux_win32.cpp -mux_win32.h - - - -cygwin -windows -mingw - 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 -#include - -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 - -namespace Botan { - -/* -* Win32 Mutex Factory -*/ -class BOTAN_DLL Win32_Mutex_Factory : public Mutex_Factory - { - public: - Mutex* make(); - }; -} - -#endif -- cgit v1.2.3