<?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>MQX Software Solutionsのトピック_mem_copy is backwards</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/mem-copy-is-backwards/m-p/248544#M7149</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is both a short rant a warning for others. In mqx.h (line 1247) we find:&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;#define _mem_copy(s,d,l) memcpy(d,s,l)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Note the subtle reversing of the order of the arguments. And the same thing applies to all the higher level abstractions built on top of this (e.g. USB_mem_copy). They are all backwards. For the love of God why would you do that? Are you &lt;EM&gt;trying&lt;/EM&gt; to trip people up? I mean, why follow a convention that has only been fixed since the late 70's.&lt;/P&gt;&lt;P&gt;Seriously, is there a good reason for this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Oct 2013 01:45:49 GMT</pubDate>
    <dc:creator>matthewkendall</dc:creator>
    <dc:date>2013-10-31T01:45:49Z</dc:date>
    <item>
      <title>_mem_copy is backwards</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/mem-copy-is-backwards/m-p/248544#M7149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is both a short rant a warning for others. In mqx.h (line 1247) we find:&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;#define _mem_copy(s,d,l) memcpy(d,s,l)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Note the subtle reversing of the order of the arguments. And the same thing applies to all the higher level abstractions built on top of this (e.g. USB_mem_copy). They are all backwards. For the love of God why would you do that? Are you &lt;EM&gt;trying&lt;/EM&gt; to trip people up? I mean, why follow a convention that has only been fixed since the late 70's.&lt;/P&gt;&lt;P&gt;Seriously, is there a good reason for this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 01:45:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/mem-copy-is-backwards/m-p/248544#M7149</guid>
      <dc:creator>matthewkendall</dc:creator>
      <dc:date>2013-10-31T01:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: _mem_copy is backwards</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/mem-copy-is-backwards/m-p/248545#M7150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I watched the code and found that when the Macro MQXCFG_MEM_COPY defined as 1 or MQXCFG_MEM_COPY_NEON and PSP_HAS_FPU all defined as 1, the code will not use the memcpy function from C lib, instead will use _mem_copy function in MQX code.&lt;/P&gt;&lt;P&gt;#if MQXCFG_MEM_COPY || (MQXCFG_MEM_COPY_NEON &amp;amp;&amp;amp; PSP_HAS_FPU)&lt;/P&gt;&lt;P&gt;extern void&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _mem_copy(pointer, pointer, _mem_size);&lt;/P&gt;&lt;P&gt;#else&lt;/P&gt;&lt;P&gt;# include &amp;lt;string.h&amp;gt;&lt;/P&gt;&lt;P&gt;#define _mem_copy(s,d,l) memcpy(d,s,l)&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;With regards to the parameter reverse problem, in _mem_copy function, the first parameter is the source address of the data to copy and the second is the destination address to place at; but in memcpy function that defined in C lib, the first parameter is the destination address to place at and second is the source address of the data to copy.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 02:44:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/mem-copy-is-backwards/m-p/248545#M7150</guid>
      <dc:creator>susansu</dc:creator>
      <dc:date>2013-10-31T02:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: _mem_copy is backwards</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/mem-copy-is-backwards/m-p/248546#M7151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I stumbled upon this same problem today.&amp;nbsp; I was looking at the Vybrid bootloader example (/mqx/examples/bootloader_vybrid) and noticed the source and destination arguments were backwards and thought it was a bug in the bootloader code.&amp;nbsp; That was until I found the _mem_copy() implementation in MQX in module mem_copy.c&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;void _mem_copy&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; (&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* [IN] address to copy data from */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; void&amp;nbsp;&amp;nbsp;&amp;nbsp; *from_ptr,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* [IN] address to copy data to */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; void&amp;nbsp;&amp;nbsp;&amp;nbsp; *to_ptr,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* [IN] number of bytes to copy */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; register _mem_size number_of_bytes&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The source and destination arguments are backwards from the standard c library implementation which has been in existence since forever.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I second Matthew's rant.&amp;nbsp; Why would you do this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Aug 2015 16:31:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/mem-copy-is-backwards/m-p/248546#M7151</guid>
      <dc:creator>keno</dc:creator>
      <dc:date>2015-08-17T16:31:20Z</dc:date>
    </item>
  </channel>
</rss>

