Compartilhar via


Funções intrínsecas _InterlockedExchange

Seção específica da Microsoft

Gera uma instrução atômica para definir um valor especificado.

Sintaxe

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
);

Parâmetros

Target (destino)
[in, out] Ponteiro para o valor a ser trocado. A função define essa variável como Value e retorna seu valor anterior.

Valor
[in] Valor a ser trocado pelo valor apontado por Target.

Retornar valor

Retorna o valor inicial apontado por Target.

Requisitos

Intrinsic Arquitetura Cabeçalho
_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>

Comentários

_InterlockedExchange dá suporte intrínseco de compilador à função InterlockedExchange do SDK do Windows Win32.

Há diversas variações em _InterlockedExchange que têm base no tipo de dados que envolvem e se a semântica acquire ou release é usada.

Enquanto a função _InterlockedExchange opera em valores inteiros de 32 bits, _InterlockedExchange8 opera em valores inteiros de 8 bits, _InterlockedExchange16 opera em valores inteiros de 16 bits e _InterlockedExchange64 opera em valores inteiros de 64 bits.

Em plataformas ARM, use intrínsecos com os sufixos _acq e _rel para semântica de aquisição e liberação, como no início e no final de uma seção crítica. Os intrínsecos com um sufixo _nf ("no fence") não funcionam como uma barreira de memória.

Em plataformas Intel que suportam instruções HLE (Elisão de Bloqueio de Hardware), intrínsecos com os sufixos _HLEAcquire e _HLERelease incluem uma dica para o processador que pode acelerar o desempenho, eliminando uma etapa de gravação de bloqueio no hardware. Se esses intrínsecos forem chamados em plataformas que não dão suporte a HLE, a dica será ignorada.

Essas rotinas somente estão disponíveis como intrínsecos.

Exemplo

Para obter uma amostra de como usar _InterlockedExchange, consulte _InterlockedDecrement.

Fim da seção específica da Microsoft

Confira também

Compilador intrínsecos
Palavras-chave
conflitos com o compilador x86