diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 4356b3219207bbf26fb59a737bcea4c0e5b1a1ff..73d96fca1a2bf3c1bbf99fc750d23a6e6281f862 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -34,9 +34,11 @@
 #if HAVE_SCHED_GETAFFINITY
 #define _GNU_SOURCE
 #include <sched.h>
-#elif HAVE_GETSYSTEMINFO
+#endif
+#if HAVE_GETSYSTEMINFO
 #include <windows.h>
-#elif HAVE_SYSCTL
+#endif
+#if HAVE_SYSCTL
 #if HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif