aboutsummaryrefslogtreecommitdiffstats
path: root/Attic
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-01-21 16:36:12 +0000
committerlloyd <[email protected]>2010-01-21 16:36:12 +0000
commit412a13fc607a57bd9986155d247353ba8e5fb203 (patch)
treecbdf63aaa7e9f28a748dedda286e79a138573f74 /Attic
parent41bed2fa0c4d96faf805cd33850166972dcac114 (diff)
parent9b82bb5a720f32e3e7878550310b1151cac188b8 (diff)
propagate from branch 'net.randombit.botan' (head 12382647ef0a28fcb11c824c77b670cc88a4f721)
to branch 'net.randombit.botan.c++0x' (head b586a3286d2c4d547ad3add5af9df1455bf4b87b)
Diffstat (limited to 'Attic')
-rw-r--r--Attic/mutex/info.txt5
-rw-r--r--Attic/mutex/mutex.h56
-rw-r--r--Attic/mutex/noop_mutex/info.txt9
-rw-r--r--Attic/mutex/noop_mutex/mux_noop.cpp50
-rw-r--r--Attic/mutex/noop_mutex/mux_noop.h26
-rw-r--r--Attic/mutex/pthreads/info.txt29
-rw-r--r--Attic/mutex/pthreads/mux_pthr.cpp58
-rw-r--r--Attic/mutex/pthreads/mux_pthr.h26
-rw-r--r--Attic/mutex/qt_mutex/info.txt17
-rw-r--r--Attic/mutex/qt_mutex/mux_qt.cpp35
-rw-r--r--Attic/mutex/qt_mutex/mux_qt.h27
-rw-r--r--Attic/mutex/win32_crit_section/info.txt15
-rw-r--r--Attic/mutex/win32_crit_section/mux_win32.cpp34
-rw-r--r--Attic/mutex/win32_crit_section/mux_win32.h26
14 files changed, 413 insertions, 0 deletions
diff --git a/Attic/mutex/info.txt b/Attic/mutex/info.txt
new file mode 100644
index 000000000..af4cf9bb3
--- /dev/null
+++ b/Attic/mutex/info.txt
@@ -0,0 +1,5 @@
+define MUTEX_WRAPPERS
+
+<header:internal>
+mutex.h
+</header:internal>
diff --git a/Attic/mutex/mutex.h b/Attic/mutex/mutex.h
new file mode 100644
index 000000000..fcb0e9982
--- /dev/null
+++ b/Attic/mutex/mutex.h
@@ -0,0 +1,56 @@
+/*
+* 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 Mutex
+ {
+ public:
+ virtual void lock() = 0;
+ virtual void unlock() = 0;
+ virtual ~Mutex() {}
+ };
+
+/*
+* Mutex Factory
+*/
+class Mutex_Factory
+ {
+ public:
+ virtual Mutex* make() = 0;
+ virtual ~Mutex_Factory() {}
+ };
+
+/*
+* Mutex Holding Class
+*/
+class 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/Attic/mutex/noop_mutex/info.txt b/Attic/mutex/noop_mutex/info.txt
new file mode 100644
index 000000000..16670b1dd
--- /dev/null
+++ b/Attic/mutex/noop_mutex/info.txt
@@ -0,0 +1,9 @@
+define MUTEX_NOOP
+
+<source>
+mux_noop.cpp
+</source>
+
+<header:internal>
+mux_noop.h
+</header:internal>
diff --git a/Attic/mutex/noop_mutex/mux_noop.cpp b/Attic/mutex/noop_mutex/mux_noop.cpp
new file mode 100644
index 000000000..18151274a
--- /dev/null
+++ b/Attic/mutex/noop_mutex/mux_noop.cpp
@@ -0,0 +1,50 @@
+/*
+* No-Op Mutex Factory
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/internal/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/Attic/mutex/noop_mutex/mux_noop.h b/Attic/mutex/noop_mutex/mux_noop.h
new file mode 100644
index 000000000..a1bd57858
--- /dev/null
+++ b/Attic/mutex/noop_mutex/mux_noop.h
@@ -0,0 +1,26 @@
+/*
+* 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/internal/mutex.h>
+
+namespace Botan {
+
+/*
+* No-Op Mutex Factory
+*/
+class Noop_Mutex_Factory : public Mutex_Factory
+ {
+ public:
+ Mutex* make();
+ };
+
+}
+
+#endif
diff --git a/Attic/mutex/pthreads/info.txt b/Attic/mutex/pthreads/info.txt
new file mode 100644
index 000000000..1d826b61c
--- /dev/null
+++ b/Attic/mutex/pthreads/info.txt
@@ -0,0 +1,29 @@
+define MUTEX_PTHREAD
+
+<source>
+mux_pthr.cpp
+</source>
+
+<header:internal>
+mux_pthr.h
+</header:internal>
+
+<libs>
+all!qnx,freebsd,dragonfly,openbsd,netbsd -> pthread
+</libs>
+
+<os>
+aix
+cygwin
+darwin
+freebsd
+dragonfly
+hpux
+irix
+linux
+netbsd
+openbsd
+qnx
+solaris
+tru64
+</os>
diff --git a/Attic/mutex/pthreads/mux_pthr.cpp b/Attic/mutex/pthreads/mux_pthr.cpp
new file mode 100644
index 000000000..165132239
--- /dev/null
+++ b/Attic/mutex/pthreads/mux_pthr.cpp
@@ -0,0 +1,58 @@
+/*
+* Pthread Mutex
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/internal/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 Invalid_State("Pthread_Mutex::lock: Error occured");
+ }
+
+ void unlock()
+ {
+ if(pthread_mutex_unlock(&mutex) != 0)
+ throw Invalid_State("Pthread_Mutex::unlock: Error occured");
+ }
+
+ Pthread_Mutex()
+ {
+ if(pthread_mutex_init(&mutex, 0) != 0)
+ throw Invalid_State("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/Attic/mutex/pthreads/mux_pthr.h b/Attic/mutex/pthreads/mux_pthr.h
new file mode 100644
index 000000000..27b854265
--- /dev/null
+++ b/Attic/mutex/pthreads/mux_pthr.h
@@ -0,0 +1,26 @@
+/*
+* 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/internal/mutex.h>
+
+namespace Botan {
+
+/*
+* Pthread Mutex Factory
+*/
+class Pthread_Mutex_Factory : public Mutex_Factory
+ {
+ public:
+ Mutex* make();
+ };
+
+}
+
+#endif
diff --git a/Attic/mutex/qt_mutex/info.txt b/Attic/mutex/qt_mutex/info.txt
new file mode 100644
index 000000000..7b014f886
--- /dev/null
+++ b/Attic/mutex/qt_mutex/info.txt
@@ -0,0 +1,17 @@
+define MUTEX_QT
+
+load_on request
+
+<source>
+mux_qt.cpp
+</source>
+
+<header:internal>
+mux_qt.h
+</header:internal>
+
+# 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/Attic/mutex/qt_mutex/mux_qt.cpp b/Attic/mutex/qt_mutex/mux_qt.cpp
new file mode 100644
index 000000000..da4e5ce5c
--- /dev/null
+++ b/Attic/mutex/qt_mutex/mux_qt.cpp
@@ -0,0 +1,35 @@
+/*
+* Qt Thread Mutex
+* (C) 2004-2007 Justin Karneges
+* 2004-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/internal/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/Attic/mutex/qt_mutex/mux_qt.h b/Attic/mutex/qt_mutex/mux_qt.h
new file mode 100644
index 000000000..cb396b81d
--- /dev/null
+++ b/Attic/mutex/qt_mutex/mux_qt.h
@@ -0,0 +1,27 @@
+/*
+* 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/internal/mutex.h>
+
+namespace Botan {
+
+/*
+* Qt Mutex
+*/
+class Qt_Mutex_Factory : public Mutex_Factory
+ {
+ public:
+ Mutex* make();
+ };
+
+}
+
+#endif
diff --git a/Attic/mutex/win32_crit_section/info.txt b/Attic/mutex/win32_crit_section/info.txt
new file mode 100644
index 000000000..d90b8b64b
--- /dev/null
+++ b/Attic/mutex/win32_crit_section/info.txt
@@ -0,0 +1,15 @@
+define MUTEX_WIN32
+
+<source>
+mux_win32.cpp
+</source>
+
+<header:internal>
+mux_win32.h
+</header:internal>
+
+<os>
+cygwin
+windows
+mingw
+</os>
diff --git a/Attic/mutex/win32_crit_section/mux_win32.cpp b/Attic/mutex/win32_crit_section/mux_win32.cpp
new file mode 100644
index 000000000..fa6051798
--- /dev/null
+++ b/Attic/mutex/win32_crit_section/mux_win32.cpp
@@ -0,0 +1,34 @@
+/*
+* Win32 Mutex
+* (C) 2006 Luca Piccarreta
+* 2006-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/internal/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/Attic/mutex/win32_crit_section/mux_win32.h b/Attic/mutex/win32_crit_section/mux_win32.h
new file mode 100644
index 000000000..4bbf6a540
--- /dev/null
+++ b/Attic/mutex/win32_crit_section/mux_win32.h
@@ -0,0 +1,26 @@
+/*
+* 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/internal/mutex.h>
+
+namespace Botan {
+
+/*
+* Win32 Mutex Factory
+*/
+class Win32_Mutex_Factory : public Mutex_Factory
+ {
+ public:
+ Mutex* make();
+ };
+}
+
+#endif