<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: The data structure alignment not correct in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/The-data-structure-alignment-not-correct/m-p/1701810#M210517</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/107756"&gt;@jasonedn&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;I think that the compiler will put these variables&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;&amp;lt; bool isTxAutoSync; /*!&amp;lt; If auto sync mechanism open */&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;bool isRxAutoSync; /*!&amp;lt; If auto sync mechanism open */&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;uint8_t DPLLClkSource; /*!&amp;lt; SPDIF DPLL clock source, range from 0~15, meaning is chip-specific */&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;uint8_t txClkSource; /*!&amp;lt; SPDIF tx clock source, range from 0~7, meaning is chip-specific */ &amp;gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;in a uint32.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;Best regards&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;Harvey&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Aug 2023 08:53:23 GMT</pubDate>
    <dc:creator>Harvey021</dc:creator>
    <dc:date>2023-08-09T08:53:23Z</dc:date>
    <item>
      <title>The data structure alignment not correct</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/The-data-structure-alignment-not-correct/m-p/1699614#M210340</link>
      <description>&lt;P&gt;I tried to align the structure members, but it seems the MCUXpresso compiler doesn't.&amp;nbsp;&lt;BR /&gt;I created two data types&amp;nbsp; based on the original&amp;nbsp;spdif_config_t as below:&lt;/P&gt;&lt;P&gt;typedef struct _spdif_config_t&lt;BR /&gt;{&lt;BR /&gt;bool isTxAutoSync; /*!&amp;lt; If auto sync mechanism open */&lt;BR /&gt;bool isRxAutoSync; /*!&amp;lt; If auto sync mechanism open */&lt;BR /&gt;uint8_t DPLLClkSource; /*!&amp;lt; SPDIF DPLL clock source, range from 0~15, meaning is chip-specific */&lt;BR /&gt;uint8_t txClkSource; /*!&amp;lt; SPDIF tx clock source, range from 0~7, meaning is chip-specific */&lt;BR /&gt;spdif_rxfull_select_t rxFullSelect; /*!&amp;lt; SPDIF rx buffer full select */&lt;BR /&gt;spdif_txempty_select_t txFullSelect; /*!&amp;lt; SPDIF tx buffer empty select */&lt;BR /&gt;spdif_uchannel_source_t uChannelSrc; /*!&amp;lt; U channel source */&lt;BR /&gt;spdif_tx_source_t txSource; /*!&amp;lt; SPDIF tx data source */&lt;BR /&gt;spdif_validity_config_t validityConfig; /*!&amp;lt; Validity flag config */&lt;BR /&gt;spdif_gain_select_t gain; /*!&amp;lt; Rx receive clock measure gain parameter. */&lt;BR /&gt;} spdif_config_t;&lt;/P&gt;&lt;P&gt;typedef struct _spdif_config_t1&lt;BR /&gt;{&lt;BR /&gt;bool isTxAutoSync; /*!&amp;lt; If auto sync mechanism open */&lt;BR /&gt;bool isRxAutoSync; /*!&amp;lt; If auto sync mechanism open */&lt;BR /&gt;uint8_t DPLLClkSource; /*!&amp;lt; SPDIF DPLL clock source, range from 0~15, meaning is chip-specific */&lt;BR /&gt;uint8_t txClkSource; /*!&amp;lt; SPDIF tx clock source, range from 0~7, meaning is chip-specific */&lt;BR /&gt;spdif_rxfull_select_t rxFullSelect; /*!&amp;lt; SPDIF rx buffer full select */&lt;BR /&gt;spdif_txempty_select_t txFullSelect; /*!&amp;lt; SPDIF tx buffer empty select */&lt;BR /&gt;spdif_uchannel_source_t uChannelSrc; /*!&amp;lt; U channel source */&lt;BR /&gt;spdif_tx_source_t txSource; /*!&amp;lt; SPDIF tx data source */&lt;BR /&gt;spdif_validity_config_t validityConfig; /*!&amp;lt; Validity flag config */&lt;BR /&gt;spdif_gain_select_t gain; /*!&amp;lt; Rx receive clock measure gain parameter. */&lt;BR /&gt;} spdif_config_t1_t __attribute__(aligned(4));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#pragma pack(push, 4)&lt;BR /&gt;typedef struct _spdif_config_t2&lt;BR /&gt;{&lt;BR /&gt;bool isTxAutoSync; /*!&amp;lt; If auto sync mechanism open */&lt;BR /&gt;bool isRxAutoSync; /*!&amp;lt; If auto sync mechanism open */&lt;BR /&gt;uint8_t DPLLClkSource; /*!&amp;lt; SPDIF DPLL clock source, range from 0~15, meaning is chip-specific */&lt;BR /&gt;uint8_t txClkSource; /*!&amp;lt; SPDIF tx clock source, range from 0~7, meaning is chip-specific */&lt;BR /&gt;spdif_rxfull_select_t rxFullSelect; /*!&amp;lt; SPDIF rx buffer full select */&lt;BR /&gt;spdif_txempty_select_t txFullSelect; /*!&amp;lt; SPDIF tx buffer empty select */&lt;BR /&gt;spdif_uchannel_source_t uChannelSrc; /*!&amp;lt; U channel source */&lt;BR /&gt;spdif_tx_source_t txSource; /*!&amp;lt; SPDIF tx data source */&lt;BR /&gt;spdif_validity_config_t validityConfig; /*!&amp;lt; Validity flag config */&lt;BR /&gt;spdif_gain_select_t gain; /*!&amp;lt; Rx receive clock measure gain parameter. */&lt;BR /&gt;} spdif_config_t2_t;&lt;BR /&gt;#pragma pack(pop)&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;I printed the size using&amp;nbsp;&lt;SPAN&gt;sizeof&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;spdif_config_t/&lt;SPAN&gt;spdif_config_t1_t/spdif_config_t2_t&lt;/SPAN&gt;), all of the sizes 10.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However&amp;nbsp;&lt;SPAN&gt;sizeof&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;spdif_config_t) should be different from sizeof(spdif_config_t1_t/spdif_config_t2_t) if the alignment works.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can anybody help with this issue?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 04 Aug 2023 22:35:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/The-data-structure-alignment-not-correct/m-p/1699614#M210340</guid>
      <dc:creator>jasonedn</dc:creator>
      <dc:date>2023-08-04T22:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: The data structure alignment not correct</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/The-data-structure-alignment-not-correct/m-p/1701810#M210517</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/107756"&gt;@jasonedn&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;I think that the compiler will put these variables&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;&amp;lt; bool isTxAutoSync; /*!&amp;lt; If auto sync mechanism open */&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;bool isRxAutoSync; /*!&amp;lt; If auto sync mechanism open */&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;uint8_t DPLLClkSource; /*!&amp;lt; SPDIF DPLL clock source, range from 0~15, meaning is chip-specific */&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;uint8_t txClkSource; /*!&amp;lt; SPDIF tx clock source, range from 0~7, meaning is chip-specific */ &amp;gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;in a uint32.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;Best regards&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;Harvey&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 08:53:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/The-data-structure-alignment-not-correct/m-p/1701810#M210517</guid>
      <dc:creator>Harvey021</dc:creator>
      <dc:date>2023-08-09T08:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: The data structure alignment not correct</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/The-data-structure-alignment-not-correct/m-p/1701904#M210528</link>
      <description>&lt;P&gt;Could you please try&amp;nbsp;&amp;nbsp;aligned(1) or pack(push, 1).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because 32bit compiler&amp;nbsp; self-alignment is 4 bytes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pack will lower the performance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 11:05:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/The-data-structure-alignment-not-correct/m-p/1701904#M210528</guid>
      <dc:creator>rudi_cyber</dc:creator>
      <dc:date>2023-08-09T11:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: The data structure alignment not correct</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/The-data-structure-alignment-not-correct/m-p/1702111#M210541</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi rudi_cyber,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The MCUXPresso default alignment is 1-byte and I want 4-byte alignment. The release build at -O3 craches if it's 1-byte alignment.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 16:39:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/The-data-structure-alignment-not-correct/m-p/1702111#M210541</guid>
      <dc:creator>jasonedn</dc:creator>
      <dc:date>2023-08-09T16:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: The data structure alignment not correct</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/The-data-structure-alignment-not-correct/m-p/1702608#M210564</link>
      <description>&lt;P&gt;You can use objdump to check the size of bool in the toolchain.&lt;/P&gt;&lt;P&gt;And readelf to double confirm the alignment.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Usually, bool is 1 byte in toolchain. So the first 4 members seem in one 32bit, it doesn't matter pack 1 or pack 4.&lt;/P&gt;&lt;P&gt;objdump&lt;/P&gt;&lt;P&gt;&amp;lt;2&amp;gt;&amp;lt;ee&amp;gt;: Abbrev Number: 0&lt;BR /&gt;&amp;lt;1&amp;gt;&amp;lt;ef&amp;gt;: Abbrev Number: 2 (DW_TAG_base_type)&lt;BR /&gt;&amp;lt;f0&amp;gt; DW_AT_byte_size : 1&lt;BR /&gt;&amp;lt;f1&amp;gt; DW_AT_encoding : 2 (boolean)&lt;BR /&gt;&amp;lt;f2&amp;gt; DW_AT_name : (indirect string, offset: 0xe4): _Bool&lt;BR /&gt;&amp;lt;1&amp;gt;&amp;lt;f6&amp;gt;: Abbrev Number: 4 (DW_TAG_volatile_type)&lt;BR /&gt;&amp;lt;f7&amp;gt; DW_AT_type : &amp;lt;0xef&amp;gt;&lt;BR /&gt;&amp;lt;1&amp;gt;&amp;lt;fb&amp;gt;: Abbrev Number: 0&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;21&amp;gt; DW_AT_stmt_list : 0x0&lt;BR /&gt;&amp;lt;1&amp;gt;&amp;lt;25&amp;gt;: Abbrev Number: 2 (DW_TAG_base_type)&lt;BR /&gt;&amp;lt;26&amp;gt; DW_AT_byte_size : 4&lt;BR /&gt;&amp;lt;27&amp;gt; DW_AT_encoding : 7 (unsigned)&lt;BR /&gt;&amp;lt;28&amp;gt; DW_AT_name : (indirect string, offset: 0x129): unsigned int&lt;BR /&gt;&amp;lt;1&amp;gt;&amp;lt;2c&amp;gt;: Abbrev Number: 3 (DW_TAG_base_type)&lt;BR /&gt;&amp;lt;2d&amp;gt; DW_AT_byte_size : 4&lt;BR /&gt;&amp;lt;2e&amp;gt; DW_AT_encoding : 5 (signed)&lt;BR /&gt;&amp;lt;2f&amp;gt; DW_AT_name : int&lt;BR /&gt;&amp;lt;1&amp;gt;&amp;lt;33&amp;gt;: Abbrev Number: 2 (DW_TAG_base_type)&lt;BR /&gt;&amp;lt;34&amp;gt; DW_AT_byte_size : 8&lt;BR /&gt;&amp;lt;35&amp;gt; DW_AT_encoding : 5 (signed)&lt;BR /&gt;&amp;lt;36&amp;gt; DW_AT_name : (indirect string, offset: 0x0): long long int&lt;BR /&gt;&amp;lt;1&amp;gt;&amp;lt;3a&amp;gt;: Abbrev Number: 2 (DW_TAG_base_type)&lt;BR /&gt;&amp;lt;3b&amp;gt; DW_AT_byte_size : 8&lt;BR /&gt;&amp;lt;3c&amp;gt; DW_AT_encoding : 4 (float)&lt;BR /&gt;&amp;lt;3d&amp;gt; DW_AT_name : (indirect string, offset: 0x113): long double&lt;BR /&gt;&amp;lt;1&amp;gt;&amp;lt;41&amp;gt;: Abbrev Number: 2 (DW_TAG_base_type)&lt;/P&gt;&lt;P&gt;readelf&lt;BR /&gt;&lt;BR /&gt;Tag_ABI_PCS_wchar_t: 4&lt;BR /&gt;Tag_ABI_FP_denormal: Needed&lt;BR /&gt;Tag_ABI_FP_exceptions: Needed&lt;BR /&gt;Tag_ABI_FP_number_model: IEEE 754&lt;BR /&gt;Tag_ABI_align_needed: 8-byte&lt;BR /&gt;Tag_ABI_align_preserved: 8-byte, except leaf SP&lt;BR /&gt;Tag_ABI_enum_size: small&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 04:45:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/The-data-structure-alignment-not-correct/m-p/1702608#M210564</guid>
      <dc:creator>rudi_cyber</dc:creator>
      <dc:date>2023-08-10T04:45:23Z</dc:date>
    </item>
  </channel>
</rss>

