[libc++] Respect Windows Store app CRT restrictions
Some CRT APIs are unavailable for Windows Store apps [1]. Detect when
we're targeting the Windows Store and don't try to refer to non-existent
CRT functions in that case. (This would otherwise lead to a compile
error when using the libc++ headers and compiling for Windows Store.)
[1] https://docs.microsoft.com/en-us/cpp/cppcx/crt-functions-not-supported-in-universal-windows-platform-apps
Differential Revision: https://reviews.llvm.org/D31737
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@299625 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/__config b/include/__config
index 5199414..aab774d 100644
--- a/include/__config
+++ b/include/__config
@@ -211,6 +211,16 @@
# if defined(_LIBCPP_MSVCRT)
# define _LIBCPP_HAS_QUICK_EXIT
# endif
+
+// Some CRT APIs are unavailable to store apps
+#if defined(WINAPI_FAMILY)
+#include <winapifamily.h>
+#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \
+ (!defined(WINAPI_PARTITION_SYSTEM) || \
+ !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
+#define _LIBCPP_WINDOWS_STORE_APP
+#endif
+#endif
#endif // defined(_WIN32)
#ifdef __sun__
diff --git a/include/cstdlib b/include/cstdlib
index 2ca25ed..78c4284 100644
--- a/include/cstdlib
+++ b/include/cstdlib
@@ -130,8 +130,10 @@
using ::atexit;
using ::exit;
using ::_Exit;
+#ifndef _LIBCPP_WINDOWS_STORE_APP
using ::getenv;
using ::system;
+#endif
using ::bsearch;
using ::qsort;
using ::abs;