Skip to content

Commit 14d4bfd

Browse files
manbearianColin Robertson
authored andcommitted
Update unaligned.md to remove Itanium references (MicrosoftDocs#186)
* Update unaligned.md Remove Itanium references and generalize text to apply to all platforms (save x86...) * Update unaligned.md Edit to current markdown lint standards.
1 parent a0fdbba commit 14d4bfd

File tree

1 file changed

+25
-50
lines changed

1 file changed

+25
-50
lines changed

docs/cpp/unaligned.md

Lines changed: 25 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,40 @@
11
---
22
title: "__unaligned | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
5-
ms.reviewer: ""
6-
ms.suite: ""
4+
ms.date: "03/09/2018"
75
ms.technology: ["cpp-language"]
8-
ms.tgt_pltfrm: ""
96
ms.topic: "language-reference"
107
f1_keywords: ["__unaligned_cpp"]
118
dev_langs: ["C++"]
129
helpviewer_keywords: ["__unaligned keyword [C++]"]
1310
ms.assetid: 0cd83aad-1840-47e3-ad33-59bfcbe6375b
14-
caps.latest.revision: 11
1511
author: "mikeblome"
1612
ms.author: "mblome"
1713
manager: "ghogen"
1814
ms.workload: ["cplusplus"]
1915
---
2016
# __unaligned
21-
When you declare a pointer with the `__unaligned` modifier, the compiler assumes that the pointer addresses data that is not aligned. Consequently, for an application that targets an Itanium Processor Family (IPF) computer, the compiler generates code that reads the unaligned data one byte at a time.
22-
23-
## Remarks
24-
The `__unaligned` modifier is valid for the [!INCLUDE[vcprx64](../assembler/inline/includes/vcprx64_md.md)] and [!INCLUDE[vcpritanium](../cpp/includes/vcpritanium_md.md)] compilers but affects only applications that target an IPF computer. This modifier describes the alignment of the addressed data only; the pointer itself is assumed to be aligned.
25-
26-
The [!INCLUDE[vcpritanium](../cpp/includes/vcpritanium_md.md)] processor generates an alignment fault when it accesses misaligned data, and the time to process the fault weakens performance. Use the `__unaligned` modifier to cause the processor to read data one byte at a time and avoid the fault. This modifier is not required for [!INCLUDE[vcprx64](../assembler/inline/includes/vcprx64_md.md)] applications because the [!INCLUDE[vcprx64](../assembler/inline/includes/vcprx64_md.md)] processor handles misaligned data without faulting.
27-
28-
For more information about alignment, see:
29-
30-
- [align](../cpp/align-cpp.md)
31-
32-
- [__alignof Operator](../cpp/alignof-operator.md)
33-
34-
- [pack](../preprocessor/pack.md)
35-
36-
- [/Zp (Struct Member Alignment)](../build/reference/zp-struct-member-alignment.md)
37-
38-
- [Examples of Structure Alignment](../build/examples-of-structure-alignment.md)
39-
40-
## Example
41-
42-
```
43-
// unaligned_keyword.cpp
44-
// compile with: /c
45-
// processor: x64 IPF
46-
#include <stdio.h>
47-
int main() {
48-
char buf[100];
49-
50-
int __unaligned *p1 = (int*)(&buf[37]);
51-
int *p2 = (int *)p1;
52-
53-
*p1 = 0; // ok
54-
55-
__try {
56-
*p2 = 0; // throws an exception
57-
}
58-
__except(1) {
59-
puts("exception");
60-
}
61-
}
62-
```
63-
64-
## See Also
65-
[Keywords](../cpp/keywords-cpp.md)
17+
18+
**Microsoft specific**. When you declare a pointer with the `__unaligned` modifier, the compiler assumes that the pointer addresses data that is not aligned. Consequently, platform-appropriate code is generated to handle unaligned reads and writes through the pointer.
19+
20+
## Remarks
21+
22+
This modifier describes the alignment of the data addressed by the pointer; the pointer itself is assumed to be aligned.
23+
24+
The necessity for the `__unaligned` keyword varies by platform and environment. Failure to mark data appropriately can result in issues ranging from performance penalties to hardware faults. The `__unaligned` modifier is not valid for the x86 platform.
25+
26+
For more information about alignment, see:
27+
28+
- [align](../cpp/align-cpp.md)
29+
30+
- [__alignof Operator](../cpp/alignof-operator.md)
31+
32+
- [pack](../preprocessor/pack.md)
33+
34+
- [/Zp (Struct Member Alignment)](../build/reference/zp-struct-member-alignment.md)
35+
36+
- [Examples of Structure Alignment](../build/examples-of-structure-alignment.md)
37+
38+
## See also
39+
40+
[Keywords](../cpp/keywords-cpp.md)

0 commit comments

Comments
 (0)