Thread safety for C code: doing it right this time.