[PATCH] D99483: [clang][AIX] Define __STDC_NO_ATOMICS__ for c11 and above

David Tenty via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 28 21:46:49 PDT 2021


daltenty created this revision.
Herald added a subscriber: jfb.
daltenty requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The libc implementation on AIX does not have stdatomic.h and the requisite interfaces for c11 atomics, so for now it's better to set __STDC_NO_ATOMICS__


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99483

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/aix-nocatomics.c


Index: clang/test/Preprocessor/aix-nocatomics.c
===================================================================
--- /dev/null
+++ clang/test/Preprocessor/aix-nocatomics.c
@@ -0,0 +1,19 @@
+// The AIX library implementation of C11 atomics is incomplete, so test that the
+// appropriate macro is set.
+
+// 32-bit cases.
+// RUN: %clang_cc1 -E -dM -triple=powerpc-ibm-aix7.1.0.0 -std=c11 < /dev/null | FileCheck -match-full-lines %s
+// RUN: %clang_cc1 -E -dM -triple=powerpc-ibm-aix7.1.0.0 -std=c17 < /dev/null | FileCheck -match-full-lines %s
+// RUN: %clang_cc1 -E -dM -triple=powerpc-ibm-aix7.1.0.0 -std=c2x < /dev/null | FileCheck -match-full-lines %s
+
+// 64-bit cases.
+// RUN: %clang_cc1 -E -dM -triple=powerpc64-ibm-aix7.1.0.0 -std=c11 < /dev/null | FileCheck -match-full-lines %s
+// RUN: %clang_cc1 -E -dM -triple=powerpc64-ibm-aix7.1.0.0 -std=c17 < /dev/null | FileCheck -match-full-lines %s
+// RUN: %clang_cc1 -E -dM -triple=powerpc64-ibm-aix7.1.0.0 -std=c2x < /dev/null | FileCheck -match-full-lines %s
+
+// CHECK:#define __STDC_NO_ATOMICS__ 1
+
+// Check that it's not set for C before 11.
+// RUN: %clang_cc1 -E -dM -triple=powerpc64-ibm-aix7.1.0.0 -std=c99 < /dev/null | FileCheck -match-full-lines -check-prefix C99 %s
+
+// C99-NOT:#define __STDC_NO_ATOMICS__ 1
Index: clang/lib/Basic/Targets/OSTargets.h
===================================================================
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -722,6 +722,11 @@
     if (Opts.CPlusPlus && Opts.WChar) {
       Builder.defineMacro("_WCHAR_T");
     }
+
+    // The AIX library implementation of C11 atomics is not yet complete.
+    if (Opts.C11 || Opts.C17 || Opts.C2x) {
+      Builder.defineMacro("__STDC_NO_ATOMICS__");
+    }
   }
 
 public:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99483.333764.patch
Type: text/x-patch
Size: 1783 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210329/c522567c/attachment.bin>


More information about the cfe-commits mailing list