VirtualBox

Changeset 101772 in vbox


Ignore:
Timestamp:
Nov 4, 2023 5:54:52 PM (17 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
159868
Message:

libs/xpcom: Remove prmalloc.c as _PR_OVERRIDE_MALLOC is never set in our case, bugref:10545

Location:
trunk/src/libs/xpcom18a4
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/Makefile.kmk

    r101770 r101772  
    528528        nsprpub/pr/src/io/prstdio.c \
    529529        nsprpub/pr/src/linking/prlink.c \
    530         nsprpub/pr/src/malloc/prmalloc.c \
    531530        nsprpub/pr/src/malloc/prmem.c \
    532531        nsprpub/pr/src/md/prosdep.c \
  • trunk/src/libs/xpcom18a4/nsprpub/pr/include/private/primpl.h

    r101765 r101772  
    18611861#endif
    18621862
    1863 /* Overriding malloc, free, etc. */
    1864 #if !defined(_PR_NO_PREEMPT) && defined(XP_UNIX) \
    1865         && !defined(_PR_PTHREADS) && !defined(_PR_GLOBAL_THREADS_ONLY) \
    1866         && !defined(PURIFY) \
    1867         && !defined(DARWIN) \
    1868         && !defined(NEXTSTEP) \
    1869         && !defined(QNX) \
    1870         && !(defined (UNIXWARE) && defined (USE_SVR4_THREADS))
    1871 #define _PR_OVERRIDE_MALLOC
    1872 #endif
    18731863
    18741864/*************************************************************************
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/malloc/prmem.c

    r86273 r101772  
    576576#endif /* _PR_ZONE_ALLOCATOR */
    577577
    578 /*
    579 ** Complexity alert!
    580 **
    581 ** If malloc/calloc/free (etc.) were implemented to use pr lock's then
    582 ** the entry points could block when called if some other thread had the
    583 ** lock.
    584 **
    585 ** Most of the time this isn't a problem. However, in the case that we
    586 ** are using the thread safe malloc code after PR_Init but before
    587 ** PR_AttachThread has been called (on a native thread that nspr has yet
    588 ** to be told about) we could get royally screwed if the lock was busy
    589 ** and we tried to context switch the thread away. In this scenario
    590 **      PR_CURRENT_THREAD() == NULL
    591 **
    592 ** To avoid this unfortunate case, we use the low level locking
    593 ** facilities for malloc protection instead of the slightly higher level
    594 ** locking. This makes malloc somewhat faster so maybe it's a good thing
    595 ** anyway.
    596 */
    597 #ifdef _PR_OVERRIDE_MALLOC
    598 
    599 /* Imports */
    600 extern void *_PR_UnlockedMalloc(size_t size);
    601 extern void *_PR_UnlockedMemalign(size_t alignment, size_t size);
    602 extern void _PR_UnlockedFree(void *ptr);
    603 extern void *_PR_UnlockedRealloc(void *ptr, size_t size);
    604 extern void *_PR_UnlockedCalloc(size_t n, size_t elsize);
    605 
    606 static PRBool _PR_malloc_initialised = PR_FALSE;
    607 
    608 #ifdef _PR_PTHREADS
    609 static pthread_mutex_t _PR_MD_malloc_crustylock;
    610 
    611 #define _PR_Lock_Malloc() {                                             \
    612                                 if(PR_TRUE == _PR_malloc_initialised) { \
    613                                         PRStatus rv;                    \
    614                                         rv = pthread_mutex_lock(&_PR_MD_malloc_crustylock); \
    615                                         PR_ASSERT(0 == rv);             \
    616                                 }
    617 
    618 #define _PR_Unlock_Malloc()     if(PR_TRUE == _PR_malloc_initialised) { \
    619                                         PRStatus rv;                    \
    620                                         rv = pthread_mutex_unlock(&_PR_MD_malloc_crustylock); \
    621                                         PR_ASSERT(0 == rv);             \
    622                                 }                                       \
    623                           }
    624 #else /* _PR_PTHREADS */
    625 static _MDLock _PR_MD_malloc_crustylock;
    626 
    627 #ifdef IRIX
    628 #define _PR_Lock_Malloc() {                                             \
    629                            PRIntn _is;                                  \
    630                                 if(PR_TRUE == _PR_malloc_initialised) { \
    631                                 if (_PR_MD_GET_ATTACHED_THREAD() &&             \
    632                                         !_PR_IS_NATIVE_THREAD(          \
    633                                         _PR_MD_GET_ATTACHED_THREAD()))  \
    634                                                 _PR_INTSOFF(_is);       \
    635                                         _PR_MD_LOCK(&_PR_MD_malloc_crustylock); \
    636                                 }
    637 
    638 #define _PR_Unlock_Malloc()     if(PR_TRUE == _PR_malloc_initialised) { \
    639                                         _PR_MD_UNLOCK(&_PR_MD_malloc_crustylock); \
    640                                 if (_PR_MD_GET_ATTACHED_THREAD() &&             \
    641                                         !_PR_IS_NATIVE_THREAD(          \
    642                                         _PR_MD_GET_ATTACHED_THREAD()))  \
    643                                                 _PR_INTSON(_is);        \
    644                                 }                                       \
    645                           }
    646 #else   /* IRIX */
    647 #define _PR_Lock_Malloc() {                                             \
    648                            PRIntn _is;                                  \
    649                                 if(PR_TRUE == _PR_malloc_initialised) { \
    650                                 if (_PR_MD_CURRENT_THREAD() &&          \
    651                                         !_PR_IS_NATIVE_THREAD(          \
    652                                         _PR_MD_CURRENT_THREAD()))       \
    653                                                 _PR_INTSOFF(_is);       \
    654                                         _PR_MD_LOCK(&_PR_MD_malloc_crustylock); \
    655                                 }
    656 
    657 #define _PR_Unlock_Malloc()     if(PR_TRUE == _PR_malloc_initialised) { \
    658                                         _PR_MD_UNLOCK(&_PR_MD_malloc_crustylock); \
    659                                 if (_PR_MD_CURRENT_THREAD() &&          \
    660                                         !_PR_IS_NATIVE_THREAD(          \
    661                                         _PR_MD_CURRENT_THREAD()))       \
    662                                                 _PR_INTSON(_is);        \
    663                                 }                                       \
    664                           }
    665 #endif  /* IRIX */
    666 #endif /* _PR_PTHREADS */
    667 
    668 PR_IMPLEMENT(PRStatus) _PR_MallocInit(void)
    669 {
    670     PRStatus rv = PR_SUCCESS;
    671 
    672     if( PR_TRUE == _PR_malloc_initialised ) return PR_SUCCESS;
    673 
    674 #ifdef _PR_PTHREADS
    675     {
    676         int status;
    677         pthread_mutexattr_t mattr;
    678 
    679         status = _PT_PTHREAD_MUTEXATTR_INIT(&mattr);
    680         PR_ASSERT(0 == status);
    681         status = _PT_PTHREAD_MUTEX_INIT(_PR_MD_malloc_crustylock, mattr);
    682         PR_ASSERT(0 == status);
    683         status = _PT_PTHREAD_MUTEXATTR_DESTROY(&mattr);
    684         PR_ASSERT(0 == status);
    685     }
    686 #else /* _PR_PTHREADS */
    687     _MD_NEW_LOCK(&_PR_MD_malloc_crustylock);
    688 #endif /* _PR_PTHREADS */
    689 
    690     if( PR_SUCCESS == rv )
    691     {
    692         _PR_malloc_initialised = PR_TRUE;
    693     }
    694 
    695     return rv;
    696 }
    697 
    698 void *malloc(size_t size)
    699 {
    700     void *p;
    701     _PR_Lock_Malloc();
    702     p = _PR_UnlockedMalloc(size);
    703     _PR_Unlock_Malloc();
    704     return p;
    705 }
    706 
    707 #if defined(IRIX)
    708 void *memalign(size_t alignment, size_t size)
    709 {
    710     void *p;
    711     _PR_Lock_Malloc();
    712     p = _PR_UnlockedMemalign(alignment, size);
    713     _PR_Unlock_Malloc();
    714     return p;
    715 }
    716 
    717 void *valloc(size_t size)
    718 {
    719     return(memalign(sysconf(_SC_PAGESIZE),size));
    720 }
    721 #endif  /* IRIX */
    722 
    723 void free(void *ptr)
    724 {
    725     _PR_Lock_Malloc();
    726     _PR_UnlockedFree(ptr);
    727     _PR_Unlock_Malloc();
    728 }
    729 
    730 void *realloc(void *ptr, size_t size)
    731 {
    732     void *p;
    733     _PR_Lock_Malloc();
    734     p = _PR_UnlockedRealloc(ptr, size);
    735     _PR_Unlock_Malloc();
    736     return p;
    737 }
    738 
    739 void *calloc(size_t n, size_t elsize)
    740 {
    741     void *p;
    742     _PR_Lock_Malloc();
    743     p = _PR_UnlockedCalloc(n, elsize);
    744     _PR_Unlock_Malloc();
    745     return p;
    746 }
    747 
    748 void cfree(void *p)
    749 {
    750     _PR_Lock_Malloc();
    751     _PR_UnlockedFree(p);
    752     _PR_Unlock_Malloc();
    753 }
    754 
    755 void _PR_InitMem(void)
    756 {
    757     PRStatus rv;
    758     rv = _PR_MallocInit();
    759     PR_ASSERT(PR_SUCCESS == rv);
    760 }
    761 
    762 #endif /* _PR_OVERRIDE_MALLOC */
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prinit.c

    r101770 r101772  
    231231#ifndef _PR_GLOBAL_THREADS_ONLY
    232232        _PR_InitCPUs();
    233 #endif
    234 
    235 /*
    236  * XXX: call _PR_InitMem only on those platforms for which nspr implements
    237  *      malloc, for now.
    238  */
    239 #ifdef _PR_OVERRIDE_MALLOC
    240     _PR_InitMem();
    241233#endif
    242234
Note: See TracChangeset for help on using the changeset viewer.

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