utils: Move thread-safe strerror replacement to a separate file