分享方式:


_InterlockedExchange內部函數

Microsoft 特定的

會產生不可部分完成的指示,以設定指定的值。

語法

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

參數

Target
[in, out]要交換之值的指標。 函式會將此變數設定為 Value,並傳回其先前的值。

ReplTest1
[in]要與 所 Target指向的值交換的值。

傳回值

傳回 Target 所指的初始值。

需求

內建 架構 頁首
_InterlockedExchange、 、 _InterlockedExchange8_InterlockedExchange16 x86、ARM、x64、ARM64 <intrin.h>
_InterlockedExchange64 ARM、x64、ARM64 <intrin.h>
_InterlockedExchange_acq_InterlockedExchange_nf_InterlockedExchange_rel_InterlockedExchange8_acq、、_InterlockedExchange8_rel_InterlockedExchange16_nf_InterlockedExchange64_acq_InterlockedExchange16_acq_InterlockedExchange16_rel_InterlockedExchange8_nf、、 _InterlockedExchange64_nf_InterlockedExchange64_rel ARM、ARM64 <intrin.h>
_InterlockedExchange_HLEAcquire, _InterlockedExchange_HLERelease x86、x64 <immintrin.h>
_InterlockedExchange64_HLEAcquire, _InterlockedExchange64_HLERelease x64 <immintrin.h>

備註

_InterlockedExchange 提供 Win32 Windows SDK InterlockedExchange 函式的編譯程式內建支援。

_InterlockedExchange 上有數個變化,會因所涉及的資料類型,以及是否使用處理器專用的取得或釋放語意,而有所不同。

_InterlockedExchange 函式在 32 位元整數值上運算;_InterlockedExchange8 在 8 位元整數值上運算;_InterlockedExchange16 在 16 位元整數值上運算;_InterlockedExchange64 在 64 位元整數值上運算。

在 ARM 平台上,搭配取得和釋放語意的 _acq_rel 字尾使用內建函式,例如在重要區段的開頭和結尾處。 具有 _nf (“無柵欄”) 後綴的內部函數不會作為記憶體屏障。

在支援 Hardware Lock Elision (HLE) 指令的 Intel 平台上,搭配 _HLEAcquire_HLERelease 字尾的內建函式會包含對處理器的提示,提示其可以藉由消除硬體中鎖定寫入 (lock write) 的階段以加速效能。 如果在不支援 HLE 的平台上呼叫這些內建函式,會忽略該提示。

這些常式僅以內建函式的形式供您使用。

範例

如需如何使用 _InterlockedExchange的範例,請參閱 _InterlockedDecrement

END Microsoft 特定的

另請參閱

編譯程式內部函數
關鍵字
與 x86 編譯器衝突