Funciones intrínsecas _InterlockedExchange

Específicos de Microsoft

Genera una instrucción atómica para establecer un valor especificado.

Sintaxis

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

Destino
[in, out] Puntero al valor que se va a intercambiar. La función establece esta variable en Value y devuelve su valor anterior.

Valor
[in] Valor que se va a intercambiar con el valor al que apunta Target.

Valor devuelto

Devuelve el valor inicial al que apunta Target.

Requisitos

Intrinsic Architecture Encabezado
_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>

Comentarios

_InterlockedExchange proporciona compatibilidad con intrínsecos del compilador para la función InterlockedExchange de Windows SDK de Win32.

Hay diversas variaciones en _InterlockedExchange que varían en función de los tipos de datos que implican y de si se utiliza la liberación o la adquisición de semántica específica del procesador.

Mientras que la función _InterlockedExchange opera con valores enteros de 32 bits, _InterlockedExchange8 opera con valores enteros de 8 bits, _InterlockedExchange16 opera con valores enteros de 16 bits y _InterlockedExchange64 opera con valores enteros de 64 bits.

En plataformas ARM, utilice los intrínsecos con sufijos _acq y _rel para adquirir y liberar semántica, como al principio y al final de una sección crítica. Los intrínsecos con un sufijo _nf ("sin barrera") no actúan como una barrera de memoria.

En las plataformas de Intel que admiten instrucciones de Elisión de bloqueo de Hardware (HLE), los intrínsecos con sufijos _HLEAcquire y _HLERelease incluyen una sugerencia para el procesador que puede acelerar el rendimiento mediante la eliminación de un paso de escritura de bloqueo en el hardware. Si se llama a estos intrínsecos en plataformas que no son compatibles con HLE, se omite la sugerencia.

Estas rutinas solo están disponibles como intrínsecos.

Ejemplo

Para un ejemplo de cómo usar _InterlockedExchange, consulte _InterlockedDecrement.

FIN de Específicos de Microsoft

Consulte también

Intrínsecos del compilador
Palabras clave
Conflictos con el compilador de x86