3636extern "C" {
3737#endif
3838
39- #ifndef __packed
40- #define __packed __attribute__((__packed__))
39+ #if defined(__IAR_SYSTEMS_ICC__ )
40+ #define STRUCT_PACKED __packed struct
41+ #else
42+ #define STRUCT_PACKED struct __attribute__((__packed__))
4143#endif
4244
4345struct flash_area ;
@@ -136,12 +138,12 @@ struct flash_area;
136138 */
137139#define IMAGE_TLV_ANY 0xffff /* Used to iterate over all TLV */
138140
139- struct image_version {
141+ STRUCT_PACKED image_version {
140142 uint8_t iv_major ;
141143 uint8_t iv_minor ;
142144 uint16_t iv_revision ;
143145 uint32_t iv_build_num ;
144- } __packed ;
146+ };
145147
146148struct image_dependency {
147149 uint8_t image_id ; /* Image index (from 0) */
@@ -154,7 +156,7 @@ struct image_dependency {
154156};
155157
156158/** Image header. All fields are in little endian byte order. */
157- struct image_header {
159+ STRUCT_PACKED image_header {
158160 uint32_t ih_magic ;
159161 uint32_t ih_load_addr ;
160162 uint16_t ih_hdr_size ; /* Size of image header (bytes). */
@@ -163,19 +165,19 @@ struct image_header {
163165 uint32_t ih_flags ; /* IMAGE_F_[...]. */
164166 struct image_version ih_ver ;
165167 uint32_t _pad1 ;
166- } __packed ;
168+ };
167169
168170/** Image TLV header. All fields in little endian. */
169- struct image_tlv_info {
171+ STRUCT_PACKED image_tlv_info {
170172 uint16_t it_magic ;
171173 uint16_t it_tlv_tot ; /* size of TLV area (including tlv_info header) */
172- } __packed ;
174+ };
173175
174176/** Image trailer TLV format. All fields in little endian. */
175- struct image_tlv {
177+ STRUCT_PACKED image_tlv {
176178 uint16_t it_type ; /* IMAGE_TLV_[...]. */
177179 uint16_t it_len ; /* Data length (not including TLV header). */
178- } __packed ;
180+ };
179181
180182#define ENCRYPTIONFLAGS (IMAGE_F_ENCRYPTED_AES128 | IMAGE_F_ENCRYPTED_AES256)
181183#define IS_ENCRYPTED (hdr ) (((hdr)->ih_flags & IMAGE_F_ENCRYPTED_AES128) \
0 commit comments