aboutsummaryrefslogtreecommitdiffstats
path: root/Attic/mutex/pthreads
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-10-13 16:05:37 +0000
committerlloyd <[email protected]>2009-10-13 16:05:37 +0000
commit6f68dc5485ebd41fdef837ab651a47a893d84408 (patch)
tree3cda82570052b7bed24df2754c2245479188488a /Attic/mutex/pthreads
parent9268a0455a07d31a66364aa5b7594bd75250b466 (diff)
parent1b0448fae6652a2da7f0de1fdcd2bbcda9836ca9 (diff)
propagate from branch 'net.randombit.botan' (head 139d6957d20f0b1202e0eacc63cb011588faffde)
to branch 'net.randombit.botan.c++0x' (head c16676fa6c393bc3f46a044755ce525a013380a6)
Diffstat (limited to 'Attic/mutex/pthreads')
-rw-r--r--Attic/mutex/pthreads/info.txt30
-rw-r--r--Attic/mutex/pthreads/mux_pthr.cpp58
-rw-r--r--Attic/mutex/pthreads/mux_pthr.h26
3 files changed, 114 insertions, 0 deletions
diff --git a/Attic/mutex/pthreads/info.txt b/Attic/mutex/pthreads/info.txt
new file mode 100644
index 000000000..f135dea48
--- /dev/null
+++ b/Attic/mutex/pthreads/info.txt
@@ -0,0 +1,30 @@
+realname "Pthread Mutex"
+
+define MUTEX_PTHREAD
+
+load_on auto
+
+<add>
+mux_pthr.cpp
+mux_pthr.h
+</add>
+
+<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..9f1d9816e
--- /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/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/Attic/mutex/pthreads/mux_pthr.h b/Attic/mutex/pthreads/mux_pthr.h
new file mode 100644
index 000000000..118853947
--- /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/mutex.h>
+
+namespace Botan {
+
+/*
+* Pthread Mutex Factory
+*/
+class BOTAN_DLL Pthread_Mutex_Factory : public Mutex_Factory
+ {
+ public:
+ Mutex* make();
+ };
+
+}
+
+#endif