1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 #if defined(_LIBCPP_WIN32API)
14 # define WIN32_LEAN_AND_MEAN
20 _LIBCPP_BEGIN_NAMESPACE_STD
22 #if defined(_LIBCPP_WIN32API)
24 // Confirm that `HANDLE` is `void*` as implemented in `basic_filebuf`
25 static_assert(std::same_as
<HANDLE
, void*>);
27 _LIBCPP_EXPORTED_FROM_ABI
void* __filebuf_windows_native_handle(FILE* __file
) noexcept
{
28 // https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/get-osfhandle?view=msvc-170
29 intptr_t __handle
= _get_osfhandle(fileno(__file
));
32 return reinterpret_cast<void*>(__handle
);
37 _LIBCPP_END_NAMESPACE_STD