From 16b1ac950b5fb796e4c126ce451d34d3ceefe155 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Thu, 27 Apr 2017 01:47:22 +0000 Subject: [PATCH] Darwin: Define __STDC_NO_THREADS__ on Darwin targets Darwin doesn't support C11 threads.h. Define `__STDC_NO_THREADS__` so that users can check for it. rdar://problem/18461003 llvm-svn: 301508 --- clang/lib/Basic/Targets.cpp | 1 + clang/test/Preprocessor/init.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index d7f1793e377c..78b03b1c314a 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -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. diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c index 5fb2011cd025..36ef9b213658 100644 --- a/clang/test/Preprocessor/init.c +++ b/clang/test/Preprocessor/init.c @@ -9690,3 +9690,12 @@ // 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