First of all, apologies for the delay in replying to this.
Thanks for reporting this issue, you are correct the way the in-line implementation (provided by ctype.h) uses a global variable which is not thread safe. This issue only applies to the in-line implementation, and the out-of-line (library call) is safe to use in a multi-threaded environment.
To force use of the out-of-line copy, you just need to #undef the appropriate functions after including ctype.h, for example:
#include <ctype.h> #undef toupper #undef tolower
Which will do the equivalent of your own function.
Regards,
Murray