VirtualBox

Changeset 101978 in vbox


Ignore:
Timestamp:
Nov 8, 2023 1:44:31 PM (15 months ago)
Author:
vboxsync
Message:

libs/xpcom/xpcom/io: Convert some code from using PRLock to IPRT's RTSEMFASTMUTEX locks, bugref:10545

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/xpcom/io/nsNativeCharsetUtils.cpp

    r46043 r101978  
    5050#include <locale.h>   // setlocale
    5151#include "nscore.h"
    52 #include "prlock.h"
    5352#include "nsAString.h"
    5453#include "nsReadableUtils.h"
     54
     55#include <iprt/assert.h>
     56#include <iprt/errcore.h>
     57#include <iprt/semaphore.h>
    5558
    5659//
     
    271274    static iconv_t gUTF8ToUnicode;
    272275#endif
    273     static PRLock *gLock;
     276    static RTSEMFASTMUTEX gLock;
    274277    static PRBool  gInitialized;
    275278
    276279    static void LazyInit();
    277280
    278     static void Lock()   { if (gLock) PR_Lock(gLock);  }
    279     static void Unlock() { if (gLock) PR_Unlock(gLock); }
     281    static void Lock()   { if (gLock != NILRTSEMFASTMUTEX) RTSemFastMutexRequest(gLock); }
     282    static void Unlock() { if (gLock != NILRTSEMFASTMUTEX) RTSemFastMutexRelease(gLock); }
    280283};
    281284
     
    288291iconv_t nsNativeCharsetConverter::gUTF8ToUnicode   = INVALID_ICONV_T;
    289292#endif
    290 PRLock *nsNativeCharsetConverter::gLock            = nsnull;
     293RTSEMFASTMUTEX nsNativeCharsetConverter::gLock     = NIL_RTSEMFASTMUTEX;
    291294PRBool  nsNativeCharsetConverter::gInitialized     = PR_FALSE;
    292295
     
    364367nsNativeCharsetConverter::GlobalInit()
    365368{
    366     gLock = PR_NewLock();
    367     NS_ASSERTION(gLock, "lock creation failed");
     369    int vrc = RTSemFastMutexCreate(&gLock);
     370    NS_ASSERTION(RT_SUCCESS(vrc), "lock creation failed");
    368371}
    369372
     
    371374nsNativeCharsetConverter::GlobalShutdown()
    372375{
    373     if (gLock) {
    374         PR_DestroyLock(gLock);
    375         gLock = nsnull;
     376    if (gLock != NIL_RTSEMFASTMUTEX) {
     377        RTSemFastMutexDestroy(gLock);
     378        gLock = NIL_RTSEMFASTMUTEX;
    376379    }
    377380
     
    12791282
    12801283#endif
     1284
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