]> granicus.if.org Git - clang/commitdiff
Darwin: Define __STDC_NO_THREADS__ on Darwin targets
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 27 Apr 2017 01:47:22 +0000 (01:47 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 27 Apr 2017 01:47:22 +0000 (01:47 +0000)
Darwin doesn't support C11 threads.h.  Define `__STDC_NO_THREADS__` so
that users can check for it.

rdar://problem/18461003

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301508 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets.cpp
test/Preprocessor/init.c

index d7f1793e377ca96207cba9f362c06622d7bdf526..78b03b1c314a5118a78dd4ee10a736656834bfe5 100644 (file)
@@ -117,6 +117,7 @@ static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
                              VersionTuple &PlatformMinVersion) {
   Builder.defineMacro("__APPLE_CC__", "6000");
   Builder.defineMacro("__APPLE__");
+  Builder.defineMacro("__STDC_NO_THREADS__");
   Builder.defineMacro("OBJC_NEW_PROPERTIES");
   // AddressSanitizer doesn't play well with source fortification, which is on
   // by default on Darwin.
index 5fb2011cd02508245d17cc6e64cbb32d21ff8c3e..36ef9b213658e7244177c9261abb1acbd600cd9c 100644 (file)
 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_SHORT_LOCK_FREE 2
 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
 // MSVC-X86-NOT:#define __GCC_ATOMIC{{.*}}
+
+// RUN: %clang_cc1 -E -dM -ffreestanding                \
+// RUN:   -triple=aarch64-apple-ios9 < /dev/null        \
+// RUN: | FileCheck -check-prefix=DARWIN %s
+// RUN: %clang_cc1 -E -dM -ffreestanding                \
+// RUN:   -triple=aarch64-apple-macosx10.12 < /dev/null \
+// RUN: | FileCheck -check-prefix=DARWIN %s
+
+// DARWIN:#define __STDC_NO_THREADS__ 1