Funciones intrínsecas _InterlockedExchange

Específicos de Microsoft

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

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

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

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

Valor devuelto

Devuelve el valor inicial al que apunta Target.

Requisitos

Función intrínseca

Arquitectura

Header

_InterlockedExchange, _InterlockedExchange8, _InterlockedExchange16, _InterlockedExchange64

x86, ARM, x64

<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

<intrin.h>

_InterlockedExchange_HLEAcquire, _InterlockedExchange_HLERelease, _InterlockedExchange64_HLEAcquire, _InterlockedExchange64_HLERelease

x86, x64

<immintrin.h>

Comentarios

_InterlockedExchange proporciona compatibilidad intrínseca con el compilador para la función Windows SDK InterlockedExchange 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 límite") 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 ver un ejemplo de cómo usar _InterlockedExchange, consulte _InterlockedDecrement.

Vea también

Referencia

Intrínsecos del controlador

Palabras clave de C++

Conflictos con el compilador de x86