Merge pull request #21293 from compnerd/msvcrt-fileio

Platform: make MSVCRT more Unix-libc like
diff --git a/stdlib/public/Platform/Platform.swift b/stdlib/public/Platform/Platform.swift
index 3da7dd9..25c19c2 100644
--- a/stdlib/public/Platform/Platform.swift
+++ b/stdlib/public/Platform/Platform.swift
@@ -13,6 +13,10 @@
 import SwiftShims
 import SwiftOverlayShims
 
+#if os(Windows)
+import ucrt
+#endif
+
 #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
 //===----------------------------------------------------------------------===//
 // MacTypes.h
@@ -132,6 +136,14 @@
     return vsnprintf(ptr, len, format, va_args)
   }
 }
+#elseif os(Windows)
+public var stdin: UnsafeMutablePointer<FILE> { return __acrt_iob_func(0) }
+public var stdout: UnsafeMutablePointer<FILE> { return __acrt_iob_func(1) }
+public var stderr: UnsafeMutablePointer<FILE> { return __acrt_iob_func(2) }
+
+public var STDIN_FILENO: Int32 { return _fileno(stdin) }
+public var STDOUT_FILENO: Int32 { return _fileno(stdout) }
+public var STDERR_FILENO: Int32 { return _fileno(stderr) }
 #endif
 
 
diff --git a/stdlib/public/Platform/ucrt.modulemap b/stdlib/public/Platform/ucrt.modulemap
index ef30fff..9188f34 100644
--- a/stdlib/public/Platform/ucrt.modulemap
+++ b/stdlib/public/Platform/ucrt.modulemap
@@ -111,6 +111,7 @@
 
   module corecrt {
     header "corecrt.h"
+    header "corecrt_stdio_config.h"
     export *
 
     module io {
@@ -122,6 +123,11 @@
       header "corecrt_math.h"
       export *
     }
+
+    module stdio {
+      header "corecrt_wstdio.h"
+      export *
+    }
   }
 }