added files
[bcm963xx.git] / userapps / opensource / net-snmp / include / net-snmp / library / snmp_locking.h
1
2 /*
3  * snmp_locking.h - multi-thread resource locking support declarations 
4  */
5 /*
6  * Author: Markku Laukkanen
7  * Created: 6-Sep-1999
8  * History:
9  *  8-Sep-1999 M. Slifcak method names changed;
10  *                        use array of resource locking structures.
11  *  3-Jan-2001 R. Story   copy mt_resource.h to snmp_locking.h
12  */
13
14 #ifndef SNMP_LOCKING_H
15 #define SNMP_LOCKING_H
16
17 #ifdef __cplusplus
18 extern          "C" {
19 #endif
20
21 #ifdef NS_REENTRANT
22
23 #if HAVE_PTHREAD_H
24 #include <pthread.h>
25 typedef pthread_mutex_t mutex_type;
26 #ifdef pthread_mutexattr_default
27 #define MT_MUTEX_INIT_DEFAULT pthread_mutexattr_default
28 #else
29 #define MT_MUTEX_INIT_DEFAULT 0
30 #endif
31
32 #elif defined(WIN32) || defined(cygwin)
33 #include <windows.h>
34 typedef CRITICAL_SECTION mutex_type;
35 #else
36                     error "There is no re-entrant support as defined."
37 #endif  /*  HAVE_PTHREAD_H  */
38
39 int     netsnmp_mutex_init(mutex_type *);
40 int     netsnmp_mutex_lock(mutex_type *);
41 int     netsnmp_mutex_unlock(mutex_type *);
42 int     netsnmp_mutex_destroy_mutex(mutex_type *);
43
44 #else                           /* !NS_REENTRANT */
45
46 #define netsnmp_mutex_init(x) do {} while (0)
47 #define netsnmp_mutex_lock(x) do {} while (0)
48 #define netsnmp_mutex_unlock(x) do {} while (0)
49 #define netsnmp_mutex_destroy_mutex(x) do {} while (0)
50
51 #endif                          /* !NS_REENTRANT */
52
53 #ifdef __cplusplus
54 }
55 #endif
56 #endif /*  SNMP_LOCKING_H  */