summaryrefslogtreecommitdiff
path: root/polux/application/agent/snmp++/src/reentrant.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'polux/application/agent/snmp++/src/reentrant.cpp')
-rw-r--r--polux/application/agent/snmp++/src/reentrant.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/polux/application/agent/snmp++/src/reentrant.cpp b/polux/application/agent/snmp++/src/reentrant.cpp
new file mode 100644
index 0000000000..6df190a50b
--- /dev/null
+++ b/polux/application/agent/snmp++/src/reentrant.cpp
@@ -0,0 +1,93 @@
+/*_############################################################################
+ _##
+ _## reentrant.cpp
+ _##
+ _## SNMP++v3.2.23
+ _## -----------------------------------------------
+ _## Copyright (c) 2001-2007 Jochen Katz, Frank Fock
+ _##
+ _## This software is based on SNMP++2.6 from Hewlett Packard:
+ _##
+ _## Copyright (c) 1996
+ _## Hewlett-Packard Company
+ _##
+ _## ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
+ _## Permission to use, copy, modify, distribute and/or sell this software
+ _## and/or its documentation is hereby granted without fee. User agrees
+ _## to display the above copyright notice and this license notice in all
+ _## copies of the software and any documentation of the software. User
+ _## agrees to assume all liability for the use of the software;
+ _## Hewlett-Packard and Jochen Katz make no representations about the
+ _## suitability of this software for any purpose. It is provided
+ _## "AS-IS" without warranty of any kind, either express or implied. User
+ _## hereby grants a royalty-free license to any and all derivatives based
+ _## upon this software code base.
+ _##
+ _## Stuttgart, Germany, Sun Nov 11 15:10:59 CET 2007
+ _##
+ _##########################################################################*/
+char reentrant_cpp_version[]="#(@) SNMP++ $Id: reentrant.cpp 178 2005-09-19 19:59:36Z fock $";
+
+#include "snmp_pp/reentrant.h"
+
+#ifdef SNMP_PP_NAMESPACE
+namespace Snmp_pp {
+#endif
+
+SnmpSynchronized::SnmpSynchronized()
+{
+#ifdef _THREADS
+#ifdef WIN32
+ InitializeCriticalSection(&_mutex);
+#elif defined (CPU) && CPU == PPC603
+ _mutex = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE );
+#else
+ pthread_mutex_init(&_mutex, 0);
+#endif
+#endif
+}
+
+SnmpSynchronized::~SnmpSynchronized()
+{
+#ifdef _THREADS
+#ifdef WIN32
+ DeleteCriticalSection(&_mutex);
+#elif defined (CPU) && CPU == PPC603
+ semTake(_mutex, WAIT_FOREVER);
+ semDelete(_mutex);
+#else
+ pthread_mutex_destroy(&_mutex);
+#endif
+#endif
+}
+
+void SnmpSynchronized::lock()
+{
+#ifdef _THREADS
+#ifdef WIN32
+ EnterCriticalSection(&_mutex);
+#elif defined (CPU) && CPU == PPC603
+ semTake(_mutex, WAIT_FOREVER);
+#else
+ pthread_mutex_lock(&_mutex);
+#endif
+#endif
+}
+
+void SnmpSynchronized::unlock()
+{
+#ifdef _THREADS
+#ifdef WIN32
+ LeaveCriticalSection(&_mutex);
+#elif defined (CPU) && CPU == PPC603
+ semGive(_mutex);
+#else
+ pthread_mutex_unlock(&_mutex);
+#endif
+#endif
+}
+
+#ifdef SNMP_PP_NAMESPACE
+}; // end of namespace Snmp_pp
+#endif
+