Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: nspr/pr/src/pthreads/ptsynch.c

Issue 1504923011: Update NSS to 3.21 RTM and NSPR to 4.11 RTM (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/nss
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 /* 6 /*
7 ** File: ptsynch.c 7 ** File: ptsynch.c
8 ** Descritpion: Implemenation for thread synchronization using pthreads 8 ** Descritpion: Implemenation for thread synchronization using pthreads
9 ** Exports: prlock.h, prcvar.h, prmon.h, prcmon.h 9 ** Exports: prlock.h, prcvar.h, prmon.h, prcmon.h
10 */ 10 */
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 notified->cv[index].cv = cvar; 315 notified->cv[index].cv = cvar;
316 notified->length += 1; 316 notified->length += 1;
317 } /* pt_PostNotifyToCvar */ 317 } /* pt_PostNotifyToCvar */
318 318
319 PR_IMPLEMENT(PRCondVar*) PR_NewCondVar(PRLock *lock) 319 PR_IMPLEMENT(PRCondVar*) PR_NewCondVar(PRLock *lock)
320 { 320 {
321 PRCondVar *cv = PR_NEW(PRCondVar); 321 PRCondVar *cv = PR_NEW(PRCondVar);
322 PR_ASSERT(lock != NULL); 322 PR_ASSERT(lock != NULL);
323 if (cv != NULL) 323 if (cv != NULL)
324 { 324 {
325 int rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr); 325 int rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr);
326 PR_ASSERT(0 == rv); 326 PR_ASSERT(0 == rv);
327 cv->lock = lock; 327 if (0 == rv)
328 cv->notify_pending = 0; 328 {
329 cv->lock = lock;
330 cv->notify_pending = 0;
329 #if defined(DEBUG) 331 #if defined(DEBUG)
330 pt_debug.cvars_created += 1; 332 pt_debug.cvars_created += 1;
331 #endif 333 #endif
334 }
335 else
336 {
337 PR_DELETE(cv);
338 cv = NULL;
339 }
332 } 340 }
333 return cv; 341 return cv;
334 } /* PR_NewCondVar */ 342 } /* PR_NewCondVar */
335 343
336 PR_IMPLEMENT(void) PR_DestroyCondVar(PRCondVar *cvar) 344 PR_IMPLEMENT(void) PR_DestroyCondVar(PRCondVar *cvar)
337 { 345 {
338 if (0 > PR_ATOMIC_DECREMENT(&cvar->notify_pending)) 346 if (0 > PR_ATOMIC_DECREMENT(&cvar->notify_pending))
339 { 347 {
340 PRIntn rv = pthread_cond_destroy(&cvar->cv); PR_ASSERT(0 == rv); 348 PRIntn rv = pthread_cond_destroy(&cvar->cv);
341 #if defined(DEBUG) 349 #if defined(DEBUG)
350 PR_ASSERT(0 == rv);
342 memset(cvar, 0xaf, sizeof(PRCondVar)); 351 memset(cvar, 0xaf, sizeof(PRCondVar));
343 pt_debug.cvars_destroyed += 1; 352 pt_debug.cvars_destroyed += 1;
353 #else
354 (void)rv;
344 #endif 355 #endif
345 PR_Free(cvar); 356 PR_Free(cvar);
346 } 357 }
347 } /* PR_DestroyCondVar */ 358 } /* PR_DestroyCondVar */
348 359
349 PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout) 360 PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout)
350 { 361 {
351 PRIntn rv; 362 PRIntn rv;
352 PRThread *thred = PR_GetCurrentThread(); 363 PRThread *thred = PR_GetCurrentThread();
353 364
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 PR_IMPLEMENT(PRCondVar*) PRP_NewNakedCondVar(void) 1185 PR_IMPLEMENT(PRCondVar*) PRP_NewNakedCondVar(void)
1175 { 1186 {
1176 PRCondVar *cv; 1187 PRCondVar *cv;
1177 1188
1178 if (!_pr_initialized) _PR_ImplicitInitialization(); 1189 if (!_pr_initialized) _PR_ImplicitInitialization();
1179 1190
1180 cv = PR_NEW(PRCondVar); 1191 cv = PR_NEW(PRCondVar);
1181 if (cv != NULL) 1192 if (cv != NULL)
1182 { 1193 {
1183 int rv; 1194 int rv;
1184 rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr); 1195 rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr);
1185 PR_ASSERT(0 == rv); 1196 PR_ASSERT(0 == rv);
1186 cv->lock = _PR_NAKED_CV_LOCK; 1197 if (0 == rv)
1198 {
1199 cv->lock = _PR_NAKED_CV_LOCK;
1200 }
1201 else
1202 {
1203 PR_DELETE(cv);
1204 cv = NULL;
1205 }
1187 } 1206 }
1188 return cv; 1207 return cv;
1189 } /* PRP_NewNakedCondVar */ 1208 } /* PRP_NewNakedCondVar */
1190 1209
1191 PR_IMPLEMENT(void) PRP_DestroyNakedCondVar(PRCondVar *cvar) 1210 PR_IMPLEMENT(void) PRP_DestroyNakedCondVar(PRCondVar *cvar)
1192 { 1211 {
1193 int rv; 1212 int rv;
1194 rv = pthread_cond_destroy(&cvar->cv); PR_ASSERT(0 == rv); 1213 rv = pthread_cond_destroy(&cvar->cv); PR_ASSERT(0 == rv);
1195 #if defined(DEBUG) 1214 #if defined(DEBUG)
1196 memset(cvar, 0xaf, sizeof(PRCondVar)); 1215 memset(cvar, 0xaf, sizeof(PRCondVar));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 int rv; 1250 int rv;
1232 PR_ASSERT(cvar != NULL); 1251 PR_ASSERT(cvar != NULL);
1233 rv = pthread_cond_broadcast(&cvar->cv); 1252 rv = pthread_cond_broadcast(&cvar->cv);
1234 PR_ASSERT(0 == rv); 1253 PR_ASSERT(0 == rv);
1235 return PR_SUCCESS; 1254 return PR_SUCCESS;
1236 } /* PRP_NakedBroadcast */ 1255 } /* PRP_NakedBroadcast */
1237 1256
1238 #endif /* defined(_PR_PTHREADS) */ 1257 #endif /* defined(_PR_PTHREADS) */
1239 1258
1240 /* ptsynch.c */ 1259 /* ptsynch.c */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698