Cleanup foo.h headers and __config to work in C

llvm-svn: 252274
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 60506cbcd48a905950971f7211ceef1867aa25c8
diff --git a/include/__config b/include/__config
index b7e3532..1fe96d0 100644
--- a/include/__config
+++ b/include/__config
@@ -11,10 +11,16 @@
 #ifndef _LIBCPP_CONFIG
 #define _LIBCPP_CONFIG
 
-#if !defined(_MSC_VER) || defined(__clang__)
+#if defined(_MSC_VER) && !defined(__clang__)
+#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+#endif
+
+#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #pragma GCC system_header
 #endif
 
+#ifdef __cplusplus
+
 #ifdef __GNUC__
 #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
 #else
@@ -526,7 +532,6 @@
 #elif defined(_LIBCPP_MSVC)
 
 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
@@ -811,4 +816,6 @@
 #define _LIBCPP_HAS_NO_ATOMIC_HEADER
 #endif
 
+#endif // __cplusplus
+
 #endif // _LIBCPP_CONFIG
diff --git a/include/errno.h b/include/errno.h
index 556ef61..ee64291 100644
--- a/include/errno.h
+++ b/include/errno.h
@@ -31,6 +31,8 @@
 
 #include_next <errno.h>
 
+#ifdef __cplusplus
+
 #if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
 
 #ifdef ELAST
@@ -391,4 +393,6 @@
 #define EMLINK 9979
 #endif
 
+#endif // __cplusplus
+
 #endif  // _LIBCPP_ERRNO_H
diff --git a/include/float.h b/include/float.h
index f890c68..1acfdc6 100644
--- a/include/float.h
+++ b/include/float.h
@@ -68,6 +68,8 @@
 
 #include_next <float.h>
 
+#ifdef __cplusplus
+
 #ifndef FLT_EVAL_METHOD
 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
 #endif
@@ -76,4 +78,6 @@
 #define DECIMAL_DIG __DECIMAL_DIG__
 #endif
 
+#endif // __cplusplus
+
 #endif  // _LIBCPP_FLOAT_H
diff --git a/include/inttypes.h b/include/inttypes.h
index 328e57e..5c5618b 100644
--- a/include/inttypes.h
+++ b/include/inttypes.h
@@ -246,6 +246,6 @@
 #undef imaxabs
 #undef imaxdiv
 
-#endif
+#endif // __cplusplus
 
 #endif  // _LIBCPP_INTTYPES_H
diff --git a/include/setjmp.h b/include/setjmp.h
index ec4a5f6..464b4a5 100644
--- a/include/setjmp.h
+++ b/include/setjmp.h
@@ -34,8 +34,12 @@
 
 #include_next <setjmp.h>
 
+#ifdef __cplusplus
+
 #ifndef setjmp
 #define setjmp(env) setjmp(env)
 #endif
 
+#endif // __cplusplus
+
 #endif  // _LIBCPP_SETJMP_H
diff --git a/include/stdlib.h b/include/stdlib.h
index 919faa1..12fd676 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -94,6 +94,7 @@
 #include_next <stdlib.h>
 
 #ifdef __cplusplus
+
 extern "C++" {
 
 #ifdef _LIBCPP_MSVCRT
@@ -123,6 +124,7 @@
 #endif // _LIBCPP_MSVCRT / __sun__ / _AIX
 
 }  // extern "C++"
+
 #endif  // __cplusplus
 
 #endif  // _LIBCPP_STDLIB_H