VirtualBox

Changeset 101966 in vbox


Ignore:
Timestamp:
Nov 8, 2023 12:30:30 PM (13 months ago)
Author:
vboxsync
Message:

libs/xpcom/ipc: Convert PR_Atomic* to ASMAtomic*, bugref:10545

Location:
trunk/src/libs/xpcom18a4/ipc/ipcd
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp

    r101915 r101966  
    5757#include "prio.h"
    5858#include "prproces.h"
    59 #include "pratom.h"
    60 
     59
     60#include <iprt/asm.h>
    6161#include <iprt/critsect.h>
    6262
     
    7373
    7474  // threadsafe addref/release
    75   NS_HIDDEN_(nsrefcnt) AddRef()  { return PR_AtomicIncrement(&refcnt); }
    76   NS_HIDDEN_(nsrefcnt) Release() { PRInt32 r = PR_AtomicDecrement(&refcnt); if (r == 0) delete this; return r; }
     75  NS_HIDDEN_(nsrefcnt) AddRef()  { return ASMAtomicIncU32(&refcnt); }
     76  NS_HIDDEN_(nsrefcnt) Release() { uint32_t r = ASMAtomicDecU32(&refcnt); if (r == 0) delete this; return r; }
    7777
    7878  NS_HIDDEN_(void) SetObserver(ipcIMessageObserver *aObserver, PRBool aOnCurrentThread);
     
    109109  }
    110110
    111   PRInt32 refcnt;
     111  volatile uint32_t refcnt;
    112112};
    113113
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp

    r101927 r101966  
    5555# include <map>
    5656# include <list>
     57# include <iprt/asm.h>
    5758# include <iprt/err.h>
    5859# include <iprt/req.h>
     
    254255    NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");
    255256    nsrefcnt count;
    256     count = PR_AtomicIncrement((PRInt32*)&mRefCnt);
     257    count = ASMAtomicIncU32((volatile uint32_t *)&mRefCnt);
    257258    return count;
    258259  }
     
    262263    nsrefcnt count;
    263264    NS_PRECONDITION(0 != mRefCnt, "dup release");
    264     count = PR_AtomicDecrement((PRInt32 *)&mRefCnt);
     265    count = ASMAtomicDecU32((volatile uint32_t *)&mRefCnt);
    265266    if (0 == count) {
    266267      NS_PRECONDITION(PRInt32(mRefCntIPC) == 0, "non-zero IPC refcnt");
     
    278279  {
    279280    NS_PRECONDITION(PRInt32(mRefCntIPC) >= 0, "illegal refcnt");
    280     nsrefcnt count = PR_AtomicIncrement((PRInt32*)&mRefCntIPC);
     281    nsrefcnt count = ASMAtomicIncU32((volatile uint32_t *)&mRefCntIPC);
    281282    return count;
    282283  }
     
    287288  {
    288289    NS_PRECONDITION(0 != mRefCntIPC, "dup release");
    289     nsrefcnt count = PR_AtomicDecrement((PRInt32 *)&mRefCntIPC);
     290    nsrefcnt count = ASMAtomicDecU32((volatile uint32_t *)&mRefCntIPC);
    290291    if (0 == count) {
    291292      // If the last IPC reference is released, remove this instance from the map.
     
    12681269NewRequestIndex()
    12691270{
    1270   static PRInt32 sRequestIndex;
    1271   return (PRUint32) PR_AtomicIncrement(&sRequestIndex);
     1271  static volatile uint32_t sRequestIndex = 0;
     1272  return ASMAtomicIncU32(&sRequestIndex);
    12721273}
    12731274
     
    22552256{
    22562257  nsrefcnt count;
    2257   count = PR_AtomicIncrement((PRInt32*)&mRefCnt);
     2258  count = ASMAtomicIncU32((volatile uint32_t *)&mRefCnt);
    22582259  NS_LOG_ADDREF(this, count, "DConnectStub", sizeof(*this));
    22592260  return count;
     
    22762277    nsAutoLock stubLock (dConnect->StubLock());
    22772278
    2278     count = PR_AtomicDecrement((PRInt32 *)&mRefCnt);
     2279    count = ASMAtomicDecU32((volatile uint32_t *)&mRefCnt);
    22792280    NS_LOG_RELEASE(this, count, "DConnectStub");
    22802281
     
    23352336  else
    23362337  {
    2337     count = PR_AtomicDecrement((PRInt32 *)&mRefCnt);
     2338    count = ASMAtomicDecU32((volatile uint32_t *)&mRefCnt);
    23382339    NS_LOG_RELEASE(this, count, "DConnectStub");
    23392340  }
  • trunk/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcm.cpp

    r1 r101966  
    3838#include <string.h>
    3939#include "ipcm.h"
    40 #include "pratom.h"
     40
     41#include <iprt/asm.h>
    4142
    4243const nsID IPCM_TARGET =
     
    5152IPCM_NewRequestIndex()
    5253{
    53     static PRInt32 sRequestIndex;
    54     return (PRUint32) PR_AtomicIncrement(&sRequestIndex);
     54    static volatile uint32_t sRequestIndex = 0;
     55    return ASMAtomicIncU32(&sRequestIndex);
    5556}
    5657
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