Index: include/__config =================================================================== --- include/__config +++ include/__config @@ -901,6 +901,18 @@ defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) # define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ # endif +# if !defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \ + defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) +# define __IPHONE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ +# endif +# if !defined(__WATCH_OS_VERSION_MIN_REQUIRED) && \ + defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) +# define __WATCH_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ +# endif +# if !defined(__TV_OS_VERSION_MIN_REQUIRED) && \ + defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) +# define __TV_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ +# endif # if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) # if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060 # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION Index: include/__threading_support =================================================================== --- include/__threading_support +++ include/__threading_support @@ -23,6 +23,15 @@ # include <__external_threading> #elif !defined(_LIBCPP_HAS_NO_THREADS) +#if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101300)) \ + || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (__IPHONE_OS_VERSION_MIN_REQUIRED < 110000)) \ + || (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && (__WATCH_OS_VERSION_MIN_REQUIRED < 40000)) \ + || (defined(__TV_OS_VERSION_MIN_REQUIRED) && (__TV_OS_VERSION_MIN_REQUIRED < 110000)) +# if defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE) +# warning "Define _DARWIN_C_SOURCE (or undefine _POSIX_C_SOURCE) for threading support." +# endif +#endif + #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) # include # include Index: test/libcxx/posix_source.sh.cpp =================================================================== --- /dev/null +++ test/libcxx/posix_source.sh.cpp @@ -0,0 +1,29 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Test that we get a warning when using the threading support header without +// the right defines present. + +// REQUIRES: apple-darwin +// UNSUPPORTED: libcpp-has-no-threads + +// RUN: %cxx -c %s -o /dev/null %compile_flags -arch x86_64 -mmacosx-version-min=10.12 -D_LIBCPP_DISABLE_AVAILABILITY 2>&1 | not grep "warning" +// RUN: %cxx -c %s -o /dev/null %compile_flags -arch x86_64 -mmacosx-version-min=10.12 -D_LIBCPP_DISABLE_AVAILABILITY -D_POSIX_C_SOURCE=200112L 2>&1 | grep "warning" | grep "Define _DARWIN_C_SOURCE" +// RUN: %cxx -c %s -o /dev/null %compile_flags -arch x86_64 -mmacosx-version-min=10.12 -D_LIBCPP_DISABLE_AVAILABILITY -D_POSIX_C_SOURCE=200112L -D_DARWIN_C_SOURCE 2>&1 | not grep "warning" + +// RUN: %cxx -c %s -o /dev/null %compile_flags -arch x86_64 -mmacosx-version-min=10.13 -D_LIBCPP_DISABLE_AVAILABILITY 2>&1 | not grep "warning" +// RUN: %cxx -c %s -o /dev/null %compile_flags -arch x86_64 -mmacosx-version-min=10.13 -D_LIBCPP_DISABLE_AVAILABILITY -D_POSIX_C_SOURCE=200112L 2>&1 | not grep "warning" +// RUN: %cxx -c %s -o /dev/null %compile_flags -arch x86_64 -mmacosx-version-min=10.13 -D_LIBCPP_DISABLE_AVAILABILITY -D_POSIX_C_SOURCE=200112L -D_DARWIN_C_SOURCE 2>&1 | not grep "warning" + +#include + +int main() { + return 0; +}