VirtualBox

Changeset 101795 in vbox


Ignore:
Timestamp:
Nov 4, 2023 9:33:05 PM (15 months ago)
Author:
vboxsync
Message:

libs/xpcom: Remove unused code because _PR_PTHREADS is always defined, bugref:10545

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prinit.c

    r101793 r101795  
    5959PRFileDesc *_pr_stderr;
    6060
    61 #if !defined(_PR_PTHREADS) && !defined(_PR_BTHREADS)
    62 
    63 PRCList _pr_active_local_threadQ =
    64                         PR_INIT_STATIC_CLIST(&_pr_active_local_threadQ);
    65 PRCList _pr_active_global_threadQ =
    66                         PR_INIT_STATIC_CLIST(&_pr_active_global_threadQ);
    67 
    68 _MDLock  _pr_cpuLock;           /* lock for the CPU Q */
    69 PRCList _pr_cpuQ = PR_INIT_STATIC_CLIST(&_pr_cpuQ);
    70 
    71 PRUint32 _pr_utid;
    72 
    73 PRInt32 _pr_userActive;
    74 PRInt32 _pr_systemActive;
    75 PRUintn _pr_maxPTDs;
    76 
    77 #ifdef _PR_LOCAL_THREADS_ONLY
    78 
    79 struct _PRCPU   *_pr_currentCPU;
    80 PRThread        *_pr_currentThread;
    81 PRThread        *_pr_lastThread;
    82 PRInt32         _pr_intsOff;
    83 
    84 #endif /* _PR_LOCAL_THREADS_ONLY */
    85 
    86 /* Lock protecting all "termination" condition variables of all threads */
    87 PRLock *_pr_terminationCVLock;
    88 
    89 #endif /* !defined(_PR_PTHREADS) */
    90 
    9161PRLock *_pr_sleeplock;  /* used in PR_Sleep(), classic and pthreads */
    9262
     
    295265    return rv;
    296266}  /* PR_Initialize */
    297 
    298 /*
    299  *-----------------------------------------------------------------------
    300  *
    301  * _PR_CleanupBeforeExit --
    302  *
    303  *   Perform the cleanup work before exiting the process.
    304  *   We first do the cleanup generic to all platforms.  Then
    305  *   we call _PR_MD_CLEANUP_BEFORE_EXIT(), where platform-dependent
    306  *   cleanup is done.  This function is used by PR_Cleanup().
    307  *
    308  * See also: PR_Cleanup().
    309  *
    310  *-----------------------------------------------------------------------
    311  */
    312 #if defined(_PR_PTHREADS) || defined(_PR_BTHREADS)
    313     /* see ptthread.c */
    314 #else
    315 static void
    316 _PR_CleanupBeforeExit(void)
    317 {
    318 /*
    319 Do not make any calls here other than to destroy resources.  For example,
    320 do not make any calls that eventually may end up in PR_Lock.  Because the
    321 thread is destroyed, can not access current thread any more.
    322 */
    323     _PR_CleanupTPD();
    324     if (_pr_terminationCVLock)
    325     /*
    326      * In light of the comment above, this looks real suspicious.
    327      * I'd go so far as to say it's just a problem waiting to happen.
    328      */
    329         PR_DestroyLock(_pr_terminationCVLock);
    330 
    331     _PR_MD_CLEANUP_BEFORE_EXIT();
    332 }
    333 #endif /* defined(_PR_PTHREADS) */
    334 
    335 /*
    336  *----------------------------------------------------------------------
    337  *
    338  * PR_Cleanup --
    339  *
    340  *   Perform a graceful shutdown of the NSPR runtime.  PR_Cleanup() may
    341  *   only be called from the primordial thread, typically at the
    342  *   end of the main() function.  It returns when it has completed
    343  *   its platform-dependent duty and the process must not make any other
    344  *   NSPR library calls prior to exiting from main().
    345  *
    346  *   PR_Cleanup() first blocks the primordial thread until all the
    347  *   other user (non-system) threads, if any, have terminated.
    348  *   Then it performs cleanup in preparation for exiting the process.
    349  *   PR_Cleanup() does not exit the primordial thread (which would
    350  *   in turn exit the process).
    351  *
    352  *   PR_Cleanup() only responds when it is called by the primordial
    353  *   thread. Calls by any other thread are silently ignored.
    354  *
    355  * See also: PR_ExitProcess()
    356  *
    357  *----------------------------------------------------------------------
    358  */
    359 #if defined(_PR_PTHREADS) || defined(_PR_BTHREADS)
    360     /* see ptthread.c */
    361 #else
    362 
    363 PR_IMPLEMENT(PRStatus) PR_Cleanup()
    364 {
    365     PRThread *me = PR_GetCurrentThread();
    366     PR_ASSERT((NULL != me) && (me->flags & _PR_PRIMORDIAL));
    367     if ((NULL != me) && (me->flags & _PR_PRIMORDIAL))
    368     {
    369         PR_LOG(_pr_thread_lm, PR_LOG_MIN, ("PR_Cleanup: shutting down NSPR"));
    370 
    371         /*
    372          * No more recycling of threads
    373          */
    374         _pr_recycleThreads = 0;
    375 
    376         /*
    377          * Wait for all other user (non-system/daemon) threads
    378          * to terminate.
    379          */
    380         PR_Lock(_pr_activeLock);
    381         while (_pr_userActive > _pr_primordialExitCount) {
    382             PR_WaitCondVar(_pr_primordialExitCVar, PR_INTERVAL_NO_TIMEOUT);
    383         }
    384         PR_Unlock(_pr_activeLock);
    385 
    386 #ifdef IRIX
    387                 _PR_MD_PRE_CLEANUP(me);
    388                 /*
    389                  * The primordial thread must now be running on the primordial cpu
    390                  */
    391         PR_ASSERT((_PR_IS_NATIVE_THREAD(me)) || (me->cpu->id == 0));
    392 #endif
    393 
    394         _PR_CleanupDtoa();
    395         _PR_CleanupCallOnce();
    396                 _PR_ShutdownLinker();
    397         /* Release the primordial thread's private data, etc. */
    398         _PR_CleanupThread(me);
    399 
    400         _PR_MD_STOP_INTERRUPTS();
    401 
    402             PR_LOG(_pr_thread_lm, PR_LOG_MIN,
    403                     ("PR_Cleanup: clean up before destroying thread"));
    404             _PR_LogCleanup();
    405 
    406         /*
    407          * This part should look like the end of _PR_NativeRunThread
    408          * and _PR_UserRunThread.
    409          */
    410         if (_PR_IS_NATIVE_THREAD(me)) {
    411             _PR_MD_EXIT_THREAD(me);
    412             _PR_NativeDestroyThread(me);
    413         } else {
    414             _PR_UserDestroyThread(me);
    415             PR_DELETE(me->stack);
    416             PR_DELETE(me);
    417         }
    418 
    419         /*
    420          * XXX: We are freeing the heap memory here so that Purify won't
    421          * complain, but we should also free other kinds of resources
    422          * that are allocated by the _PR_InitXXX() functions.
    423          * Ideally, for each _PR_InitXXX(), there should be a corresponding
    424          * _PR_XXXCleanup() that we can call here.
    425          */
    426         _PR_CleanupIO();
    427 #ifdef WINNT
    428         _PR_CleanupCPUs();
    429 #endif
    430         _PR_CleanupThreads();
    431         PR_DestroyLock(_pr_sleeplock);
    432         _pr_sleeplock = NULL;
    433         _PR_CleanupLayerCache();
    434         _PR_CleanupEnv();
    435         _PR_CleanupStacks();
    436         _PR_CleanupBeforeExit();
    437         _pr_initialized = PR_FALSE;
    438         return PR_SUCCESS;
    439     }
    440     return PR_FAILURE;
    441 }
    442 #endif /* defined(_PR_PTHREADS) */
    443 
    444 /*
    445  *------------------------------------------------------------------------
    446  * PR_ProcessExit --
    447  *
    448  *   Cause an immediate, nongraceful, forced termination of the process.
    449  *   It takes a PRIntn argument, which is the exit status code of the
    450  *   process.
    451  *
    452  * See also: PR_Cleanup()
    453  *
    454  *------------------------------------------------------------------------
    455  */
    456 
    457 #if defined(_PR_PTHREADS) || defined(_PR_BTHREADS)
    458     /* see ptthread.c */
    459 #else
    460 PR_IMPLEMENT(void) PR_ProcessExit(PRIntn status)
    461 {
    462     _PR_MD_EXIT(status);
    463 }
    464 
    465 #endif /* defined(_PR_PTHREADS) */
    466267
    467268PR_IMPLEMENT(PRProcessAttr *)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette