Somehow it would still build fine, but would crash when compiled with GCC 12.2
on Debian 12.
Also re-add wrongly removed Mutex include from `thread_safe.h`, where it's used
in macros.
Add IWYU pragma comments to prevent it from mistakenly flagging those as unused.