funkcje wewnętrzne _InterlockedAnd
Specyficzne dla firmy Microsoft
Służy do wykonywania niepodzielnej operacji bitowej AND na zmiennej współużytkowanej przez wiele wątków.
Składnia
long _InterlockedAnd(
long volatile * value,
long mask
);
long _InterlockedAnd_acq(
long volatile * value,
long mask
);
long _InterlockedAnd_HLEAcquire(
long volatile * value,
long mask
);
long _InterlockedAnd_HLERelease(
long volatile * value,
long mask
);
long _InterlockedAnd_nf(
long volatile * value,
long mask
);
long _InterlockedAnd_np(
long volatile * value,
long mask
);
long _InterlockedAnd_rel(
long volatile * value,
long mask
);
char _InterlockedAnd8(
char volatile * value,
char mask
);
char _InterlockedAnd8_acq(
char volatile * value,
char mask
);
char _InterlockedAnd8_nf(
char volatile * value,
char mask
);
char _InterlockedAnd8_np(
char volatile * value,
char mask
);
char _InterlockedAnd8_rel(
char volatile * value,
char mask
);
short _InterlockedAnd16(
short volatile * value,
short mask
);
short _InterlockedAnd16_acq(
short volatile * value,
short mask
);
short _InterlockedAnd16_nf(
short volatile * value,
short mask
);
short _InterlockedAnd16_np(
short volatile * value,
short mask
);
short _InterlockedAnd16_rel(
short volatile * value,
short mask
);
__int64 _InterlockedAnd64(
__int64 volatile* value,
__int64 mask
);
__int64 _InterlockedAnd64_acq(
__int64 volatile* value,
__int64 mask
);
__int64 _InterlockedAnd64_HLEAcquire(
__int64 volatile* value,
__int64 mask
);
__int64 _InterlockedAnd64_HLERelease(
__int64 volatile* value,
__int64 mask
);
__int64 _InterlockedAnd64_nf(
__int64 volatile* value,
__int64 mask
);
__int64 _InterlockedAnd64_np(
__int64 volatile* value,
__int64 mask
);
__int64 _InterlockedAnd64_rel(
__int64 volatile* value,
__int64 mask
);
Parametry
wartość
[in, out] Wskaźnik do pierwszego operandu, który ma zostać zastąpiony przez wynik.
Maska
[in] Drugi operand.
Wartość zwracana
Oryginalna wartość pierwszego operandu.
Wymagania
Wewnętrzne | Architektura | Nagłówek |
---|---|---|
_InterlockedAnd , _InterlockedAnd8 , _InterlockedAnd16 |
x86, ARM, x64, ARM64 | <intrin.h> |
_InterlockedAnd64 |
ARM, x64, ARM64 | <intrin.h> |
_InterlockedAnd_acq , _InterlockedAnd_nf , _InterlockedAnd_rel , _InterlockedAnd8_acq , _InterlockedAnd8_nf , _InterlockedAnd8_rel , _InterlockedAnd16_acq , _InterlockedAnd16_nf , _InterlockedAnd16_rel , _InterlockedAnd64_acq , _InterlockedAnd64_nf , _InterlockedAnd64_rel |
ARM, ARM64 | <intrin.h> |
_InterlockedAnd_np , _InterlockedAnd8_np , _InterlockedAnd16_np , _InterlockedAnd64_np |
x64 | <intrin.h> |
_InterlockedAnd_HLEAcquire , _InterlockedAnd_HLERelease , _InterlockedAnd64_HLEAcquire , _InterlockedAnd64_HLERelease |
x86, x64 | <immintrin.h> |
Uwagi
Liczba w nazwie każdej funkcji określa rozmiar bitów argumentów.
Na platformach ARM i ARM64 użyj funkcji wewnętrznych z sufiksami _acq
i _rel
do uzyskiwania i semantyki wydań, 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.
Funkcje wewnętrzne z sufiksem _np
("brak pobierania wstępnego") uniemożliwiają wstawienie możliwej operacji pobierania wstępnego przez kompilator.
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.
Przykład
// InterlockedAnd.cpp
// Compile with: /Oi
#include <stdio.h>
#include <intrin.h>
#pragma intrinsic(_InterlockedAnd)
int main()
{
long data1 = 0xFF00FF00;
long data2 = 0x00FFFF00;
long retval;
retval = _InterlockedAnd(&data1, data2);
printf_s("0x%x 0x%x 0x%x", data1, data2, retval);
}
0xff00 0xffff00 0xff00ff00
END Microsoft Specific
Zobacz też
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla