다음을 통해 공유


내장 함수 _InterlockedAnd

Microsoft 전용

여러 스레드가 공유하는 변수에 대해 원자성 비트 AND 작업을 수행하는 데 사용됩니다.

구문

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

매개 변수

value
[in, out] 결과로 바꿀 첫 번째 피연산자를 가리키는 포인터입니다.

마스크
[in] 두 번째 피연산자입니다.

반환 값

첫 번째 피연산자의 원래 값입니다.

요구 사항

Intrinsic 아키텍처 헤더
_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>

설명

각 함수 이름의 숫자는 인수의 비트 크기를 지정합니다.

ARM 및 ARM64 플랫폼에서는 중요한 섹션의 시작 및 끝 부분과 _rel 같은 의미 체계를 획득하고 해제하기 위해 내장 함수 _acq 와 접미사를 사용합니다. _nf("no fence"의 약어) 접미사가 포함된 내장 함수는 메모리 장벽으로 작동하지 않습니다.

_np("no prefetch"의 약어) 접미사가 포함된 내장 함수는 컴파일러가 가능한 프리페치 연산을 삽입하지 못하도록 차단합니다.

HLE(Hardware Lock Elision) 명령을 지원하는 Intel 플랫폼에서 _HLEAcquire_HLERelease 접미사가 포함된 내장 함수는 하드웨어에서 잠금 쓰기 단계를 제거하여 성능을 향상시킬 수 있는 힌트를 프로세서에 포함합니다. HLE를 지원하지 않는 플랫폼에서 이러한 내장 함수를 호출하면 힌트는 무시됩니다.

예시

// 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

Microsoft 전용 종료

참고 항목

컴파일러 내장 함수
x86 컴파일러와 충돌