Issue #10062: Allow building on platforms which do not have sem_timedwait.
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index a529b7a..c007c8b 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -64,7 +64,8 @@
 /* Whether or not to use semaphores directly rather than emulating them with
  * mutexes and condition variables:
  */
-#if defined(_POSIX_SEMAPHORES) && !defined(HAVE_BROKEN_POSIX_SEMAPHORES)
+#if (defined(_POSIX_SEMAPHORES) && !defined(HAVE_BROKEN_POSIX_SEMAPHORES) && \
+     defined(HAVE_SEM_TIMEDWAIT))
 #  define USE_SEMAPHORES
 #else
 #  undef USE_SEMAPHORES