Skip to content

Commit

Permalink
Fix pragma pack in CCS compiler to push/pop (#906)
Browse files Browse the repository at this point in the history
`#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
  • Loading branch information
rahul-arasikere authored Jun 12, 2023
1 parent 62b6d1e commit 06b98f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions source/portable/Compiler/CCS/pack_struct_end.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
*
* Contains a semicolon to end the wrapped structure,
* and resets warnings that were supressed in pack_struct_start.h.
* It also pops the previously pushed alignment of 1 byte of the stack.
*/
;
#pragma pack(pop)
#pragma diag_pop
3 changes: 2 additions & 1 deletion source/portable/Compiler/CCS/pack_struct_start.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
*
* Also suppress an incorrect warning from the CCS compiler:
* error #1916-D: definition at end of file not followed by a semicolon or a declarator
* Pushes the struct alignment of packed.
*/
#pragma diag_push
#pragma diag_suppress=1916
#pragma pack(1)
#pragma pack(push, 1)

0 comments on commit 06b98f4

Please sign in to comment.