Udostępnij za pośrednictwem


funkcje wewnętrzne _InterlockedExchange

Specyficzne dla firmy Microsoft

Generuje instrukcję niepodzieną, aby ustawić określoną wartość.

Składnia

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

Parametry

Obiekt docelowy
[in, out] Wskaźnik do wartości do wymiany. Funkcja ustawia tę zmienną na Value i zwraca jej poprzednią wartość.

Wartość
[in] Wartość do wymiany z wartością wskazywaną przez Target.

Wartość zwracana

Zwraca początkową wartość wskazywaną przez Targetwartość .

Wymagania

Wewnętrzne Architektura Nagłówek
_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>

Uwagi

_InterlockedExchangeZapewnia wewnętrzną obsługę kompilatora dla funkcji InterlockedExchange zestawu Windows SDK systemu Windows Win32.

Istnieje kilka odmian, _InterlockedExchange które różnią się w zależności od typów danych, które obejmują, i czy jest używana semantyka pozyskiwania lub wydawania specyficzne dla procesora.

_InterlockedExchange Chociaż funkcja działa na 32-bitowych wartościach całkowitych, _InterlockedExchange8 działa na 8-bitowych wartościach całkowitych, _InterlockedExchange16 działa na 16-bitowych wartościach całkowitych i _InterlockedExchange64 działa na 64-bitowych wartościach całkowitych.

Na platformach ARM użyj funkcji wewnętrznych z sufiksami _acq i _rel do uzyskiwania i semantyki wydania, takich jak na początku i na końcu sekcji krytycznej. Funkcje wewnętrzne z sufiksem _nf ("bez ogrodzenia") nie działają jako bariera pamięci.

Na platformach Intel, które obsługują instrukcje dotyczące blokady sprzętu Elision (HLE), funkcje wewnętrzne z sufiksami _HLEAcquire zawierają _HLERelease wskazówkę dla procesora, który może przyspieszyć wydajność, eliminując krok zapisu blokady w sprzęcie. Jeśli te funkcje wewnętrzne są wywoływane na platformach, które nie obsługują HLE, wskazówka jest ignorowana.

Te procedury są dostępne tylko jako funkcje wewnętrzne.

Przykład

Aby zapoznać się z przykładem korzystania z usługi _InterlockedExchange, zobacz _InterlockedDecrement.

END Microsoft Specific

Zobacz też

Funkcje wewnętrzne kompilatora
Słowa kluczowe
Konflikty z kompilatorem x86