We are moving the embedded application from Windows CE to another system. The current processor is STM32F4. Our current code makes heavy use of TLS. The new prototype uses KEIL CMSIS RTOS, which has very low functionality.
In http://www.keil.com/support/man/docs/armcc/armcc_chr1359124216560.htm it states that the thread local storage is maintained 5.04. Now we are using 5.04. The problem is that when linking our program to the definition of a variable, the __thread int a;linker cannot find __aeabi_read_tpwhat makes sense to me.
My question is: is it possible to implement __aeabi_read_tp, and it will work, or is there more to it?
If this is simply not possible for us: is there a way to implement TLS only in software? Don't talk about performance there yet.
EDIT I ββtried to implement __aeabi_read_tpby looking at the old freeBSD source and other sources. Although the function is mainly implemented in the assembly, I found a version in C that boils down to the following:
extern "C"
{
extern osThreadId svcThreadGetId(void);
void *__aeabi_read_tp()
{
return (void*)svcThreadGetId();
}
}
This basically gives me the ID (void *) of my current executable thread. If I understand correctly, this is what we want. Could this work?
source
share