Giovanni wrote:Do you have an example for this?
I am reluctant to support this kind of things because it would depend on the library (newlib) and how the library is compiled (reentrant or not).
Giovanni
Not sure if it should be part of standard ChibiOS distribution. Perhaps part of the optional syscalls, and have some #ifdefs based on the flavor of newlib included ..
CH_CFG_THREAD_EXTRAFIELDS: Add struct _reent newlib_reentry_structure.
CH_CFG_THREAD_INIT_HOOK(tp): Execute _REENT_INIT_PTR(tp->newlib_reentry_structure) to initialize struct _reent .
int *__errno(void)
{
return &_REENT->_errno;
}
struct _reent *__getreent()
{
return chThdGetSlefX()->newlib_reentry_structure;
}
Probably want to have a critical section in __errno.
I haven't tested this yet, but I have some other working code with CMX RTOS which looks similar. I'll update this thread when I have it working with ChibiOS.