https://trac.macports.org/ticket/49272
https://bugs.python.org/issue24844

Compiling python fails in Xcode 4 (clang < 3.3) where existence of 'atomic'
is detected by configure, but it is not fully functional.

--- configure.orig
+++ configure
@@ -16240,6 +16242,24 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
     volatile int val = 1;
     int main() {
       __atomic_load_n(&val, __ATOMIC_SEQ_CST);
+
+      // https://bugs.python.org/issue24844
+      #define VERSION_CHECK(cc_major, cc_minor, req_major, req_minor) \
+          ((cc_major) > (req_major) || \
+          (cc_major) == (req_major) && (cc_minor) >= (req_minor))
+      #if defined(__clang__)
+          #if defined(__apple_build_version__)
+              // either one test or the other should work
+              // #if __apple_build_version__ < 5000000
+              #if !VERSION_CHECK(__clang_major__, __clang_minor__, 5, 0)
+                  #error
+              #endif
+          // not sure if this is 3.3 or 3.4
+          #elif !VERSION_CHECK(__clang_major__, __clang_minor__, 3, 3)
+              #error
+          #endif
+      #endif
+
       return 0;
     }
 
