Move header thread_affinity declaration to extern to avoid duplicate declarations.
Suppress compiler warning about comparing signed and unsigned vars