These functions definitely need to be reentrant and although the scheduler code should guard against pseudo simultaneously calls it cannot guard against the application code making similar calls.
I would be amazed if this function was ever not reentrant, although many of the SDCC libraries are not (hence I provide a download of reentrant versions).
The design decision was taken to use the library function as it was considered more likely to be the source of errors if an equivalent function were defined in the portable layer (as different memory alignment requirements could cause problems).
I’m still investigating this. If I have found an issue - it is only in my MSP430 IAR port.
I’ve discussed this with IAR and they have told me the functions are reentrant - but I need to do further testing to determine if I’ve hit some kind
of corner case.
I think strncpy() is used to copy the task name into the TCB - so only when a task is created. Other than that the library functions are used when configUSE_TRACE_FACILITY is defined and you are creating a table of the task status.
I have noticed this - and this is in my app - not the core FreeRTOS code. If I do something like this - back to back:
memset
memcpy
strtoul
I get results in the debugger that seemingly aren’t ‘real’. If I run ‘realtime’ - all seems to be well - but if I set breakpoints and try to examine - I get conflicting results. An example -
I initialize a ‘packet’. Part of the ‘packet’ get’s memcpy(ied) like above - but when I stop the debugger and look at the packet contents - it shows the initialized values - even though this is impossible. Kindof strange - I noticed it’s hard to debug if you have too many back-to-back lib functions stacked up for some reason…
I don’t think I’m having a problem with inlining - but I’ll check that. I suppose that could explain the issue with trying to debug with back to back lib calls.