and added files
[bcm963xx.git] / userapps / opensource / net-snmp / include / net-snmp / library / mt_support.h
1 /*
2  * mt_support.h - multi-thread resource locking support declarations 
3  */
4 /*
5  * Author: Markku Laukkanen
6  * Created: 6-Sep-1999
7  * History:
8  *  8-Sep-1999 M. Slifcak method names changed;
9  *                        use array of resource locking structures.
10  */
11
12 #ifndef MT_SUPPORT_H
13 #define MT_SUPPORT_H
14
15 #ifdef __cplusplus
16 extern          "C" {
17 #endif
18   
19 /*
20  * Lock group identifiers 
21  */
22
23 #define MT_LIBRARY_ID      0
24 #define MT_APPLICATION_ID  1
25 #define MT_TOKEN_ID        2
26
27 #define MT_MAX_IDS         3    /* one greater than last from above */
28 #define MT_MAX_SUBIDS      10
29
30
31 /*
32  * Lock resource identifiers for library resources 
33  */
34
35 #define MT_LIB_NONE        0
36 #define MT_LIB_SESSION     1
37 #define MT_LIB_REQUESTID   2
38 #define MT_LIB_MESSAGEID   3
39 #define MT_LIB_SESSIONID   4
40 #define MT_LIB_TRANSID     5
41
42 #define MT_LIB_MAXIMUM     6    /* must be one greater than the last one */
43
44
45 #if defined(NS_REENTRANT) || defined(WIN32)
46
47 #if HAVE_PTHREAD_H
48 #include <pthread.h>
49 typedef pthread_mutex_t mutex_type;
50 #ifdef pthread_mutexattr_default
51 #define MT_MUTEX_INIT_DEFAULT pthread_mutexattr_default
52 #else
53 #define MT_MUTEX_INIT_DEFAULT 0
54 #endif
55
56 #elif defined(WIN32) || defined(cygwin)
57
58 #include <windows.h>
59 typedef CRITICAL_SECTION mutex_type;
60
61 #else  /*  HAVE_PTHREAD_H  */
62 error "There is no re-entrant support as defined."
63 #endif /*  HAVE_PTHREAD_H  */
64
65
66 int             snmp_res_init(void);
67 int             snmp_res_lock(int groupID, int resourceID);
68 int             snmp_res_unlock(int groupID, int resourceID);
69 int             snmp_res_destroy_mutex(int groupID, int resourceID);
70
71 #else /*  NS_REENTRANT  */
72
73 #ifndef WIN32
74 #define snmp_res_init() do {} while (0)
75 #define snmp_res_lock(x,y) do {} while (0)
76 #define snmp_res_unlock(x,y) do {} while (0)
77 #define snmp_res_destroy_mutex(x,y) do {} while (0)
78 #endif /*  WIN32  */
79
80 #endif /*  NS_REENTRANT  */
81
82 #ifdef __cplusplus
83 }
84 #endif
85 #endif /*  MT_SUPPORT_H  */