comparison nss/lib/util/nssrwlk.h @ 0:1e5118fa0cb1

This is NSS with a Cmake Buildsyste To compile a static NSS library for Windows we've used the Chromium-NSS fork and added a Cmake buildsystem to compile it statically for Windows. See README.chromium for chromium changes and README.trustbridge for our modifications.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 28 Jul 2014 10:47:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e5118fa0cb1
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 /*
6 ** File: nsrwlock.h
7 ** Description: API to basic reader-writer lock functions of NSS.
8 ** These are re-entrant reader writer locks; that is,
9 ** If I hold the write lock, I can ask for it and get it again.
10 ** If I hold the write lock, I can also ask for and get a read lock.
11 ** I can then release the locks in any order (read or write).
12 ** I must release each lock type as many times as I acquired it.
13 ** Otherwise, these are normal reader/writer locks.
14 **
15 ** For deadlock detection, locks should be ranked, and no lock may be aquired
16 ** while I hold a lock of higher rank number.
17 ** If you don't want that feature, always use NSS_RWLOCK_RANK_NONE.
18 ** Lock name is for debugging, and is optional (may be NULL)
19 **/
20
21 #ifndef nssrwlk_h___
22 #define nssrwlk_h___
23
24 #include "utilrename.h"
25 #include "prtypes.h"
26 #include "nssrwlkt.h"
27
28 #define NSS_RWLOCK_RANK_NONE 0
29
30 /* SEC_BEGIN_PROTOS */
31 PR_BEGIN_EXTERN_C
32
33 /***********************************************************************
34 ** FUNCTION: NSSRWLock_New
35 ** DESCRIPTION:
36 ** Returns a pointer to a newly created reader-writer lock object.
37 ** INPUTS: Lock rank
38 ** Lock name
39 ** OUTPUTS: void
40 ** RETURN: NSSRWLock*
41 ** If the lock cannot be created because of resource constraints, NULL
42 ** is returned.
43 **
44 ***********************************************************************/
45 extern NSSRWLock* NSSRWLock_New(PRUint32 lock_rank, const char *lock_name);
46
47 /***********************************************************************
48 ** FUNCTION: NSSRWLock_AtomicCreate
49 ** DESCRIPTION:
50 ** Given the address of a NULL pointer to a NSSRWLock,
51 ** atomically initializes that pointer to a newly created NSSRWLock.
52 ** Returns the value placed into that pointer, or NULL.
53 **
54 ** INPUTS: address of NSRWLock pointer
55 ** Lock rank
56 ** Lock name
57 ** OUTPUTS: NSSRWLock*
58 ** RETURN: NSSRWLock*
59 ** If the lock cannot be created because of resource constraints,
60 ** the pointer will be left NULL.
61 **
62 ***********************************************************************/
63 extern NSSRWLock *
64 nssRWLock_AtomicCreate( NSSRWLock ** prwlock,
65 PRUint32 lock_rank,
66 const char * lock_name);
67
68 /***********************************************************************
69 ** FUNCTION: NSSRWLock_Destroy
70 ** DESCRIPTION:
71 ** Destroys a given RW lock object.
72 ** INPUTS: NSSRWLock *lock - Lock to be freed.
73 ** OUTPUTS: void
74 ** RETURN: None
75 ***********************************************************************/
76 extern void NSSRWLock_Destroy(NSSRWLock *lock);
77
78 /***********************************************************************
79 ** FUNCTION: NSSRWLock_LockRead
80 ** DESCRIPTION:
81 ** Apply a read lock (non-exclusive) on a RWLock
82 ** INPUTS: NSSRWLock *lock - Lock to be read-locked.
83 ** OUTPUTS: void
84 ** RETURN: None
85 ***********************************************************************/
86 extern void NSSRWLock_LockRead(NSSRWLock *lock);
87
88 /***********************************************************************
89 ** FUNCTION: NSSRWLock_LockWrite
90 ** DESCRIPTION:
91 ** Apply a write lock (exclusive) on a RWLock
92 ** INPUTS: NSSRWLock *lock - Lock to write-locked.
93 ** OUTPUTS: void
94 ** RETURN: None
95 ***********************************************************************/
96 extern void NSSRWLock_LockWrite(NSSRWLock *lock);
97
98 /***********************************************************************
99 ** FUNCTION: NSSRWLock_UnlockRead
100 ** DESCRIPTION:
101 ** Release a Read lock. Unlocking an unlocked lock has undefined results.
102 ** INPUTS: NSSRWLock *lock - Lock to unlocked.
103 ** OUTPUTS: void
104 ** RETURN: void
105 ***********************************************************************/
106 extern void NSSRWLock_UnlockRead(NSSRWLock *lock);
107
108 /***********************************************************************
109 ** FUNCTION: NSSRWLock_UnlockWrite
110 ** DESCRIPTION:
111 ** Release a Write lock. Unlocking an unlocked lock has undefined results.
112 ** INPUTS: NSSRWLock *lock - Lock to unlocked.
113 ** OUTPUTS: void
114 ** RETURN: void
115 ***********************************************************************/
116 extern void NSSRWLock_UnlockWrite(NSSRWLock *lock);
117
118 /***********************************************************************
119 ** FUNCTION: NSSRWLock_HaveWriteLock
120 ** DESCRIPTION:
121 ** Tells caller whether the current thread holds the write lock, or not.
122 ** INPUTS: NSSRWLock *lock - Lock to test.
123 ** OUTPUTS: void
124 ** RETURN: PRBool PR_TRUE IFF the current thread holds the write lock.
125 ***********************************************************************/
126
127 extern PRBool NSSRWLock_HaveWriteLock(NSSRWLock *rwlock);
128
129 /* SEC_END_PROTOS */
130 PR_END_EXTERN_C
131
132 #endif /* nsrwlock_h___ */
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)