]> git.stg.codes - ssmd.git/blob - 3rdparty/snmp++/include/snmp_pp/reentrant.h
Initial adding
[ssmd.git] / 3rdparty / snmp++ / include / snmp_pp / reentrant.h
1 /*_############################################################################
2   _## 
3   _##  reentrant.h  
4   _##
5   _##  SNMP++v3.2.25
6   _##  -----------------------------------------------
7   _##  Copyright (c) 2001-2010 Jochen Katz, Frank Fock
8   _##
9   _##  This software is based on SNMP++2.6 from Hewlett Packard:
10   _##  
11   _##    Copyright (c) 1996
12   _##    Hewlett-Packard Company
13   _##  
14   _##  ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
15   _##  Permission to use, copy, modify, distribute and/or sell this software 
16   _##  and/or its documentation is hereby granted without fee. User agrees 
17   _##  to display the above copyright notice and this license notice in all 
18   _##  copies of the software and any documentation of the software. User 
19   _##  agrees to assume all liability for the use of the software; 
20   _##  Hewlett-Packard and Jochen Katz make no representations about the 
21   _##  suitability of this software for any purpose. It is provided 
22   _##  "AS-IS" without warranty of any kind, either express or implied. User 
23   _##  hereby grants a royalty-free license to any and all derivatives based
24   _##  upon this software code base. 
25   _##  
26   _##  Stuttgart, Germany, Thu Sep  2 00:07:47 CEST 2010 
27   _##  
28   _##########################################################################*/
29 // $Id: reentrant.h 307 2007-09-14 20:01:45Z katz $
30
31 #ifndef _reentrant_h_
32 #define _reentrant_h_
33
34 #include "snmp_pp/config_snmp_pp.h"
35 #include "snmp_pp/smi.h"
36
37 #ifdef _THREADS
38 #ifdef WIN32
39 #include <process.h>
40 #elif defined (CPU) && CPU == PPC603
41 #include <semLib.h> 
42 #else
43 #include <pthread.h>
44 #endif
45 #endif
46
47 #ifdef SNMP_PP_NAMESPACE
48 namespace Snmp_pp {
49 #endif
50
51 class DLLOPT SnmpSynchronized {
52
53  public:
54   SnmpSynchronized();
55   virtual ~SnmpSynchronized();
56 #ifdef _THREADS
57 #ifdef WIN32
58   CRITICAL_SECTION      _mutex;
59 #elif defined (CPU) && CPU == PPC603
60   SEM_ID                _mutex;
61 #else
62   pthread_mutex_t       _mutex;
63 #endif
64 #endif
65   void lock();
66   void unlock();
67 };
68
69 class DLLOPT SnmpSynchronize {
70
71  public:
72   SnmpSynchronize(SnmpSynchronized& sync) : s(sync) { s.lock(); };
73   ~SnmpSynchronize() { s.unlock(); }
74
75  protected:
76   SnmpSynchronized& s;
77
78 };
79
80 #define REENTRANT(x) { SnmpSynchronize _synchronize(*this); x }
81
82 #ifdef SNMP_PP_NAMESPACE
83 } // end of namespace Snmp_pp
84 #endif 
85
86 #endif
87