<?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 Thread Local Storage class MQX / ARM compiler? in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Thread-Local-Storage-class-MQX-ARM-compiler/m-p/236127#M6596</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there some way to declare a variable to be placed in thread local storage in MQX?&amp;nbsp; Can someone point me to an example of this?&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Caveat:&amp;nbsp; I am using MQX with the Arm (Keil) toolchain.&amp;nbsp; In this tool-chain there is a __declspec(thread) attribute in the compiler.&amp;nbsp; Example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;__declspec(thread) int i;&lt;/P&gt;&lt;P&gt;__thread int j;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // same as __declspec(thread) int j;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This targets the variable for a particular linker section.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suspect that you would have to declare a variable with this compile time attribute along with adding a special linker section that ultimately MQX understands to mean that this variable context is conditional on the currently running task.&amp;nbsp; It's not clear to me where or how to enable this, but I am sure another tool chain (Metaware) that I have used in the past with MQX implemented this feature.&amp;nbsp; So I know it should be possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, I'm not looking for a workaround solution.&amp;nbsp; I know I could allocate storage dynamically, or write a function that returns a value with sensitivity to the current task ID.&amp;nbsp; I would like to implement it with a compile time solution.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;PMT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jan 2014 16:01:13 GMT</pubDate>
    <dc:creator>pmt</dc:creator>
    <dc:date>2014-01-15T16:01:13Z</dc:date>
    <item>
      <title>Thread Local Storage class MQX / ARM compiler?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Thread-Local-Storage-class-MQX-ARM-compiler/m-p/236127#M6596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there some way to declare a variable to be placed in thread local storage in MQX?&amp;nbsp; Can someone point me to an example of this?&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Caveat:&amp;nbsp; I am using MQX with the Arm (Keil) toolchain.&amp;nbsp; In this tool-chain there is a __declspec(thread) attribute in the compiler.&amp;nbsp; Example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;__declspec(thread) int i;&lt;/P&gt;&lt;P&gt;__thread int j;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // same as __declspec(thread) int j;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This targets the variable for a particular linker section.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suspect that you would have to declare a variable with this compile time attribute along with adding a special linker section that ultimately MQX understands to mean that this variable context is conditional on the currently running task.&amp;nbsp; It's not clear to me where or how to enable this, but I am sure another tool chain (Metaware) that I have used in the past with MQX implemented this feature.&amp;nbsp; So I know it should be possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, I'm not looking for a workaround solution.&amp;nbsp; I know I could allocate storage dynamically, or write a function that returns a value with sensitivity to the current task ID.&amp;nbsp; I would like to implement it with a compile time solution.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;PMT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 16:01:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Thread-Local-Storage-class-MQX-ARM-compiler/m-p/236127#M6596</guid>
      <dc:creator>pmt</dc:creator>
      <dc:date>2014-01-15T16:01:13Z</dc:date>
    </item>
  </channel>
</rss>

