- Timestamp:
- Nov 7, 2023 3:22:59 PM (16 months ago)
- svn:sync-xref-src-repo-rev:
- 160044
- Location:
- trunk/src/libs/xpcom18a4/nsprpub/pr
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/nsprpub/pr/include/prinit.h
r101818 r101947 46 46 #define PR_Abort VBoxNsprPR_Abort 47 47 #define PR_Cleanup VBoxNsprPR_Cleanup 48 #define PR_DisableClockInterrupts VBoxNsprPR_DisableClockInterrupts49 #define PR_EnableClockInterrupts VBoxNsprPR_EnableClockInterrupts50 #define PR_BlockClockInterrupts VBoxNsprPR_BlockClockInterrupts51 #define PR_UnblockClockInterrupts VBoxNsprPR_UnblockClockInterrupts52 48 #define PR_Init VBoxNsprPR_Init 53 49 #define PR_Initialize VBoxNsprPR_Initialize 54 50 #define PR_Initialized VBoxNsprPR_Initialized 55 #define PR_VersionCheck VBoxNsprPR_VersionCheck56 51 #define PR_SetFDCacheSize VBoxNsprPR_SetFDCacheSize 57 #define PR_ProcessExit VBoxNsprPR_ProcessExit58 #define PR_CallOnce VBoxNsprPR_CallOnce59 #define PR_CallOnceWithArg VBoxNsprPR_CallOnceWithArg60 52 #endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */ 61 53 … … 85 77 #define PR_VPATCH 0 86 78 #define PR_BETA PR_TRUE 87 88 /*89 ** PRVersionCheck90 **91 ** The basic signature of the function that is called to provide version92 ** checking. The result will be a boolean that indicates the likelihood93 ** that the underling library will perform as the caller expects.94 **95 ** The only argument is a string, which should be the verson identifier96 ** of the library in question. That string will be compared against an97 ** equivalent string that represents the actual build version of the98 ** exporting library.99 **100 ** The result will be the logical union of the directly called library101 ** and all dependent libraries.102 */103 104 typedef PRBool (*PRVersionCheck)(const char*);105 106 /*107 ** PR_VersionCheck108 **109 ** NSPR's existance proof of the version check function.110 **111 ** Note that NSPR has no cooperating dependencies.112 */113 114 NSPR_API(PRBool) PR_VersionCheck(const char *importedVersion);115 116 79 117 80 /************************************************************************/ … … 175 138 176 139 /* 177 ** Disable Interrupts178 ** Disables timer signals used for pre-emptive scheduling.179 */180 NSPR_API(void) PR_DisableClockInterrupts(void);181 182 /*183 ** Enables Interrupts184 ** Enables timer signals used for pre-emptive scheduling.185 */186 NSPR_API(void) PR_EnableClockInterrupts(void);187 188 /*189 ** Block Interrupts190 ** Blocks the timer signal used for pre-emptive scheduling191 */192 NSPR_API(void) PR_BlockClockInterrupts(void);193 194 /*195 ** Unblock Interrupts196 ** Unblocks the timer signal used for pre-emptive scheduling197 */198 NSPR_API(void) PR_UnblockClockInterrupts(void);199 200 /*201 140 ** Control the method and size of the file descriptor (PRFileDesc*) 202 141 ** cache used by the runtime. Setting 'high' to zero is for performance, … … 204 143 */ 205 144 NSPR_API(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high); 206 207 /*208 * Cause an immediate, nongraceful, forced termination of the process.209 * It takes a PRIntn argument, which is the exit status code of the210 * process.211 */212 NSPR_API(void) PR_ProcessExit(PRIntn status);213 145 214 146 /* … … 219 151 NSPR_API(void) PR_Abort(void); 220 152 221 /*222 ****************************************************************223 *224 * Module initialization:225 *226 ****************************************************************227 */228 229 typedef struct PRCallOnceType {230 PRIntn initialized;231 PRInt32 inProgress;232 PRStatus status;233 } PRCallOnceType;234 235 typedef PRStatus (PR_CALLBACK *PRCallOnceFN)(void);236 237 typedef PRStatus (PR_CALLBACK *PRCallOnceWithArgFN)(void *arg);238 239 NSPR_API(PRStatus) PR_CallOnce(240 PRCallOnceType *once,241 PRCallOnceFN func242 );243 244 NSPR_API(PRStatus) PR_CallOnceWithArg(245 PRCallOnceType *once,246 PRCallOnceWithArgFN func,247 void *arg248 );249 250 251 153 PR_END_EXTERN_C 252 154 -
trunk/src/libs/xpcom18a4/nsprpub/pr/include/private/primpl.h
r101945 r101947 516 516 extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me); 517 517 extern void _PR_CleanupThread(PRThread *thread); 518 extern void _PR_CleanupCallOnce(void);519 518 extern void _PR_CleanupMW(void); 520 519 extern void _PR_CleanupDtoa(void); … … 535 534 extern PRBool _pr_initialized; 536 535 extern void _PR_ImplicitInitialization(void); 537 extern PRBool _PR_Obsolete(const char *obsolete, const char *preferred);538 536 539 537 /************************************************************************/ -
trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prinit.c
r101945 r101947 68 68 PRLock *_pr_sleeplock; /* used in PR_Sleep(), classic and pthreads */ 69 69 70 static void _PR_InitCallOnce(void);71 72 70 PRBool _pr_initialized = PR_FALSE; 73 74 75 PR_IMPLEMENT(PRBool) PR_VersionCheck(const char *importedVersion)76 {77 /*78 ** This is the secret handshake algorithm.79 **80 ** This release has a simple version compatibility81 ** check algorithm. This release is not backward82 ** compatible with previous major releases. It is83 ** not compatible with future major, minor, or84 ** patch releases.85 */86 int vmajor = 0, vminor = 0, vpatch = 0;87 const char *ptr = importedVersion;88 89 while (isdigit(*ptr)) {90 vmajor = 10 * vmajor + *ptr - '0';91 ptr++;92 }93 if (*ptr == '.') {94 ptr++;95 while (isdigit(*ptr)) {96 vminor = 10 * vminor + *ptr - '0';97 ptr++;98 }99 if (*ptr == '.') {100 ptr++;101 while (isdigit(*ptr)) {102 vpatch = 10 * vpatch + *ptr - '0';103 ptr++;104 }105 }106 }107 108 if (vmajor != PR_VMAJOR) {109 return PR_FALSE;110 }111 if (vmajor == PR_VMAJOR && vminor > PR_VMINOR) {112 return PR_FALSE;113 }114 if (vmajor == PR_VMAJOR && vminor == PR_VMINOR && vpatch > PR_VPATCH) {115 return PR_FALSE;116 }117 return PR_TRUE;118 } /* PR_VersionCheck */119 71 120 72 … … 163 115 _PR_InitIO(); 164 116 _PR_InitLog(); 165 _PR_InitCallOnce();166 117 _PR_InitDtoa(); 167 118 … … 174 125 { 175 126 _PR_InitStuff(); 176 }177 178 PR_IMPLEMENT(void) PR_DisableClockInterrupts(void)179 {180 }181 182 PR_IMPLEMENT(void) PR_EnableClockInterrupts(void)183 {184 }185 186 PR_IMPLEMENT(void) PR_BlockClockInterrupts(void)187 {188 }189 190 PR_IMPLEMENT(void) PR_UnblockClockInterrupts(void)191 {192 127 } 193 128 … … 483 418 } 484 419 485 /*486 ********************************************************************487 *488 * Module initialization489 *490 ********************************************************************491 */492 493 static struct {494 PRLock *ml;495 PRCondVar *cv;496 } mod_init;497 498 static void _PR_InitCallOnce(void) {499 mod_init.ml = PR_NewLock();500 PR_ASSERT(NULL != mod_init.ml);501 mod_init.cv = PR_NewCondVar(mod_init.ml);502 PR_ASSERT(NULL != mod_init.cv);503 }504 505 void _PR_CleanupCallOnce()506 {507 PR_DestroyLock(mod_init.ml);508 mod_init.ml = NULL;509 PR_DestroyCondVar(mod_init.cv);510 mod_init.cv = NULL;511 }512 513 PR_IMPLEMENT(PRStatus) PR_CallOnce(514 PRCallOnceType *once,515 PRCallOnceFN func)516 {517 if (!_pr_initialized) _PR_ImplicitInitialization();518 519 if (!once->initialized) {520 if (PR_AtomicSet(&once->inProgress, 1) == 0) {521 once->status = (*func)();522 PR_Lock(mod_init.ml);523 once->initialized = 1;524 PR_NotifyAllCondVar(mod_init.cv);525 PR_Unlock(mod_init.ml);526 } else {527 PR_Lock(mod_init.ml);528 while (!once->initialized) {529 PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT);530 }531 PR_Unlock(mod_init.ml);532 }533 }534 return once->status;535 }536 537 PR_IMPLEMENT(PRStatus) PR_CallOnceWithArg(538 PRCallOnceType *once,539 PRCallOnceWithArgFN func,540 void *arg)541 {542 if (!_pr_initialized) _PR_ImplicitInitialization();543 544 if (!once->initialized) {545 if (PR_AtomicSet(&once->inProgress, 1) == 0) {546 once->status = (*func)(arg);547 PR_Lock(mod_init.ml);548 once->initialized = 1;549 PR_NotifyAllCondVar(mod_init.cv);550 PR_Unlock(mod_init.ml);551 } else {552 PR_Lock(mod_init.ml);553 while (!once->initialized) {554 PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT);555 }556 PR_Unlock(mod_init.ml);557 }558 }559 return once->status;560 }561 562 PRBool _PR_Obsolete(const char *obsolete, const char *preferred)563 {564 #if defined(DEBUG)565 PR_fprintf(566 PR_STDERR, "'%s' is obsolete. Use '%s' instead.\n",567 obsolete, (NULL == preferred) ? "something else" : preferred);568 #endif569 return PR_FALSE;570 } /* _PR_Obsolete */571 572 420 /* prinit.c */ 573 421 574 -
trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptthread.c
r101945 r101947 656 656 657 657 _PR_CleanupDtoa(); 658 _PR_CleanupCallOnce();659 658 _PR_LogCleanup(); 660 659 /* Close all the fd's before calling _PR_CleanupIO */
Note:
See TracChangeset
for help on using the changeset viewer.