[libc++] Add missing __has_include checks for C headers not provided by libc++

This makes the library consistent in how it handles C library headers. For C headers provided by libc++,
we unconditionally include <foo.h> from <cfoo>, and then <foo.h> conditionally include_next <foo.h>.
For headers not provided by libc++, <cfoo> conditionally includes the system's <foo.h> directly.

Differential Revision: https://reviews.llvm.org/D138512
diff --git a/libcxx/include/ctime b/libcxx/include/ctime
index 0c6e4df..2293675 100644
--- a/libcxx/include/ctime
+++ b/libcxx/include/ctime
@@ -47,7 +47,14 @@
 
 #include <__assert> // all public C++ headers provide the assertion handler
 #include <__config>
-#include <time.h>
+
+// <time.h> is not provided by libc++
+#if __has_include(<time.h>)
+#  include <time.h>
+#  ifdef _LIBCPP_TIME_H
+#    error "If libc++ starts defining <time.h>, the __has_include check should move to libc++'s <time.h>"
+#  endif
+#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header