Skip to content

Commit 06b98f4

Browse files
Fix pragma pack in CCS compiler to push/pop (#906)
`#pragma pack(1)` would make it so that all structs inserted after pack_struct_start.h was included for the TI arm compiler would be packed, leading to potential unaligned memory access error. Refer: https://www.ti.com/lit/ug/spnu151w/spnu151w.pdf SECTION 5.11.23
1 parent 62b6d1e commit 06b98f4

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

source/portable/Compiler/CCS/pack_struct_end.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*
2626
* Contains a semicolon to end the wrapped structure,
2727
* and resets warnings that were supressed in pack_struct_start.h.
28+
* It also pops the previously pushed alignment of 1 byte of the stack.
2829
*/
2930
;
31+
#pragma pack(pop)
3032
#pragma diag_pop

source/portable/Compiler/CCS/pack_struct_start.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
*
2626
* Also suppress an incorrect warning from the CCS compiler:
2727
* error #1916-D: definition at end of file not followed by a semicolon or a declarator
28+
* Pushes the struct alignment of packed.
2829
*/
2930
#pragma diag_push
3031
#pragma diag_suppress=1916
31-
#pragma pack(1)
32+
#pragma pack(push, 1)

0 commit comments

Comments
 (0)