| OLD | NEW |
| 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 /* This Source Code Form is subject to the terms of the Mozilla Public | 2 /* This Source Code Form is subject to the terms of the Mozilla Public |
| 3 * License, v. 2.0. If a copy of the MPL was not distributed with this | 3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 5 | 5 |
| 6 #include "primpl.h" | 6 #include "primpl.h" |
| 7 | 7 |
| 8 #if defined(WIN95) | 8 #if defined(WIN95) |
| 9 /* | 9 /* |
| 10 ** Some local variables report warnings on Win95 because the code paths | 10 ** Some local variables report warnings on Win95 because the code paths |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 | 154 |
| 155 PR_IMPLEMENT(PRLock*) PR_NewLock(void) | 155 PR_IMPLEMENT(PRLock*) PR_NewLock(void) |
| 156 { | 156 { |
| 157 PRLock *lock; | 157 PRLock *lock; |
| 158 | 158 |
| 159 if (!_pr_initialized) _PR_ImplicitInitialization(); | 159 if (!_pr_initialized) _PR_ImplicitInitialization(); |
| 160 | 160 |
| 161 lock = PR_NEWZAP(PRLock); | 161 lock = PR_NEWZAP(PRLock); |
| 162 if (lock) { | 162 if (lock) { |
| 163 if (_PR_MD_NEW_LOCK(&lock->ilock) == PR_FAILURE) { | 163 if (_PR_InitLock(lock) != PR_SUCCESS) { |
| 164 » » PR_DELETE(lock); | 164 PR_DELETE(lock); |
| 165 » » return(NULL); | 165 return NULL; |
| 166 » } | 166 } |
| 167 PR_INIT_CLIST(&lock->links); | |
| 168 PR_INIT_CLIST(&lock->waitQ); | |
| 169 } | 167 } |
| 170 return lock; | 168 return lock; |
| 171 } | 169 } |
| 172 | 170 |
| 171 PRStatus _PR_InitLock(PRLock *lock) |
| 172 { |
| 173 if (_PR_MD_NEW_LOCK(&lock->ilock) != PR_SUCCESS) { |
| 174 return PR_FAILURE; |
| 175 } |
| 176 PR_INIT_CLIST(&lock->links); |
| 177 PR_INIT_CLIST(&lock->waitQ); |
| 178 return PR_SUCCESS; |
| 179 } |
| 180 |
| 173 /* | 181 /* |
| 174 ** Destroy the given lock "lock". There is no point in making this race | 182 ** Destroy the given lock "lock". There is no point in making this race |
| 175 ** free because if some other thread has the pointer to this lock all | 183 ** free because if some other thread has the pointer to this lock all |
| 176 ** bets are off. | 184 ** bets are off. |
| 177 */ | 185 */ |
| 178 PR_IMPLEMENT(void) PR_DestroyLock(PRLock *lock) | 186 PR_IMPLEMENT(void) PR_DestroyLock(PRLock *lock) |
| 179 { | 187 { |
| 188 _PR_FreeLock(lock); |
| 189 PR_DELETE(lock); |
| 190 } |
| 191 |
| 192 void _PR_FreeLock(PRLock *lock) |
| 193 { |
| 180 PR_ASSERT(lock->owner == 0); | 194 PR_ASSERT(lock->owner == 0); |
| 181 » _PR_MD_FREE_LOCK(&lock->ilock); | 195 _PR_MD_FREE_LOCK(&lock->ilock); |
| 182 PR_DELETE(lock); | |
| 183 } | 196 } |
| 184 | 197 |
| 185 extern PRThread *suspendAllThread; | 198 extern PRThread *suspendAllThread; |
| 186 /* | 199 /* |
| 187 ** Lock the lock. | 200 ** Lock the lock. |
| 188 */ | 201 */ |
| 189 PR_IMPLEMENT(void) PR_Lock(PRLock *lock) | 202 PR_IMPLEMENT(void) PR_Lock(PRLock *lock) |
| 190 { | 203 { |
| 191 PRThread *me = _PR_MD_CURRENT_THREAD(); | 204 PRThread *me = _PR_MD_CURRENT_THREAD(); |
| 192 PRIntn is; | 205 PRIntn is; |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 #endif /* _PR_GLOBAL_THREADS_ONLY */ | 437 #endif /* _PR_GLOBAL_THREADS_ONLY */ |
| 425 } | 438 } |
| 426 | 439 |
| 427 /************************************************************************/ | 440 /************************************************************************/ |
| 428 /************************************************************************/ | 441 /************************************************************************/ |
| 429 /***********************ROUTINES FOR DCE EMULATION***********************/ | 442 /***********************ROUTINES FOR DCE EMULATION***********************/ |
| 430 /************************************************************************/ | 443 /************************************************************************/ |
| 431 /************************************************************************/ | 444 /************************************************************************/ |
| 432 PR_IMPLEMENT(PRStatus) PRP_TryLock(PRLock *lock) | 445 PR_IMPLEMENT(PRStatus) PRP_TryLock(PRLock *lock) |
| 433 { return (PR_TestAndLock(lock)) ? PR_SUCCESS : PR_FAILURE; } | 446 { return (PR_TestAndLock(lock)) ? PR_SUCCESS : PR_FAILURE; } |
| OLD | NEW |