__printf_lock and __printf_unlock
The CrossWorks for ARM 3.2 documentation says that implementing these two functions is necessary to ensure mutual exclusion for printf and related functions.
If I define these two functions in my code (along with mutex lock/unlock code to enable exclusion), the linker complains that these functions are already defined (presumably in the Rowley C libraries).
How do I implement these functions in my code (which used an RTOS, so mutual exclusion is necessary) so that they don't conflict with the stub versions in the libraries?
-
I only use sprintf in my code, not printf/scanf. Based on your reply above, it looks like I don't need to implement mutual exclusion--is this correct? Is sprintf thread-safe without having to implement any specific mechanisms (like __printf_lock/unlock)?
This came up because I'm having problems with bus errors happening in the library vfprintf code. My application runs under an RTOS, so thread safety is an issue.
Please sign in to leave a comment.
Comments
4 comments