[libcxx-commits] [libcxx] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)
Hristo Hristov via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Dec 31 04:57:17 PST 2023
================
@@ -208,8 +215,34 @@ _LIBCPP_PUSH_MACROS
#if !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+# if defined(_LIBCPP_WIN32API)
+# define WIN32_LEAN_AND_MEAN
+# define NOMINMAX
+# include <io.h>
+# include <windows.h>
+# endif
+
+// # include <fcntl.h>
+
_LIBCPP_BEGIN_NAMESPACE_STD
+# if _LIBCPP_STD_VER >= 26
+# if defined(_LIBCPP_WIN32API)
+using __filebuf_native_handle_type = HANDLE;
+_LIBCPP_EXPORTED_FROM_ABI __filebuf_native_handle_type __filebuf_windows_native_handle(FILE* __file);
+# else // POSIX
+using __filebuf_native_handle_type = int; // File descriptor
+# endif
+
+_LIBCPP_HIDE_FROM_ABI inline __filebuf_native_handle_type __filebuf_native_handle(FILE* __file) noexcept {
+# if defined(_LIBCPP_WIN32API)
+ return __filebuf_windows_native_handle(__file);
+# else
+ return ::fileno(__file);
+# endif
+}
+# endif
+
----------------
H-G-Hristov wrote:
I assume we don't want to pull in `windows.h` in the header, so I'll need to refactor this.
https://github.com/llvm/llvm-project/pull/76632
More information about the libcxx-commits
mailing list