Support TLS for IAR DLib
Market leading real time kernel for 40+ microcontroller architectures
Brought to you by:
gaurav-aws,
rtel
I would like to have IAR DLib TLS supported (similarly as newlib). DLib TLS support is described here:
http://supp.iar.com/FilesPublic/UPDINFO/005691/arm/doc/infocenter/DLIBThreadSupport.html
Attached is a proposed implementation based on v8.2.2 and an according Unix diff. Please watch for tags #011 in the proposed source file.
Thanks for this.
I am not familiar with DLib, but it does look similar in concept to the
NewLib's thread awareness. Supporting 18 or more different compilers we
prefer not to have compiler specifics in the core (common) source files
themselves, but instead to have the code in the port layer. I'm
wondering if we could combine Newlib and DLib support by using macros -
in the IAR port layer the macros would be defined to use DLib, and in
GCC port layers they could be defined to use Newlib. In other cases the
macros would default to being empty. There may even be a way of using
the FreeRTOS TLS pointers
(http://www.freertos.org/thread-local-storage-pointers.html) and the
trace macros so DLib support can be added without editing the source files.
Thank you for the hint with the Thread Local Storage pointers. I think I can use this for DLib support, but I am only concerned about the deallocation of memory in prvDeleteTCB( TCB_t pxTCB ). If I could establish a callback function that is called by prvDeleteTCB passing the TLS with index 0, this callback could in turn call the iar_dlib_perthread_deallocate to clean up the memory. I would be glad, if such a callback could be supported.
Regards
WSC
This might (or might not) work for you.
Find the implementation of prvDeleteTCB() in FreeRTOS/Source/Tasks.c.
In there you will see a macro called portCLEAN_UP_TCB(). As might be
expected by the 'port' prefix, the macro is used by some port layers.
However, in your case I think you are free to define the macro how you
want in FreeRTOSConfig.h. You could define the macro to do something
similar to the code immediately after where the macro is called, which
cleans up the newlib structures.
Thank you very much for this hint. I am quite sure that this solution will work.
Regards,
WSC