Crt threads warning fixes

This cleans up a number of warnings when using ``-Weverything`` in the c-run-time code, especially those related to the posix threading code.