Protect use of pthread functions with #ifdef HAVE_PTHREAD_H.