diff --git a/libavutil/atomic.c b/libavutil/atomic.c
index 04182f2330b226b46db76de1cea70aa470969ad6..b7b3872d6ce7d7c5978661f491120b289cdecba3 100644
--- a/libavutil/atomic.c
+++ b/libavutil/atomic.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
 #include "atomic.h"
 
 #if !HAVE_ATOMICS_NATIVE
@@ -102,7 +103,7 @@ void *avpriv_atomic_ptr_cas(void * volatile *ptr, void *oldval, void *newval)
 
 #endif /* HAVE_PTHREADS */
 
-#endif /* !HAVE_MEMORYBARRIER && !HAVE_SYNC_VAL_COMPARE_AND_SWAP && !HAVE_MACHINE_RW_BARRIER */
+#endif /* !HAVE_ATOMICS_NATIVE */
 
 #ifdef TEST
 #include "avassert.h"
diff --git a/libavutil/atomic.h b/libavutil/atomic.h
index fd7d8fc03e0b9aea0de4d061ab706cf034573228..15906d24c9cb8ba573edf0b55e6eef335b2e59f8 100644
--- a/libavutil/atomic.h
+++ b/libavutil/atomic.h
@@ -23,12 +23,16 @@
 
 #include "config.h"
 
+#if HAVE_ATOMICS_NATIVE
+
 #if HAVE_ATOMICS_GCC
 #include "atomic_gcc.h"
 #elif HAVE_ATOMICS_WIN32
 #include "atomic_win32.h"
 #elif HAVE_ATOMICS_SUNCC
 #include "atomic_suncc.h"
+#endif
+
 #else
 
 /**
@@ -70,5 +74,6 @@ int avpriv_atomic_int_add_and_fetch(volatile int *ptr, int inc);
  */
 void *avpriv_atomic_ptr_cas(void * volatile *ptr, void *oldval, void *newval);
 
-#endif /* HAVE_MEMORYBARRIER */
+#endif /* HAVE_ATOMICS_NATIVE */
+
 #endif /* AVUTIL_ATOMIC_H */