Skip to content

Commit

Permalink
removed packed attribute from structs, packing caused memory alignmen…
Browse files Browse the repository at this point in the history
…t problems on Cortex-M0+. we can optimize later if needed
  • Loading branch information
glennergeerts committed Sep 3, 2015
1 parent b82ba4f commit 761cf7c
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions stack/framework/hal/inc/hwradio.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,8 @@ typedef struct
* HW_CRC_VALID if the CRC was valid
*/

//this struct is "packed" so it occupies minimal space
//and to ensure that, the 'prefix' fields (including length) of hw_radio_packet_t
//are 32-bits aligned (that is sizeof(hw_radio_packet_t)%4 == 0)
} __attribute__ ((packed)) hw_rx_metadata_t;
// TODO optimize struct for size. This was packed but resulted in alignment issues on Cortex-M0 so removed for now.
} hw_rx_metadata_t;

/** \brief The metadata an TX settings attached to a packet ready to be transmitted / that has been
* transmitted.
Expand All @@ -195,10 +193,8 @@ typedef struct
#endif
hw_tx_cfg_t tx_cfg; /**< The 'TX Configuration' used to receive the packet. */

//this struct is "packed" so it occupies minimal space
//and to ensure that, the 'prefix' fields (including length) of hw_radio_packet_t
//are 32-bits aligned (that is sizeof(hw_radio_packet_t)%4 == 0)
} __attribute__ ((packed)) hw_tx_metadata_t;
// TODO optimize struct for size. This was packed but resulted in alignment issues on Cortex-M0 so removed for now.
} hw_tx_metadata_t;

/** \brief A PHY layer packet that can be sent / received over the air using the HW radio interface.
*
Expand Down Expand Up @@ -233,10 +229,8 @@ typedef struct
uint8_t data[]; /**< The packet data. data[0] overlaps with the 'length' field */
};
};
//this struct is "packed" so it occupies minimal space
//and to ensure that, the 'prefix' fields (including length) of hw_radio_packet_t
//are 32-bits alligned (that is sizeof(hw_radio_packet_t)%4 == 0)
} __attribute__ ((packed)) hw_radio_packet_t;
// TODO optimize struct for size. This was packed but resulted in alignment issues on Cortex-M0 so removed for now.
} hw_radio_packet_t;

/** \brief A convenience MACRO that calculates the minimum size of a buffer large enough to hold a single
* hw_radio_packet_t of the specified length
Expand Down

0 comments on commit 761cf7c

Please sign in to comment.