Condividi tramite


Funzioni intrinseche _InterlockedExchangeAdd

Sezione specifica Microsoft

Fornisce il supporto per le funzioni intrinseche del compilatore per la funzione Win32 Windows SDK Funzioni intrinseche _InterlockedExchangeAdd.

long _InterlockedExchangeAdd(
   long volatile * Addend,
   long Value
);
long _InterlockedExchangeAdd_acq(
   long volatile * Addend,
   long Value
);
long _InterlockedExchangeAdd_rel(
   long volatile * Addend,
   long Value
);
long _InterlockedExchangeAdd_nf(
   long volatile * Addend,
   long Value
);
long _InterlockedExchangeAdd_HLEAcquire(
   long volatile * Addend,
   long Value
);
long _InterlockedExchangeAdd_HLERelease(
   long volatile * Addend,
   long Value
);
char _InterlockedExchangeAdd8(
   char volatile * Addend,
   char Value
);
char _InterlockedExchangeAdd8_acq(
   char volatile * Addend,
   char Value
);
char _InterlockedExchangeAdd8_rel(
   char volatile * Addend,
   char Value
);
char _InterlockedExchangeAdd8_nf(
   char volatile * Addend,
   char Value
);
short _InterlockedExchangeAdd16(
   short volatile * Addend,
   short Value
);
short _InterlockedExchangeAdd16_acq(
   short volatile * Addend,
   short Value
);
short _InterlockedExchangeAdd16_rel(
   short volatile * Addend,
   short Value
);
short _InterlockedExchangeAdd16_nf(
   short volatile * Addend,
   short Value
);
__int64 _InterlockedExchangeAdd64(
   __int64 volatile * Addend,
   __int64 Value
);
__int64 _InterlockedExchangeAdd64_acq(
   __int64 volatile * Addend,
   __int64 Value
);
__int64 _InterlockedExchangeAdd64_rel(
   __int64 volatile * Addend,
   __int64 Value
);
__int64 _InterlockedExchangeAdd64_nf(
   __int64 volatile * Addend,
   __int64 Value
);
__int64 _InterlockedExchangeAdd64_HLEAcquire(
   __int64 volatile * Addend,
   __int64 Value
);
__int64 _InterlockedExchangeAdd64_HLERelease(
   __int64 volatile * Addend,
   __int64 Value
);

Parametri

  • [in, out] Addend
    Il valore da aggiungere a; sostituito dal risultato dell'addizione.

  • [in] Value
    Il valore da aggiungere.

Valore restituito

Il valore restituito è il valore iniziale della variabile a cui punta il parametro Addend.

Requisiti

Funzione intrinseca

Architettura

Header

_InterlockedExchangeAdd, _InterlockedExchangeAdd8, _InterlockedExchangeAdd16, _InterlockedExchangeAdd64

x86, ARM, x64

<intrin.h>

_InterlockedExchangeAdd_acq, _InterlockedExchangeAdd_rel, _InterlockedExchangeAdd_nf, _InterlockedExchangeAdd8_acq, _InterlockedExchangeAdd8_rel, _InterlockedExchangeAdd8_nf,_InterlockedExchangeAdd16_acq, _InterlockedExchangeAdd16_rel, _InterlockedExchangeAdd16_nf, _InterlockedExchangeAdd64_acq, _InterlockedExchangeAdd64_rel, _InterlockedExchangeAdd64_nf

ARM

<intrin.h>

_InterlockedExchangeAdd_HLEAcquire, _InterlockedExchangeAdd_HLERelease, _InterlockedExchangeAdd64_HLEAcquire, _InterlockedExchangeAdd64_HLErelease

x86, x64

<immintrin.h>

Note

Ci sono diverse varianti di _InterlockedExchangeAdd che variano in base ai tipi di dati interessati e all'uso della semantica di acquisizione o di rilascio specifica del processore.

Mentre la funzione _InterlockedExchangeAdd opera su valori integer a 32 bit, _InterlockedExchangeAdd8 opera su valori integer a 8 bit, _InterlockedExchangeAdd16 opera su valori integer a 16 bit e _InterlockedExchangeAdd64 opera su valori integer a 64 bit.

Sulle piattaforme ARM usare le funzioni intrinseche con i suffissi _acq e _rel per la semantica di acquisizione e di rilascio, ad esempio all'inizio e alla fine di una sezione critica. Le funzioni intrinseche con suffisso _nf ("nessun limite") non fungono da barriera di memoria.

Sulle piattaforme Intel che supportano le istruzioni HLE (Hardware Lock Elision), le funzioni intrinseche con suffissi _HLEAcquire e _HLERelease includono un hint per il processore che consente di accelerare le prestazioni eliminando un passaggio di blocco scrittura nell'hardware. Se queste funzioni intrinseche vengono chiamate su piattaforme che non supportano HLE, l'hint viene ignorato.

Queste routine sono disponibili solo come funzioni intrinseche. Pertanto, sono intrinseci a prescindere dall'uso di /Oi o #pragma intrinsic. Non è possibile usare #pragma function su queste funzioni intrinseche.

Esempio

Per un esempio di come usare _InterlockedExchangeAdd, vedere _InterlockedDecrement.

Vedere anche

Riferimenti

Intrinseci del compilatore

Parole chiave C++

Conflitti con il compilatore x86