build: fix some portability issues with pthread.