Share via


_InterlockedExchange funzioni intrinseche

Sezione specifica Microsoft

Genera un'istruzione atomica per impostare un valore specificato.

Sintassi

long _InterlockedExchange(
   long volatile * Target,
   long Value
);
long _InterlockedExchange_acq(
   long volatile * Target,
   long Value
);
long _InterlockedExchange_HLEAcquire(
   long volatile * Target,
   long Value
);
long _InterlockedExchange_HLERelease(
   long volatile * Target,
   long Value
);
long _InterlockedExchange_nf(
   long volatile * Target,
   long Value
);
long _InterlockedExchange_rel(
   long volatile * Target,
   long Value
);
char _InterlockedExchange8(
   char volatile * Target,
   char Value
);
char _InterlockedExchange8_acq(
   char volatile * Target,
   char Value
);
char _InterlockedExchange8_nf(
   char volatile * Target,
   char Value
);
char _InterlockedExchange8_rel(
   char volatile * Target,
   char Value
);
short _InterlockedExchange16(
   short volatile * Target,
   short Value
);
short _InterlockedExchange16_acq(
   short volatile * Target,
   short Value
);
short _InterlockedExchange16_nf(
   short volatile * Target,
   short Value
);
short _InterlockedExchange16_rel(
   short volatile * Target,
   short Value
);
__int64 _InterlockedExchange64(
   __int64 volatile * Target,
   __int64 Value
);
__int64 _InterlockedExchange64_acq(
   __int64 volatile * Target,
   __int64 Value
);
__int64 _InterlockedExchange64_HLEAcquire(
   __int64 volatile * Target,
   __int64 Value
);
__int64 _InterlockedExchange64_HLERelease(
   __int64 volatile * Target,
   __int64 Value
);
__int64 _InterlockedExchange64_nf(
   __int64 volatile * Target,
   __int64 Value
);
__int64 _InterlockedExchange64_rel(
   __int64 volatile * Target,
   __int64 Value
);

Parametri

Destinazione
[in, out] Puntatore al valore da scambiare. La funzione imposta questa variabile su Value e restituisce il valore precedente.

valore
[in] Valore da scambiare con il valore a Targetcui punta .

Valore restituito

Restituisce il valore iniziale a cui punta Target.

Requisiti

Intrinsic Architettura Intestazione
_InterlockedExchange, _InterlockedExchange8, _InterlockedExchange16 x86, ARM, x64, ARM64 <intrin.h>
_InterlockedExchange64 ARM, x64, ARM64 <intrin.h>
_InterlockedExchange_acq, _InterlockedExchange_nf, _InterlockedExchange_rel, _InterlockedExchange8_acq, _InterlockedExchange8_nf, _InterlockedExchange8_rel, _InterlockedExchange16_acq, _InterlockedExchange16_nf, _InterlockedExchange16_rel, _InterlockedExchange64_acq, _InterlockedExchange64_nf, _InterlockedExchange64_rel, ARM, ARM64 <intrin.h>
_InterlockedExchange_HLEAcquire, _InterlockedExchange_HLERelease x86, x64 <immintrin.h>
_InterlockedExchange64_HLEAcquire, _InterlockedExchange64_HLERelease x64 <immintrin.h>

Osservazioni:

_InterlockedExchangefornisce il supporto intrinseco del compilatore per la funzione InterlockedExchange di Windows SDK Win32.

Ci sono diverse varianti di _InterlockedExchange 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 _InterlockedExchange opera su valori integer a 32 bit, _InterlockedExchange8 opera su valori integer a 8 bit, _InterlockedExchange16 opera su valori integer a 16 bit e _InterlockedExchange64 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. I suffissi intrinseci con un _nf suffisso ("nessun recinto") 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.

Esempio

Per un esempio di come usare _InterlockedExchange, vedere _InterlockedDecrement.

Fine sezione specifica Microsoft

Vedi anche

Intrinseci del compilatore
Parole chiave
Conflitti con il compilatore x86