Skip to content

Commit aae334d

Browse files
Taojunshencolin-homeopbld16opbld15opbld17
authored
8/4/2022 AM Publish (#4451)
* crtsetdbgflag.md: _CrtCheckMemory is not called by default * Confirm merge from FromPublicMasterBranch to main to sync with https://github.com/MicrosoftDocs/cpp-docs (branch main) (MicrosoftDocs#4430) * 7/19/2022 AM Publish (MicrosoftDocs#4424) * Follow up 4221 Acrolinx score for TN035 * Fix heading style Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> * 7/20/2022 AM Publish (MicrosoftDocs#4426) * Follow up 4221 Acrolinx score for TN035 * Fix heading style Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> * 7/21/2022 AM Publish (MicrosoftDocs#4427) * Follow up 4221 Acrolinx score for TN035 * Fix heading style * Update C++-specific template info * Fix links to raw and rendered markdown Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> * crtsetdbgflag.md: _CrtCheckMemory is not called by default Co-authored-by: JiayueHu <36248303+JiayueHu@users.noreply.github.com> Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Taojunshen <v-jutao@microsoft.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> Co-authored-by: opbld16 <opbld16@microsoft.com> Co-authored-by: opbld15 <opbld15@microsoft.com> Co-authored-by: opbld17 <opbld17@microsoft.com> Co-authored-by: Oliver Old <oliver.old@outlook.com> Co-authored-by: Tyler Whitney <TylerMSFT@users.noreply.github.com> * wordsmith * clarify wording * wording * Update .openpublishing.publish.config.json * Repo sync for protected CLA branch (MicrosoftDocs#4061) * add initial doc stubs * Initial docs push, contains stubs for some files and a stub for a landing page * update some links * add more cards and links to the Hub page * fix error * remove monikor's so it's easy to test, fix rtos-view.md path * fix link * add more to the sidebar * update peripheral view by consolidating to the table, change things to objects in rtos-view * add tabs * forgot to end tabbed section * fix items after adding tabs * update h1 * slightly fix some wording * add link from C++ and C workloads, features, and libraries to embedded hub * move into own directory so that the url is better * fix some warnings * remove next steps that pointed to linux items * prefer tabbed view vs table * attempt to add moniker * attempt highest moniker in range * assign to a specific version * push again to get new build * add '=' sign to try and test it * add metadata for msvc-170 * add moniker range for index.yml * remove inline moniker since we only need it on the files themselves * Follow up 4221 Acrolinx score for TN035 * Fix heading style * Update C++-specific template info * Fix links to raw and rendered markdown * Edit pass for house style * add 'while debugging' for peripheral-view * Fix table issue, stray punctuation Co-authored-by: Garrett Campbell <gcampbell@microsoft.com> Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> Co-authored-by: Alma Jenks <v-alje@microsoft.com> * Update ios-functions.md fix typo (MicrosoftDocs#4071) showps→showpos * Confirm merge from FromPublicMasterBranch to main to sync with https://github.com/MicrosoftDocs/cpp-docs (branch main) (#4442) * 7/27/2022 AM Publish (#4432) * Confirm merge from FromPublicMasterBranch to main to sync with https://github.com/MicrosoftDocs/cpp-docs (branch main) (MicrosoftDocs#4430) * 7/19/2022 AM Publish (MicrosoftDocs#4424) * Follow up 4221 Acrolinx score for TN035 * Fix heading style Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> * 7/20/2022 AM Publish (MicrosoftDocs#4426) * Follow up 4221 Acrolinx score for TN035 * Fix heading style Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> * 7/21/2022 AM Publish (MicrosoftDocs#4427) * Follow up 4221 Acrolinx score for TN035 * Fix heading style * Update C++-specific template info * Fix links to raw and rendered markdown Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> * crtsetdbgflag.md: _CrtCheckMemory is not called by default Co-authored-by: JiayueHu <36248303+JiayueHu@users.noreply.github.com> Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Taojunshen <v-jutao@microsoft.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> Co-authored-by: opbld16 <opbld16@microsoft.com> Co-authored-by: opbld15 <opbld15@microsoft.com> Co-authored-by: opbld17 <opbld17@microsoft.com> Co-authored-by: Oliver Old <oliver.old@outlook.com> Co-authored-by: Tyler Whitney <TylerMSFT@users.noreply.github.com> * wordsmith * clarify wording * wording Co-authored-by: Feng Xu <fenxu@microsoft.com> Co-authored-by: JiayueHu <36248303+JiayueHu@users.noreply.github.com> Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> Co-authored-by: opbld16 <opbld16@microsoft.com> Co-authored-by: opbld15 <opbld15@microsoft.com> Co-authored-by: opbld17 <opbld17@microsoft.com> Co-authored-by: Oliver Old <oliver.old@outlook.com> Co-authored-by: Tyler Whitney <TylerMSFT@users.noreply.github.com> Co-authored-by: TylerMSFT <Tyler.Whitney@microsoft.com> Co-authored-by: PRMerger20 <prmrgr20@microsoft.com> * 7/28/2022 AM Publish (#4437) * Confirm merge from FromPublicMasterBranch to main to sync with https://github.com/MicrosoftDocs/cpp-docs (branch main) (MicrosoftDocs#4430) * 7/19/2022 AM Publish (MicrosoftDocs#4424) * Follow up 4221 Acrolinx score for TN035 * Fix heading style Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> * 7/20/2022 AM Publish (MicrosoftDocs#4426) * Follow up 4221 Acrolinx score for TN035 * Fix heading style Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> * 7/21/2022 AM Publish (MicrosoftDocs#4427) * Follow up 4221 Acrolinx score for TN035 * Fix heading style * Update C++-specific template info * Fix links to raw and rendered markdown Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> * crtsetdbgflag.md: _CrtCheckMemory is not called by default Co-authored-by: JiayueHu <36248303+JiayueHu@users.noreply.github.com> Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Taojunshen <v-jutao@microsoft.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> Co-authored-by: opbld16 <opbld16@microsoft.com> Co-authored-by: opbld15 <opbld15@microsoft.com> Co-authored-by: opbld17 <opbld17@microsoft.com> Co-authored-by: Oliver Old <oliver.old@outlook.com> Co-authored-by: Tyler Whitney <TylerMSFT@users.noreply.github.com> * wordsmith * clarify wording * wording Co-authored-by: Feng Xu <fenxu@microsoft.com> Co-authored-by: JiayueHu <36248303+JiayueHu@users.noreply.github.com> Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> Co-authored-by: opbld16 <opbld16@microsoft.com> Co-authored-by: opbld15 <opbld15@microsoft.com> Co-authored-by: opbld17 <opbld17@microsoft.com> Co-authored-by: Oliver Old <oliver.old@outlook.com> Co-authored-by: Tyler Whitney <TylerMSFT@users.noreply.github.com> Co-authored-by: TylerMSFT <Tyler.Whitney@microsoft.com> Co-authored-by: PRMerger20 <prmrgr20@microsoft.com> * 7/29/2022 AM Publish (MicrosoftDocs#4441) * Confirm merge from FromPublicMasterBranch to main to sync with https://github.com/MicrosoftDocs/cpp-docs (branch main) (MicrosoftDocs#4430) * 7/19/2022 AM Publish (MicrosoftDocs#4424) * Follow up 4221 Acrolinx score for TN035 * Fix heading style Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> * 7/20/2022 AM Publish (MicrosoftDocs#4426) * Follow up 4221 Acrolinx score for TN035 * Fix heading style Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> * 7/21/2022 AM Publish (MicrosoftDocs#4427) * Follow up 4221 Acrolinx score for TN035 * Fix heading style * Update C++-specific template info * Fix links to raw and rendered markdown Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> * crtsetdbgflag.md: _CrtCheckMemory is not called by default Co-authored-by: JiayueHu <36248303+JiayueHu@users.noreply.github.com> Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Taojunshen <v-jutao@microsoft.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> Co-authored-by: opbld16 <opbld16@microsoft.com> Co-authored-by: opbld15 <opbld15@microsoft.com> Co-authored-by: opbld17 <opbld17@microsoft.com> Co-authored-by: Oliver Old <oliver.old@outlook.com> Co-authored-by: Tyler Whitney <TylerMSFT@users.noreply.github.com> * wordsmith * clarify wording * wording Co-authored-by: Feng Xu <fenxu@microsoft.com> Co-authored-by: JiayueHu <36248303+JiayueHu@users.noreply.github.com> Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> Co-authored-by: opbld16 <opbld16@microsoft.com> Co-authored-by: opbld15 <opbld15@microsoft.com> Co-authored-by: opbld17 <opbld17@microsoft.com> Co-authored-by: Oliver Old <oliver.old@outlook.com> Co-authored-by: Tyler Whitney <TylerMSFT@users.noreply.github.com> Co-authored-by: TylerMSFT <Tyler.Whitney@microsoft.com> Co-authored-by: PRMerger20 <prmrgr20@microsoft.com> Co-authored-by: Alma Jenks <v-alje@microsoft.com> Co-authored-by: Taojunshen <v-jutao@microsoft.com> Co-authored-by: JiayueHu <36248303+JiayueHu@users.noreply.github.com> Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> Co-authored-by: opbld16 <opbld16@microsoft.com> Co-authored-by: opbld15 <opbld15@microsoft.com> Co-authored-by: opbld17 <opbld17@microsoft.com> Co-authored-by: Oliver Old <oliver.old@outlook.com> Co-authored-by: Tyler Whitney <TylerMSFT@users.noreply.github.com> Co-authored-by: TylerMSFT <Tyler.Whitney@microsoft.com> Co-authored-by: PRMerger20 <prmrgr20@microsoft.com> * Address cpp-docs 4075 __assume issues * Address cpp-docs 4072 clarity issue * update date Co-authored-by: Colin Robertson <3836425+corob-msft@users.noreply.github.com> Co-authored-by: opbld16 <opbld16@microsoft.com> Co-authored-by: opbld15 <opbld15@microsoft.com> Co-authored-by: opbld17 <opbld17@microsoft.com> Co-authored-by: Oliver Old <oliver.old@outlook.com> Co-authored-by: Tyler Whitney <TylerMSFT@users.noreply.github.com> Co-authored-by: Feng Xu <fenxu@microsoft.com> Co-authored-by: JiayueHu <36248303+JiayueHu@users.noreply.github.com> Co-authored-by: Bryan Gold <101299717+19BMG00@users.noreply.github.com> Co-authored-by: TylerMSFT <Tyler.Whitney@microsoft.com> Co-authored-by: PRMerger20 <prmrgr20@microsoft.com> Co-authored-by: irushx <39490127+irushx@users.noreply.github.com> Co-authored-by: Garrett Campbell <gcampbell@microsoft.com> Co-authored-by: Alma Jenks <v-alje@microsoft.com> Co-authored-by: pea-sys <49807271+pea-sys@users.noreply.github.com> Co-authored-by: PRMerger7 <prmrgr7@microsoft.com>
1 parent 4666b63 commit aae334d

File tree

2 files changed

+55
-60
lines changed

2 files changed

+55
-60
lines changed

docs/intrinsics/assume.md

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
description: "Learn more about: __assume"
33
title: "__assume"
4-
ms.date: "09/02/2019"
4+
ms.date: 08/03/2022
55
f1_keywords: ["__assume", "_assume", "__assume_cpp"]
66
helpviewer_keywords: ["__assume keyword [C++]"]
77
ms.assetid: d8565123-b132-44b1-8235-5a8c8bff85a7
88
---
9-
# __assume
9+
# `__assume`
1010

1111
**Microsoft Specific**
1212

@@ -22,85 +22,80 @@ __assume(
2222

2323
### Parameters
2424

25-
*expression*\
26-
Any expression that is assumed to evaluate to true.
25+
*`expression`*\
26+
For reachable code, any expression that is assumed to evaluate to **`true`**. Use `0` to indicate unreachable code to the optimizer.
2727

2828
## Remarks
2929

30-
The optimizer assumes that the condition represented by `expression` is true at the point where the keyword appears and remains true until `expression` is modified (for example, by assignment to a variable). Selective use of hints passed to the optimizer by **`__assume`** can improve optimization.
30+
The optimizer assumes that the condition represented by `expression` is **`true`** at the point where the keyword appears and remains true until `expression` is modified (for example, by assignment to a variable). Selective use of hints passed to the optimizer by **`__assume`** can improve optimization.
3131

32-
If the **`__assume`** statement is written as a contradiction (an expression that always evaluates to false), it is always treated as `__assume(0)`. If your code isnt behaving as expected, ensure that the `expression` you defined is valid and true, as described earlier. For more information about expected `__assume(0)` behavior, see the later remarks.
32+
If the **`__assume`** statement is written as a contradiction (an expression that always evaluates to **`false`**), it's always treated as `__assume(0)`. If your code isn't behaving as expected, ensure that the `expression` you defined is valid and **`true`**, as described earlier. The `__assume(0)` statement is a special case. Use `__assume(0)` to indicate a code path that can't be reached.
3333

3434
> [!WARNING]
3535
> A program must not contain an invalid **`__assume`** statement on a reachable path. If the compiler can reach an invalid **`__assume`** statement, the program might cause unpredictable and potentially dangerous behavior.
3636
37-
`__assume` is not a genuine intrinsic. It does not have to be declared as a function and it cannot be used in a `#pragma intrinsic` directive. Although no code is generated, the code generated by the optimizer is affected.
37+
For compatibility with previous versions, **`_assume`** is a synonym for **`__assume`** unless compiler option [`/Za` (Disable language extensions)](../build/reference/za-ze-disable-language-extensions.md) is specified.
3838

39-
Use **`__assume`** in an [ASSERT](../c-runtime-library/reference/assert-asserte-assert-expr-macros.md) only when the assert is not recoverable. Do not use **`__assume`** in an assert for which you have subsequent error recovery code because the compiler might optimize away the error-handling code.
39+
`__assume` isn't a genuine intrinsic. It doesn't have to be declared as a function and it can't be used in a `#pragma intrinsic` directive. Although no code is generated, the code generated by the optimizer is affected.
4040

41-
The `__assume(0)` statement is a special case. Use `__assume(0)` to indicate a code path that cannot be reached. The following example shows how to use `__assume(0)` to indicate that the default case of a switch statement cannot be reached. This shows the most typical use of `__assume(0)`.
42-
43-
For compatibility with previous versions, **`_assume`** is a synonym for **`__assume`** unless compiler option [/Za \(Disable language extensions)](../build/reference/za-ze-disable-language-extensions.md) is specified.
41+
Use **`__assume`** in an [`ASSERT`](../c-runtime-library/reference/assert-asserte-assert-expr-macros.md) only when the assertion isn't recoverable. Don't use **`__assume`** in an assertion for which you have subsequent error recovery code because the compiler might optimize away the error-handling code.
4442

4543
## Requirements
4644

47-
|Intrinsic|Architecture|
48-
|---------------|------------------|
49-
|**`__assume`**|x86, ARM, x64, ARM64|
45+
| Intrinsic | Architecture |
46+
|--|--|
47+
| **`__assume`** | x86, ARM, x64, ARM64, ARM64EC |
5048

5149
## Example
5250

51+
The following example shows how to use `__assume(0)` to indicate that the **`default`** case of a **`switch`** statement can't be reached. It's the most typical use of `__assume(0)`. Here, the programmer knows that the only possible inputs for `p` will be 1 or 2. If another value is passed in for `p`, the program becomes invalid and causes unpredictable behavior.
52+
5353
```cpp
5454
// compiler_intrinsics__assume.cpp
55-
#ifdef DEBUG
56-
# define ASSERT(e) ( ((e) || assert(__FILE__, __LINE__) )
57-
#else
58-
# define ASSERT(e) ( __assume(e) )
59-
#endif
6055

61-
void func1(int i)
56+
void func1(int /*ignored*/)
6257
{
6358
}
6459

6560
int main(int p)
6661
{
67-
switch(p){
68-
case 1:
69-
func1(1);
70-
break;
71-
case 2:
72-
func1(-1);
73-
break;
74-
default:
75-
__assume(0);
76-
// This tells the optimizer that the default
77-
// cannot be reached. As so, it does not have to generate
78-
// the extra code to check that 'p' has a value
79-
// not represented by a case arm. This makes the switch
80-
// run faster.
62+
switch(p)
63+
{
64+
case 1:
65+
func1(1);
66+
break;
67+
case 2:
68+
func1(-1);
69+
break;
70+
default:
71+
__assume(0);
72+
// This tells the optimizer that the default
73+
// cannot be reached. As so, it does not have to generate
74+
// the extra code to check that 'p' has a value
75+
// not represented by a case arm. This makes the switch
76+
// run faster.
8177
}
8278
}
8379
```
8480
85-
The use of `__assume(0)` tells the optimizer that the default case cannot be reached. The example demonstrates that the programmer knows that the only possible inputs for `p` will be 1 or 2. If another value is passed in for `p`, the program becomes invalid and causes unpredictable behavior.
81+
As a result of the `__assume(0)` statement, the compiler doesn't generate code to test whether `p` has a value that isn't represented in a case statement.
8682
87-
As a result of the `__assume(0)` statement, the compiler does not generate code to test whether `p` has a value that is not represented in a case statement. For this to work, the `__assume(0)` statement must be the first statement in the body of the default case.
88-
89-
Because the compiler generates code based on **`__assume`**, that code might not run correctly if the expression inside the **`__assume`** statement is false at run time. If you are not sure that the expression will always be true at run time, you can use the `assert` function to protect the code.
83+
If you aren't sure that the expression will always be **`true`** at runtime, you can use the `assert` function to protect the code. This macro definition wraps the **`__assume`** statement with a check:
9084
9185
```C
92-
#define ASSERT(e) ( ((e) || assert(__FILE__, __LINE__)), __assume(e) )
86+
#define ASSUME(e) (((e) || (assert(e), (e))), __assume(e))
9387
```
9488

95-
Unfortunately, this use of `assert` prevents the compiler from performing the default-case optimization that was described earlier in this document. As an alternative, you can use a separate macro, as follows.
89+
For the **`default`** case optimization to work, the `__assume(0)` statement must be the first statement in the body of the **`default`** case. Unfortunately, the `assert` in the `ASSUME` macro prevents the compiler from performing this optimization. As an alternative, you can use a separate macro, as shown here:
9690

9791
```C
9892
#ifdef DEBUG
99-
# define NODEFAULT ASSERT(0)
93+
// This code is supposed to be unreachable, so assert
94+
# define NODEFAULT assert(0)
10095
#else
10196
# define NODEFAULT __assume(0)
10297
#endif
103-
98+
// . . .
10499
default:
105100
NODEFAULT;
106101
```

docs/intrinsics/interlockedcompareexchange-intrinsic-functions.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
description: "Learn more about: _InterlockedCompareExchange intrinsic functions"
33
title: "_InterlockedCompareExchange intrinsic functions"
4-
ms.date: 10/27/2021
4+
ms.date: 08/03/2022
55
f1_keywords: ["_InterlockedCompareExchange", "_InterlockedCompareExchange_acq", "_InterlockedCompareExchange_acq_cpp", "_InterlockedCompareExchange_cpp", "_InterlockedCompareExchange_HLEAcquire", "_InterlockedCompareExchange_HLERelease", "_InterlockedCompareExchange_nf", "_InterlockedCompareExchange_np", "_InterlockedCompareExchange_rel", "_InterlockedCompareExchange_rel_cpp", "_InterlockedCompareExchange8", "_InterlockedCompareExchange8_acq", "_InterlockedCompareExchange8_nf", "_InterlockedCompareExchange8_rel", "_InterlockedCompareExchange16", "_InterlockedCompareExchange16_acq", "_InterlockedCompareExchange16_acq_cpp", "_InterlockedCompareExchange16_cpp", "_InterlockedCompareExchange16_nf", "_InterlockedCompareExchange16_rel", "_InterlockedCompareExchange16_rel_cpp", "_InterlockedCompareExchange64", "_InterlockedCompareExchange64_acq", "_InterlockedCompareExchange64_acq_cpp", "_InterlockedCompareExchange64_cpp", "_InterlockedCompareExchange64_HLEAcquire", "_InterlockedCompareExchange64_HLERelease", "_InterlockedCompareExchange64_nf", "_InterlockedCompareExchange64_np", "_InterlockedCompareExchange64_rel", "_InterlockedCompareExchange64_rel_cpp"]
66
helpviewer_keywords: ["_InterlockedCompareExchange intrinsic", "_InterlockedCompareExchange_acq intrinsic", "_InterlockedCompareExchange_acq_cpp intrinsic", "_InterlockedCompareExchange_cpp intrinsic", "_InterlockedCompareExchange_HLEAcquire intrinsic", "_InterlockedCompareExchange_HLERelease intrinsic", "_InterlockedCompareExchange_nf intrinsic", "_InterlockedCompareExchange_np intrinsic", "_InterlockedCompareExchange_rel intrinsic", "_InterlockedCompareExchange_rel_cpp intrinsic", "_InterlockedCompareExchange8 intrinsic", "_InterlockedCompareExchange8_acq intrinsic", "_InterlockedCompareExchange8_nf intrinsic", "_InterlockedCompareExchange8_rel intrinsic", "_InterlockedCompareExchange16 intrinsic", "_InterlockedCompareExchange16_acq intrinsic", "_InterlockedCompareExchange16_acq_cpp intrinsic", "_InterlockedCompareExchange16_cpp intrinsic", "_InterlockedCompareExchange16_nf intrinsic", "_InterlockedCompareExchange16_rel intrinsic", "_InterlockedCompareExchange16_rel_cpp intrinsic", "_InterlockedCompareExchange64 intrinsic", "_InterlockedCompareExchange64_acq intrinsic", "_InterlockedCompareExchange64_acq_cpp intrinsic", "_InterlockedCompareExchange64_cpp intrinsic", "_InterlockedCompareExchange64_HLEAcquire intrinsic", "_InterlockedCompareExchange64_HLERelease intrinsic", "_InterlockedCompareExchange64_nf intrinsic", "_InterlockedCompareExchange64_np intrinsic", "_InterlockedCompareExchange64_rel intrinsic", "_InterlockedCompareExchange64_rel_cpp intrinsic"]
77
ms.assetid: c3ad79c0-a523-4930-a3a4-69a65d7d5c81
88
---
9-
# _InterlockedCompareExchange intrinsic functions
9+
# `_InterlockedCompareExchange` intrinsic functions
1010

1111
**Microsoft Specific**
1212

@@ -134,37 +134,37 @@ __int64 _InterlockedCompareExchange64_rel(
134134

135135
### Parameters
136136

137-
*Destination*\
137+
*`Destination`*\
138138
[in, out] Pointer to the destination value. The sign is ignored.
139139

140-
*Exchange*\
140+
*`Exchange`*\
141141
[in] Exchange value. The sign is ignored.
142142

143-
*Comparand*\
144-
[in] Value to compare to destination. The sign is ignored.
143+
*`Comparand`*\
144+
[in] Value to compare to the value pointed at by *`Destination`*. The sign is ignored.
145145

146146
## Return value
147147

148-
The return value is the initial value of the `Destination` pointer.
148+
The return value is the initial value pointed at by the `Destination` pointer.
149149

150150
## Requirements
151151

152-
|Intrinsic|Architecture|Header|
153-
|---------------|------------------|------------|
154-
|`_InterlockedCompareExchange`, `_InterlockedCompareExchange8`, `_InterlockedCompareExchange16`, `_InterlockedCompareExchange64`|x86, ARM, x64, ARM64|\<intrin.h>|
155-
|`_InterlockedCompareExchange_acq`, `_InterlockedCompareExchange_nf`, `_InterlockedCompareExchange_rel`, `_InterlockedCompareExchange8_acq`, `_InterlockedCompareExchange8_nf`, `_InterlockedCompareExchange8_rel`,`_InterlockedCompareExchange16_acq`, `_InterlockedCompareExchange16_nf`, `_InterlockedCompareExchange16_rel`, `_InterlockedCompareExchange64_acq`, `_InterlockedCompareExchange64_nf`, `_InterlockedCompareExchange64_rel`,|ARM, ARM64|\<intrin.h>|
156-
|`_InterlockedCompareExchange_np`, `_InterlockedCompareExchange16_np`, `_InterlockedCompareExchange64_np`|x64|\<intrin.h>|
157-
|`_InterlockedCompareExchange_HLEAcquire`, `_InterlockedCompareExchange_HLERelease`, `_InterlockedCompareExchange64_HLEAcquire`, `_InterlockedCompareExchange64_HLERelease`|x86, x64|\<immintrin.h>|
152+
| Intrinsic | Architecture | Header |
153+
|--|--|--|
154+
| `_InterlockedCompareExchange`, `_InterlockedCompareExchange8`, `_InterlockedCompareExchange16`, `_InterlockedCompareExchange64` | x86, ARM, x64, ARM64 | \<intrin.h> |
155+
| `_InterlockedCompareExchange_acq`, `_InterlockedCompareExchange_nf`, `_InterlockedCompareExchange_rel`, `_InterlockedCompareExchange8_acq`, `_InterlockedCompareExchange8_nf`, `_InterlockedCompareExchange8_rel`,`_InterlockedCompareExchange16_acq`, `_InterlockedCompareExchange16_nf`, `_InterlockedCompareExchange16_rel`, `_InterlockedCompareExchange64_acq`, `_InterlockedCompareExchange64_nf`, `_InterlockedCompareExchange64_rel`, | ARM, ARM64 | \<intrin.h> |
156+
| `_InterlockedCompareExchange_np`, `_InterlockedCompareExchange16_np`, `_InterlockedCompareExchange64_np` | x64 | \<intrin.h> |
157+
| `_InterlockedCompareExchange_HLEAcquire`, `_InterlockedCompareExchange_HLERelease`, `_InterlockedCompareExchange64_HLEAcquire`, `_InterlockedCompareExchange64_HLERelease` | x86, x64 | \<immintrin.h> |
158158

159159
## Remarks
160160

161-
`_InterlockedCompareExchange` does an atomic comparison of the `Destination` value with the `Comparand` value. If the `Destination` value is equal to the `Comparand` value, the `Exchange` value is stored in the address specified by `Destination`. Otherwise, does no operation.
161+
`_InterlockedCompareExchange` does an atomic comparison of the value pointed at by `Destination` with the `Comparand` value. If the `Destination` value is equal to the `Comparand` value, the `Exchange` value is stored in the address specified by `Destination`. Otherwise, does no operation.
162162

163-
`_InterlockedCompareExchange` provides compiler intrinsic support for the Win32 Windows SDK [InterlockedCompareExchange](/windows/win32/api/winnt/nf-winnt-interlockedcompareexchange) function.
163+
`_InterlockedCompareExchange` provides compiler intrinsic support for the Win32 Windows SDK [`InterlockedCompareExchange`](/windows/win32/api/winnt/nf-winnt-interlockedcompareexchange) function.
164164

165165
There are several variations on `_InterlockedCompareExchange` that vary based on the data types they involve and whether processor-specific acquire or release semantics are used.
166166

167-
While the `_InterlockedCompareExchange` function operates on long integer values, `_InterlockedCompareExchange8` operates on 8-bit integer values, `_InterlockedCompareExchange16` operates on short integer values, and `_InterlockedCompareExchange64` operates on 64-bit integer values.
167+
While the `_InterlockedCompareExchange` function operates on 32-bit **`long`** integer values, `_InterlockedCompareExchange8` operates on 8-bit integer values, `_InterlockedCompareExchange16` operates on 16-bit **`short`** integer values, and `_InterlockedCompareExchange64` operates on 64-bit integer values. For more information on similar intrinsics for 128-bit values, see [`_InterlockedCompareExchange128`](./interlockedcompareexchange128.md).
168168

169169
On all ARM platforms, use the intrinsics with `_acq` and `_rel` suffixes for acquire and release semantics, such as at the beginning and end of a critical section. The ARM intrinsics with an `_nf` ("no fence") suffix don't act as a memory barrier.
170170

@@ -390,8 +390,8 @@ int main(
390390

391391
## See also
392392

393-
[_InterlockedCompareExchange128](../intrinsics/interlockedcompareexchange128.md)\
394-
[_InterlockedCompareExchangePointer intrinsic functions](../intrinsics/interlockedcompareexchangepointer-intrinsic-functions.md)\
393+
[`_InterlockedCompareExchange128`](../intrinsics/interlockedcompareexchange128.md)\
394+
[`_InterlockedCompareExchangePointer` intrinsic functions](../intrinsics/interlockedcompareexchangepointer-intrinsic-functions.md)\
395395
[Compiler intrinsics](../intrinsics/compiler-intrinsics.md)\
396396
[Keywords](../cpp/keywords-cpp.md)\
397397
[Conflicts with the x86 Compiler](../build/x64-software-conventions.md#conflicts-with-the-x86-compiler)

0 commit comments

Comments
 (0)