Add generic versions of pthread_spin_lock and pthread_spin_trylock.