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 #ifndef primpl_h___ | 6 #ifndef primpl_h___ |
7 #define primpl_h___ | 7 #define primpl_h___ |
8 | 8 |
9 /* | 9 /* |
10 * HP-UX 10.10's pthread.h (DCE threads) includes dce/cma.h, which | 10 * HP-UX 10.10's pthread.h (DCE threads) includes dce/cma.h, which |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 NSPR_API(void) _PR_PauseCPU(void); | 532 NSPR_API(void) _PR_PauseCPU(void); |
533 | 533 |
534 /************************************************************************/ | 534 /************************************************************************/ |
535 | 535 |
536 #define _PR_LOCK_LOCK(_lock) \ | 536 #define _PR_LOCK_LOCK(_lock) \ |
537 _PR_MD_LOCK(&(_lock)->ilock); | 537 _PR_MD_LOCK(&(_lock)->ilock); |
538 #define _PR_LOCK_UNLOCK(_lock) \ | 538 #define _PR_LOCK_UNLOCK(_lock) \ |
539 _PR_MD_UNLOCK(&(_lock)->ilock); | 539 _PR_MD_UNLOCK(&(_lock)->ilock); |
540 | 540 |
541 extern void _PR_UnblockLockWaiter(PRLock *lock); | 541 extern void _PR_UnblockLockWaiter(PRLock *lock); |
| 542 extern PRStatus _PR_InitLock(PRLock *lock); |
| 543 extern void _PR_FreeLock(PRLock *lock); |
542 | 544 |
543 #define _PR_LOCK_PTR(_qp) \ | 545 #define _PR_LOCK_PTR(_qp) \ |
544 ((PRLock*) ((char*) (_qp) - offsetof(PRLock,links))) | 546 ((PRLock*) ((char*) (_qp) - offsetof(PRLock,links))) |
545 | 547 |
546 /************************************************************************/ | 548 /************************************************************************/ |
547 | 549 |
548 #define _PR_CVAR_LOCK(_cvar) \ | 550 #define _PR_CVAR_LOCK(_cvar) \ |
549 _PR_MD_LOCK(&(_cvar)->ilock); | 551 _PR_MD_LOCK(&(_cvar)->ilock); |
550 #define _PR_CVAR_UNLOCK(_cvar) \ | 552 #define _PR_CVAR_UNLOCK(_cvar) \ |
551 _PR_MD_UNLOCK(&(_cvar)->ilock); | 553 _PR_MD_UNLOCK(&(_cvar)->ilock); |
552 | 554 |
| 555 extern PRStatus _PR_InitCondVar(PRCondVar *cvar, PRLock *lock); |
| 556 extern void _PR_FreeCondVar(PRCondVar *cvar); |
553 extern PRStatus _PR_WaitCondVar( | 557 extern PRStatus _PR_WaitCondVar( |
554 PRThread *thread, PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout); | 558 PRThread *thread, PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout); |
| 559 extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me); |
555 extern PRUint32 _PR_CondVarToString(PRCondVar *cvar, char *buf, PRUint32 buflen)
; | 560 extern PRUint32 _PR_CondVarToString(PRCondVar *cvar, char *buf, PRUint32 buflen)
; |
556 | 561 |
557 NSPR_API(void) _PR_Notify(PRMonitor *mon, PRBool all, PRBool sticky); | 562 NSPR_API(void) _PR_Notify(PRMonitor *mon, PRBool all, PRBool sticky); |
558 | 563 |
559 /* PRThread.flags */ | 564 /* PRThread.flags */ |
560 #define _PR_SYSTEM 0x01 | 565 #define _PR_SYSTEM 0x01 |
561 #define _PR_INTERRUPT 0x02 | 566 #define _PR_INTERRUPT 0x02 |
562 #define _PR_ATTACHED 0x04 /* created via PR_AttachThread */ | 567 #define _PR_ATTACHED 0x04 /* created via PR_AttachThread */ |
563 #define _PR_PRIMORDIAL 0x08 /* the thread that called PR_Init */ | 568 #define _PR_PRIMORDIAL 0x08 /* the thread that called PR_Init */ |
564 #define _PR_ON_SLEEPQ 0x10 /* thread is on the sleepQ */ | 569 #define _PR_ON_SLEEPQ 0x10 /* thread is on the sleepQ */ |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 #else /* not pthreads or Be threads */ | 1418 #else /* not pthreads or Be threads */ |
1414 PRCList links; /* linkage for PRThread.lockList */ | 1419 PRCList links; /* linkage for PRThread.lockList */ |
1415 struct PRThread *owner; /* current lock owner */ | 1420 struct PRThread *owner; /* current lock owner */ |
1416 PRCList waitQ; /* list of threads waiting for lock */ | 1421 PRCList waitQ; /* list of threads waiting for lock */ |
1417 PRThreadPriority priority; /* priority of lock */ | 1422 PRThreadPriority priority; /* priority of lock */ |
1418 PRThreadPriority boostPriority; /* boosted priority of lock owner */ | 1423 PRThreadPriority boostPriority; /* boosted priority of lock owner */ |
1419 _MDLock ilock; /* Internal Lock to protect user-level field
s */ | 1424 _MDLock ilock; /* Internal Lock to protect user-level field
s */ |
1420 #endif | 1425 #endif |
1421 }; | 1426 }; |
1422 | 1427 |
1423 extern void _PR_InitLocks(void); | |
1424 | |
1425 struct PRCondVar { | 1428 struct PRCondVar { |
1426 PRLock *lock; /* associated lock that protects the condition *
/ | 1429 PRLock *lock; /* associated lock that protects the condition *
/ |
1427 #if defined(_PR_PTHREADS) | 1430 #if defined(_PR_PTHREADS) |
1428 pthread_cond_t cv; /* underlying pthreads condition */ | 1431 pthread_cond_t cv; /* underlying pthreads condition */ |
1429 PRInt32 notify_pending; /* CV has destroy pending notification */ | 1432 PRInt32 notify_pending; /* CV has destroy pending notification */ |
1430 #elif defined(_PR_BTHREADS) | 1433 #elif defined(_PR_BTHREADS) |
1431 sem_id sem; /* the underlying lock */ | 1434 sem_id sem; /* the underlying lock */ |
1432 sem_id handshakeSem; /* the lock for 'notify'-threads waiting for con
firmation */ | 1435 sem_id handshakeSem; /* the lock for 'notify'-threads waiting for con
firmation */ |
1433 sem_id signalSem; /* the lock for threads waiting for someone to n
otify */ | 1436 sem_id signalSem; /* the lock for threads waiting for someone to n
otify */ |
1434 volatile int32 nw; /* the number waiting */ | 1437 volatile int32 nw; /* the number waiting */ |
1435 volatile int32 ns; /* the number signalling */ | 1438 volatile int32 ns; /* the number signalling */ |
1436 long signalBenCount; /* the number waiting on the underlying sem */ | 1439 long signalBenCount; /* the number waiting on the underlying sem */ |
1437 #else /* not pthreads or Be threads */ | 1440 #else /* not pthreads or Be threads */ |
1438 PRCList condQ; /* Condition variable wait Q */ | 1441 PRCList condQ; /* Condition variable wait Q */ |
1439 _MDLock ilock; /* Internal Lock to protect condQ */ | 1442 _MDLock ilock; /* Internal Lock to protect condQ */ |
1440 _MDCVar md; | 1443 _MDCVar md; |
1441 #endif | 1444 #endif |
1442 }; | 1445 }; |
1443 | 1446 |
1444 /************************************************************************/ | 1447 /************************************************************************/ |
1445 | 1448 |
1446 struct PRMonitor { | 1449 struct PRMonitor { |
1447 const char* name; /* monitor name for debugging */ | 1450 const char* name; /* monitor name for debugging */ |
1448 #if defined(_PR_PTHREADS) | 1451 #if defined(_PR_PTHREADS) |
1449 PRLock lock; /* the lock structure */ | 1452 pthread_mutex_t lock; /* lock is only held when accessing fields |
1450 pthread_t owner; /* the owner of the lock or invalid */ | 1453 * of the PRMonitor, instead of being held |
1451 PRCondVar *cvar; /* condition variable queue */ | 1454 * while the monitor is entered. The only |
| 1455 * exception is notifyTimes, which is |
| 1456 * protected by the monitor. */ |
| 1457 pthread_t owner; /* the owner of the monitor or invalid */ |
| 1458 pthread_cond_t entryCV; /* for threads waiting to enter the monitor */ |
| 1459 |
| 1460 pthread_cond_t waitCV; /* for threads waiting on the monitor */ |
| 1461 PRInt32 refCount; /* reference count, an atomic variable. |
| 1462 * PR_NewMonitor adds a reference to the |
| 1463 * newly created PRMonitor, and |
| 1464 * PR_DestroyMonitor releases that reference. |
| 1465 * PR_ExitMonitor adds a reference before |
| 1466 * unlocking the internal lock if it needs to |
| 1467 * signal entryCV, and releases the reference |
| 1468 * after signaling entryCV. */ |
1452 #else /* defined(_PR_PTHREADS) */ | 1469 #else /* defined(_PR_PTHREADS) */ |
1453 PRCondVar *cvar; /* associated lock and condition variable queue
*/ | 1470 PRLock lock; /* lock is only held when accessing fields |
| 1471 * of the PRMonitor, instead of being held |
| 1472 * while the monitor is entered. The only |
| 1473 * exception is notifyTimes, which is |
| 1474 * protected by the monitor. */ |
| 1475 PRThread *owner; /* the owner of the monitor or invalid */ |
| 1476 PRCondVar entryCV; /* for threads waiting to enter the monitor */ |
| 1477 |
| 1478 PRCondVar waitCV; /* for threads waiting on the monitor */ |
1454 #endif /* defined(_PR_PTHREADS) */ | 1479 #endif /* defined(_PR_PTHREADS) */ |
1455 PRUint32 entryCount; /* # of times re-entered */ | 1480 PRUint32 entryCount; /* # of times re-entered */ |
| 1481 PRIntn notifyTimes; /* number of pending notifies for waitCV. |
| 1482 * The special value -1 means a broadcast |
| 1483 * (PR_NotifyAll). */ |
1456 }; | 1484 }; |
1457 | 1485 |
1458 /************************************************************************/ | 1486 /************************************************************************/ |
1459 | 1487 |
1460 struct PRSemaphore { | 1488 struct PRSemaphore { |
1461 #if defined(_PR_BTHREADS) | 1489 #if defined(_PR_BTHREADS) |
1462 sem_id sem; | 1490 sem_id sem; |
1463 int32 benaphoreCount; | 1491 int32 benaphoreCount; |
1464 #else | 1492 #else |
1465 PRCondVar *cvar; /* associated lock and condition variable queue */ | 1493 PRCondVar *cvar; /* associated lock and condition variable queue */ |
1466 PRUintn count; /* the value of the counting semaphore */ | 1494 PRUintn count; /* the value of the counting semaphore */ |
1467 PRUint32 waiters; /* threads waiting on the semaphore */ | 1495 PRUint32 waiters; /* threads waiting on the semaphore */ |
1468 #if defined(_PR_PTHREADS) | 1496 #if defined(_PR_PTHREADS) |
1469 #else /* defined(_PR_PTHREADS) */ | 1497 #else /* defined(_PR_PTHREADS) */ |
1470 _MDSemaphore md; | 1498 _MDSemaphore md; |
1471 #endif /* defined(_PR_PTHREADS) */ | 1499 #endif /* defined(_PR_PTHREADS) */ |
1472 #endif /* defined(_PR_BTHREADS) */ | 1500 #endif /* defined(_PR_BTHREADS) */ |
1473 }; | 1501 }; |
1474 | 1502 |
1475 NSPR_API(void) _PR_InitSem(void); | |
1476 | |
1477 /*************************************************************************/ | 1503 /*************************************************************************/ |
1478 | 1504 |
1479 struct PRSem { | 1505 struct PRSem { |
1480 #ifdef _PR_HAVE_POSIX_SEMAPHORES | 1506 #ifdef _PR_HAVE_POSIX_SEMAPHORES |
1481 sem_t *sem; | 1507 sem_t *sem; |
1482 #elif defined(_PR_HAVE_SYSV_SEMAPHORES) | 1508 #elif defined(_PR_HAVE_SYSV_SEMAPHORES) |
1483 int semid; | 1509 int semid; |
1484 #elif defined(WIN32) | 1510 #elif defined(WIN32) |
1485 HANDLE sem; | 1511 HANDLE sem; |
1486 #else | 1512 #else |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 void **privateData; /* private data vector or NULL */ | 1574 void **privateData; /* private data vector or NULL */ |
1549 PRErrorCode errorCode; /* current NSPR error code | zero */ | 1575 PRErrorCode errorCode; /* current NSPR error code | zero */ |
1550 PRInt32 osErrorCode; /* mapping of errorCode | zero */ | 1576 PRInt32 osErrorCode; /* mapping of errorCode | zero */ |
1551 PRIntn errorStringLength; /* textLength from last call to PR_SetErrorT
ext() */ | 1577 PRIntn errorStringLength; /* textLength from last call to PR_SetErrorT
ext() */ |
1552 PRInt32 errorStringSize; /* malloc()'d size of buffer | zero */ | 1578 PRInt32 errorStringSize; /* malloc()'d size of buffer | zero */ |
1553 char *errorString; /* current error string | NULL */ | 1579 char *errorString; /* current error string | NULL */ |
1554 char *name; /* thread's name */ | 1580 char *name; /* thread's name */ |
1555 | 1581 |
1556 #if defined(_PR_PTHREADS) | 1582 #if defined(_PR_PTHREADS) |
1557 pthread_t id; /* pthread identifier for the thread */ | 1583 pthread_t id; /* pthread identifier for the thread */ |
| 1584 PRBool idSet; /* whether 'id' has been set. Protected by |
| 1585 * pt_book.ml. */ |
1558 #ifdef _PR_NICE_PRIORITY_SCHEDULING | 1586 #ifdef _PR_NICE_PRIORITY_SCHEDULING |
1559 pid_t tid; /* Linux-specific kernel thread ID */ | 1587 pid_t tid; /* Linux-specific kernel thread ID */ |
1560 #endif | 1588 #endif |
1561 PRBool okToDelete; /* ok to delete the PRThread struct? */ | 1589 PRBool okToDelete; /* ok to delete the PRThread struct? */ |
1562 PRCondVar *waiting; /* where the thread is waiting | NULL */ | 1590 PRCondVar *waiting; /* where the thread is waiting | NULL */ |
1563 void *sp; /* recorded sp for garbage collection */ | 1591 void *sp; /* recorded sp for garbage collection */ |
1564 PRThread *next, *prev; /* simple linked list of all threads */ | 1592 PRThread *next, *prev; /* simple linked list of all threads */ |
1565 PRUint32 suspend; /* used to store suspend and resume flags */ | 1593 PRUint32 suspend; /* used to store suspend and resume flags */ |
1566 #ifdef PT_NO_SIGTIMEDWAIT | 1594 #ifdef PT_NO_SIGTIMEDWAIT |
1567 pthread_mutex_t suspendResumeMutex; | 1595 pthread_mutex_t suspendResumeMutex; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1738 _MDDir md; | 1766 _MDDir md; |
1739 }; | 1767 }; |
1740 | 1768 |
1741 #ifdef MOZ_UNICODE | 1769 #ifdef MOZ_UNICODE |
1742 struct PRDirUTF16 { | 1770 struct PRDirUTF16 { |
1743 PRDirEntry d; | 1771 PRDirEntry d; |
1744 _MDDirUTF16 md; | 1772 _MDDirUTF16 md; |
1745 }; | 1773 }; |
1746 #endif /* MOZ_UNICODE */ | 1774 #endif /* MOZ_UNICODE */ |
1747 | 1775 |
| 1776 extern void _PR_InitLocks(void); |
1748 extern void _PR_InitSegs(void); | 1777 extern void _PR_InitSegs(void); |
1749 extern void _PR_InitStacks(void); | 1778 extern void _PR_InitStacks(void); |
1750 extern void _PR_InitTPD(void); | 1779 extern void _PR_InitTPD(void); |
1751 extern void _PR_InitMem(void); | 1780 extern void _PR_InitMem(void); |
1752 extern void _PR_InitEnv(void); | 1781 extern void _PR_InitEnv(void); |
1753 extern void _PR_InitCMon(void); | 1782 extern void _PR_InitCMon(void); |
1754 extern void _PR_InitIO(void); | 1783 extern void _PR_InitIO(void); |
1755 extern void _PR_InitLog(void); | 1784 extern void _PR_InitLog(void); |
1756 extern void _PR_InitNet(void); | 1785 extern void _PR_InitNet(void); |
1757 extern void _PR_InitClock(void); | 1786 extern void _PR_InitClock(void); |
1758 extern void _PR_InitLinker(void); | 1787 extern void _PR_InitLinker(void); |
1759 extern void _PR_InitAtomic(void); | 1788 extern void _PR_InitAtomic(void); |
1760 extern void _PR_InitCPUs(void); | 1789 extern void _PR_InitCPUs(void); |
1761 extern void _PR_InitDtoa(void); | 1790 extern void _PR_InitDtoa(void); |
1762 extern void _PR_InitTime(void); | 1791 extern void _PR_InitTime(void); |
1763 extern void _PR_InitMW(void); | 1792 extern void _PR_InitMW(void); |
1764 extern void _PR_InitRWLocks(void); | 1793 extern void _PR_InitRWLocks(void); |
1765 extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me); | |
1766 extern void _PR_CleanupThread(PRThread *thread); | 1794 extern void _PR_CleanupThread(PRThread *thread); |
1767 extern void _PR_CleanupCallOnce(void); | 1795 extern void _PR_CleanupCallOnce(void); |
1768 extern void _PR_CleanupMW(void); | 1796 extern void _PR_CleanupMW(void); |
1769 extern void _PR_CleanupTime(void); | 1797 extern void _PR_CleanupTime(void); |
1770 extern void _PR_CleanupDtoa(void); | 1798 extern void _PR_CleanupDtoa(void); |
1771 extern void _PR_ShutdownLinker(void); | 1799 extern void _PR_ShutdownLinker(void); |
1772 extern void _PR_CleanupEnv(void); | 1800 extern void _PR_CleanupEnv(void); |
1773 extern void _PR_CleanupIO(void); | 1801 extern void _PR_CleanupIO(void); |
1774 extern void _PR_CleanupCMon(void); | 1802 extern void _PR_CleanupCMon(void); |
1775 extern void _PR_CleanupNet(void); | 1803 extern void _PR_CleanupNet(void); |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2114 | 2142 |
2115 extern ConnectListNode connectList[64]; | 2143 extern ConnectListNode connectList[64]; |
2116 | 2144 |
2117 extern PRUint32 connectCount; | 2145 extern PRUint32 connectCount; |
2118 | 2146 |
2119 #endif /* XP_BEOS */ | 2147 #endif /* XP_BEOS */ |
2120 | 2148 |
2121 PR_END_EXTERN_C | 2149 PR_END_EXTERN_C |
2122 | 2150 |
2123 #endif /* primpl_h___ */ | 2151 #endif /* primpl_h___ */ |
OLD | NEW |