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	2022-12-07 05:31:21.000000000 +1100
+++ configure	2022-12-07 12:09:12.000000000 +1100
@@ -17359,6 +17359,24 @@
     int main(void) {
       __atomic_store_n(&val, 1, __ATOMIC_SEQ_CST);
       (void)__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;
     }
 
