Skip to content

Commit f8c2a51

Browse files
committed
latest draft
1 parent e23361a commit f8c2a51

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

docs/build/arm64-windows-abi-conventions.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,9 @@ Like AArch32, the AArch64 specification provides three system-controlled "thread
118118

119119
## Floating-point exceptions
120120

121-
Most ARM hardware doesn't support IEEE floating-point exceptions. You can determine if an ARM CPU supports them by writing a value that enables exceptions to the FPCR register and then reading it back. If the CPU supports floating-point exceptions, the bits corresponding to supported exceptions remain set, while the bits corresponding to unsupported exceptions are reset by the CPU.
121+
You can determine if an ARM CPU supports exceptions by writing a value that enables exceptions to the FPCR register and then reading it back. If the CPU supports floating-point exceptions, the bits corresponding to the supported exceptions remain set, while the bits corresponding to unsupported exceptions are reset by the CPU.
122122

123-
For ARM CPUs that do support IEEE floating-point exceptions, the behavior on Windows is as follows:
124-
125-
- **Windows ARM ABI**: The Windows kernel silently catches these exceptions and implicitly disables them in the FPSCR register. This approach ensures normalized behavior across processor variants, preventing unexpected exceptions when code developed on a platform without exception support runs on a platform with support.
123+
For ARM CPUs that support IEEE floating-point exceptions, the behavior on Windows is as follows:
126124

127125
- **Windows ARM64 ABI**: For processor variants that support hardware floating-point exceptions, the Windows kernel catches these exceptions and disables them in the FPCR register. This ensures consistent behavior across different processor variants.
128126

docs/c-runtime-library/reference/controlfp-s.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: _controlfp_s"
33
title: "_controlfp_s"
4-
ms.date: "4/2/2020"
4+
ms.date: 03/27/2025
55
api_name: ["_controlfp_s", "_o__controlfp_s"]
66
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-runtime-l1-1-0.dll"]
77
api_type: ["DLLExport"]
@@ -75,16 +75,22 @@ _controlfp_s(&current_word, _DN_FLUSH, _MCW_DN);
7575
// and x64 processors with SSE2 support. Ignored on other x86 platforms.
7676
```
7777

78-
On ARM platforms, the **`_controlfp_s`** function applies to the FPSCR register. On x64 architectures, only the SSE2 control word that's stored in the MXCSR register is affected. On Intel (x86) platforms, **`_controlfp_s`** affects the control words for both the x87 and the SSE2, if present. It's possible for the two control words to be inconsistent with each other (because of a previous call to [`__control87_2`](control87-controlfp-control87-2.md), for example); if there's an inconsistency between the two control words, **`_controlfp_s`** sets the `EM_AMBIGUOUS` flag in *`currentControl`*. It's a warning that the returned control word might not represent the state of both floating-point control words accurately.
78+
This function is ignored when you use [`/clr` (Common Language Runtime Compilation)](../../build/reference/clr-common-language-runtime-compilation.md) to compile because the common language runtime (CLR) only supports the default floating-point precision.
7979

80-
On the ARM and x64 architectures, changing the infinity mode or the floating-point precision isn't supported. If the precision control mask is used on the x64 platform, the function raises an assertion and the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md).
80+
On x64, only the SSE2 control word that's stored in the MXCSR register is affected. Changing the infinity mode or the floating-point precision isn't supported. If the precision control mask is used on the x64 platform, the function raises an assertion and the invalid parameter handler is invoked as described in [Parameter validation](../parameter-validation.md).
8181

82-
If the mask isn't set correctly, this function generates an invalid parameter exception, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, this function returns `EINVAL` and sets `errno` to `EINVAL`.
82+
On x86, **`_controlfp_s`** affects the control words for both the x87 and the SSE2, if present. It's possible for the two control words to be inconsistent with each other (because of a previous call to [`__control87_2`](control87-controlfp-control87-2.md), for example); if there's an inconsistency between the two control words, **`_controlfp_s`** sets the `EM_AMBIGUOUS` flag in *`currentControl`*. It's a warning that the returned control word might not represent the state of both floating-point control words accurately.
8383

84-
This function is ignored when you use [`/clr` (Common Language Runtime Compilation)](../../build/reference/clr-common-language-runtime-compilation.md) to compile because the common language runtime (CLR) only supports the default floating-point precision.
84+
If the mask isn't set correctly, this function generates an invalid parameter exception, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, this function returns `EINVAL` and sets `errno` to `EINVAL`.
8585

8686
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).
8787

88+
### Arm platforms
89+
90+
- Changing the infinity mode or the floating-point precision isn't supported. If the precision control mask is used on the x64 platform, the function raises an assertion and the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md).
91+
- On ARM32 (discontinued), Windows doesn't support FP exceptions.
92+
- On ARM64, unmasking the whole `_MCW_EM` or any bits from it (`_EM_INEXACT`, `_EM_UNDERFLOW`, `_EM_OVERFLOW`, `_EM_ZERODIVIDE`, and `_EM_INVALID`) correctly change the FPCR register. Floating point exceptions raised by standard math functions, like Invalid operation from std::acos, are exempt from this behavior and can be ignored or raised properly depending on the FPCR register. For more information, see [Overview of ARM32 ABI Conventions](../../build/overview-of-arm-abi-conventions.md#floating-point-exceptions).
93+
8894
### Mask constants and values
8995

9096
For the `_MCW_EM` mask, clearing it sets the exception, which allows the hardware exception; setting it hides the exception. If a `_EM_UNDERFLOW` or `_EM_OVERFLOW` occurs, no hardware exception is thrown until the next floating-point instruction is executed. To generate a hardware exception immediately after `_EM_UNDERFLOW` or `_EM_OVERFLOW`, call the `FWAIT MASM` instruction.

0 commit comments

Comments
 (0)