Skip to content

Commit

Permalink
3rdparty: Update WIL to v1.0.240803.1
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanTheToaster authored and F0bes committed Dec 6, 2024
1 parent caaa351 commit 3f1df0e
Show file tree
Hide file tree
Showing 15 changed files with 395 additions and 284 deletions.
330 changes: 193 additions & 137 deletions 3rdparty/winwil/include/wil/Tracelogging.h

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions 3rdparty/winwil/include/wil/com.h
Original file line number Diff line number Diff line change
Expand Up @@ -2398,7 +2398,7 @@ RETURN_IF_FAILED(wil::stream_seek_nothrow(source, LLONG_MAX, STREAM_SEEK_CUR));
@param stream The stream to seek
@param offset The position, in bytes from the current position, to seek
@param from The starting point from which to seek, from the STREAM_SEEK_* set of values
@param value Optionally recieves the new absolute position from the stream
@param value Optionally receives the new absolute position from the stream
*/
inline HRESULT stream_seek_nothrow(_In_ IStream* stream, long long offset, unsigned long from, _Out_opt_ unsigned long long* value = nullptr)
{
Expand All @@ -2418,7 +2418,7 @@ RETURN_HR(wil::stream_set_position_nothrow(source, 16));
~~~~
@param stream The stream whose size is to be returned in `value`
@param offset The position, in bytes from the start of the stream, to seek to
@param value Optionally recieves the new absolute position from the stream
@param value Optionally receives the new absolute position from the stream
*/
inline HRESULT stream_set_position_nothrow(_In_ IStream* stream, unsigned long long offset, _Out_opt_ unsigned long long* value = nullptr)
{
Expand Down Expand Up @@ -2888,7 +2888,7 @@ if (wcscmp(content.get(), L"waffles") == 0)
@endcode
@param source The stream from which to read a string
@param options Controls the behavior when reading a zero-length string
@return An non-null string (but possibly zero lengh) string read from `source`
@return An non-null string (but possibly zero length) string read from `source`
*/
inline wil::unique_cotaskmem_string stream_read_string(_In_ ISequentialStream* source, empty_string_options options = empty_string_options::returns_empty)
{
Expand Down
31 changes: 17 additions & 14 deletions 3rdparty/winwil/include/wil/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ to be able to layer additional functionality into other libraries by their mere
of initialization should be used whenever they are available.
~~~~
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
WI_HEADER_INITITALIZATION_FUNCTION(InitializeDesktopFamilyApis, []
WI_HEADER_INITIALIZATION_FUNCTION(InitializeDesktopFamilyApis, []
{
g_pfnGetModuleName = GetCurrentModuleName;
g_pfnFailFastInLoaderCallout = FailFastInLoaderCallout;
Expand All @@ -537,16 +537,16 @@ WI_HEADER_INITITALIZATION_FUNCTION(InitializeDesktopFamilyApis, []
The above example is used within WIL to decide whether or not the library containing WIL is allowed to use
desktop APIs. Building this functionality as `#IFDEF`s within functions would create ODR violations, whereas
doing it with global function pointers and header initialization allows a runtime determination. */
#define WI_HEADER_INITITALIZATION_FUNCTION(name, fn)
#define WI_HEADER_INITIALIZATION_FUNCTION(name, fn)
#elif defined(_M_IX86)
#define WI_HEADER_INITITALIZATION_FUNCTION(name, fn) \
#define WI_HEADER_INITIALIZATION_FUNCTION(name, fn) \
extern "C" \
{ \
__declspec(selectany) unsigned char g_header_init_##name = static_cast<unsigned char>(fn()); \
} \
__pragma(comment(linker, "/INCLUDE:_g_header_init_" #name))
#elif defined(_M_IA64) || defined(_M_AMD64) || defined(_M_ARM) || defined(_M_ARM64)
#define WI_HEADER_INITITALIZATION_FUNCTION(name, fn) \
#define WI_HEADER_INITIALIZATION_FUNCTION(name, fn) \
extern "C" \
{ \
__declspec(selectany) unsigned char g_header_init_##name = static_cast<unsigned char>(fn()); \
Expand All @@ -556,6 +556,9 @@ doing it with global function pointers and header initialization allows a runtim
#error linker pragma must include g_header_init variation
#endif

// Keep the misspelled name for backward compatibility.
#define WI_HEADER_INITITALIZATION_FUNCTION(name, fn) WI_HEADER_INITIALIZATION_FUNCTION(name, fn)

/** All Windows Implementation Library classes and functions are located within the "wil" namespace.
The 'wil' namespace is an intentionally short name as the intent is for code to be able to reference
the namespace directly (example: `wil::srwlock lock;`) without a using statement. Resist adding a using
Expand Down Expand Up @@ -687,32 +690,32 @@ boolean, BOOLEAN, and classes with an explicit bool cast.
@param val The logical bool expression
@return A C++ bool representing the evaluation of `val`. */
template <typename T, __R_ENABLE_IF_IS_CLASS(T)>
_Post_satisfies_(return == static_cast<bool>(val)) __forceinline constexpr bool verify_bool(const T& val)
_Post_satisfies_(return == static_cast<bool>(val)) __forceinline constexpr bool verify_bool(const T& val) WI_NOEXCEPT
{
return static_cast<bool>(val);
}

template <typename T, __R_ENABLE_IF_IS_NOT_CLASS(T)>
__forceinline constexpr bool verify_bool(T /*val*/)
__forceinline constexpr bool verify_bool(T /*val*/) WI_NOEXCEPT
{
static_assert(!wistd::is_same<T, T>::value, "Wrong Type: bool/BOOL/BOOLEAN/boolean expected");
return false;
}

template <>
_Post_satisfies_(return == val) __forceinline constexpr bool verify_bool<bool>(bool val)
_Post_satisfies_(return == val) __forceinline constexpr bool verify_bool<bool>(bool val) WI_NOEXCEPT
{
return val;
}

template <>
_Post_satisfies_(return == (val != 0)) __forceinline constexpr bool verify_bool<int>(int val)
_Post_satisfies_(return == (val != 0)) __forceinline constexpr bool verify_bool<int>(int val) WI_NOEXCEPT
{
return (val != 0);
}

template <>
_Post_satisfies_(return == (val != 0)) __forceinline constexpr bool verify_bool<unsigned char>(unsigned char val)
_Post_satisfies_(return == (val != 0)) __forceinline constexpr bool verify_bool<unsigned char>(unsigned char val) WI_NOEXCEPT
{
return (val != 0);
}
Expand All @@ -723,7 +726,7 @@ accept any `int` value as long as that is the underlying typedef behind `BOOL`.
@param val The Win32 BOOL returning expression
@return A Win32 BOOL representing the evaluation of `val`. */
template <typename T>
_Post_satisfies_(return == val) __forceinline constexpr int verify_BOOL(T val)
_Post_satisfies_(return == val) __forceinline constexpr int verify_BOOL(T val) WI_NOEXCEPT
{
// Note: Written in terms of 'int' as BOOL is actually: typedef int BOOL;
static_assert((wistd::is_same<T, int>::value), "Wrong Type: BOOL expected");
Expand Down Expand Up @@ -752,7 +755,7 @@ RETURN_HR_IF(static_cast<HRESULT>(UIA_E_NOTSUPPORTED), (patternId != UIA_DragPat
@param hr The HRESULT returning expression
@return An HRESULT representing the evaluation of `val`. */
template <typename T>
_Post_satisfies_(return == hr) inline constexpr long verify_hresult(T hr)
_Post_satisfies_(return == hr) inline constexpr long verify_hresult(T hr) WI_NOEXCEPT
{
// Note: Written in terms of 'long' as HRESULT is actually: typedef _Return_type_success_(return >= 0) long HRESULT
static_assert(wistd::is_same<T, long>::value, "Wrong Type: HRESULT expected");
Expand Down Expand Up @@ -781,7 +784,7 @@ NT_RETURN_IF_FALSE(static_cast<NTSTATUS>(STATUS_NOT_SUPPORTED), (dispatch->Versi
@param status The NTSTATUS returning expression
@return An NTSTATUS representing the evaluation of `val`. */
template <typename T>
_Post_satisfies_(return == status) inline long verify_ntstatus(T status)
_Post_satisfies_(return == status) inline long verify_ntstatus(T status) WI_NOEXCEPT
{
// Note: Written in terms of 'long' as NTSTATUS is actually: typedef _Return_type_success_(return >= 0) long NTSTATUS
static_assert(wistd::is_same<T, long>::value, "Wrong Type: NTSTATUS expected");
Expand All @@ -795,7 +798,7 @@ commonly used when manipulating Win32 error codes.
@param error The Win32 error code returning expression
@return An Win32 error code representing the evaluation of `error`. */
template <typename T>
_Post_satisfies_(return == error) inline T verify_win32(T error)
_Post_satisfies_(return == error) inline T verify_win32(T error) WI_NOEXCEPT
{
// Note: Win32 error code are defined as 'long' (#define ERROR_SUCCESS 0L), but are more frequently used as DWORD (unsigned
// long). This accept both types.
Expand All @@ -810,7 +813,7 @@ _Post_satisfies_(return == error) inline T verify_win32(T error)
// Implementation details for macros and helper functions... do not use directly.
namespace details
{
// Use size-specific casts to avoid sign extending numbers -- avoid warning C4310: cast truncates constant value
// Use size-specific casts to avoid sign extending numbers -- avoid warning C4310: cast truncates constant value
#define __WI_MAKE_UNSIGNED(val) \
(__pragma(warning(push)) __pragma(warning(disable : 4310 4309))( \
sizeof(val) == 1 ? static_cast<unsigned char>(val) \
Expand Down
10 changes: 5 additions & 5 deletions 3rdparty/winwil/include/wil/coroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ struct com_task;
/// @cond
namespace wil::details::coro
{
// task and com_task are convertable to each other. However, not
// task and com_task are convertible to each other. However, not
// all consumers of this header have COM enabled. Support for saving
// COM thread-local error information and restoring it on the resuming
// thread is enabled using these function pointers. If COM is not
Expand Down Expand Up @@ -764,8 +764,8 @@ inline void __stdcall DestroyRestrictedErrorInformation(_In_ void* restricted_er

struct apartment_info
{
APTTYPE aptType;
APTTYPEQUALIFIER aptTypeQualifier;
APTTYPE aptType{};
APTTYPEQUALIFIER aptTypeQualifier{};

void load()
{
Expand Down Expand Up @@ -814,7 +814,7 @@ struct apartment_resumer

__WI_COROUTINE_NAMESPACE::coroutine_handle<> waiter;
wil::com_ptr<IContextCallback> context{nullptr};
apartment_info info;
apartment_info info{};
HRESULT resume_result = S_OK;

void capture_context(__WI_COROUTINE_NAMESPACE::coroutine_handle<> handle)
Expand Down Expand Up @@ -925,7 +925,7 @@ auto task_base<T>::resume_same_apartment() && noexcept

// This section is lit up when COM headers are available. Initialize the global function
// pointers such that error information can be saved and restored across thread boundaries.
WI_HEADER_INITITALIZATION_FUNCTION(CoroutineRestrictedErrorInitialize, [] {
WI_HEADER_INITIALIZATION_FUNCTION(CoroutineRestrictedErrorInitialize, [] {
::wil::details::coro::g_pfnCaptureRestrictedErrorInformation = ::wil::details::coro::CaptureRestrictedErrorInformation;
::wil::details::coro::g_pfnRestoreRestrictedErrorInformation = ::wil::details::coro::RestoreRestrictedErrorInformation;
::wil::details::coro::g_pfnDestroyRestrictedErrorInformation = ::wil::details::coro::DestroyRestrictedErrorInformation;
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/winwil/include/wil/cppwinrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ namespace details
{
#ifndef CPPWINRT_SUPPRESS_STATIC_INITIALIZERS
WI_ODR_PRAGMA("CPPWINRT_SUPPRESS_STATIC_INITIALIZERS", "0")
WI_HEADER_INITITALIZATION_FUNCTION(WilInitialize_CppWinRT, [] {
WI_HEADER_INITIALIZATION_FUNCTION(WilInitialize_CppWinRT, [] {
::wil::WilInitialize_CppWinRT();
return 1;
});
Expand Down
24 changes: 12 additions & 12 deletions 3rdparty/winwil/include/wil/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ next_entry_offset_iterator<T> create_next_entry_offset_iterator(T* p)

enum class FolderChangeEvent : DWORD
{
ChangesLost = 0, // requies special handling, reset state as events were lost
ChangesLost = 0, // requires special handling, reset state as events were lost
Added = FILE_ACTION_ADDED,
Removed = FILE_ACTION_REMOVED,
Modified = FILE_ACTION_MODIFIED,
Expand Down Expand Up @@ -1122,9 +1122,9 @@ struct file_and_error_result
DWORD last_error{};
};

/** Non-throwing open existing using OPEN_EXISTING.
/** Non-throwing open existing using OPEN_EXISTING, returns handle and error code.
~~~
auto handle = wil::try_open_file(filePath.c_str());
auto [handle, error] = wil::try_open_file(filePath.c_str());
~~~
*/
inline file_and_error_result try_open_file(
Expand All @@ -1150,7 +1150,7 @@ inline wil::unique_hfile open_file(
DWORD dwDesiredAccess = GENERIC_READ,
DWORD dwShareMode = FILE_SHARE_READ,
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
bool inheritHandle = false) noexcept
bool inheritHandle = false)
{
auto result = try_open_file(path, dwDesiredAccess, dwShareMode, dwFlagsAndAttributes, inheritHandle);
THROW_WIN32_IF(result.last_error, !result.file.is_valid());
Expand All @@ -1173,7 +1173,7 @@ namespace details

/** create using CREATE_NEW, returns handle and error code.
~~~
auto [handle, error = wil::try_create_new_file(filePath.c_str());
auto [handle, error] = wil::try_create_new_file(filePath.c_str());
~~~
*/
inline file_and_error_result try_create_new_file(
Expand All @@ -1189,7 +1189,7 @@ inline file_and_error_result try_create_new_file(

/** create using OPEN_ALWAYS, returns handle and error code.
~~~
auto [handle, error = wil::try_open_or_create_file(filePath.c_str());
auto [handle, error] = wil::try_open_or_create_file(filePath.c_str());
~~~
*/
inline file_and_error_result try_open_or_create_file(
Expand All @@ -1205,7 +1205,7 @@ inline file_and_error_result try_open_or_create_file(

/** create using CREATE_ALWAYS, returns handle and error code.
~~~
auto [handle, error = wil::try_open_or_truncate_existing_file(filePath.c_str());
auto [handle, error] = wil::try_open_or_truncate_existing_file(filePath.c_str());
~~~
*/
inline file_and_error_result try_open_or_truncate_existing_file(
Expand All @@ -1221,7 +1221,7 @@ inline file_and_error_result try_open_or_truncate_existing_file(

/** create using TRUNCATE_EXISTING, returns handle and error code.
~~~
auto [handle, error = wil::try_truncate_existing_file(filePath.c_str());
auto [handle, error] = wil::try_truncate_existing_file(filePath.c_str());
~~~
*/
inline file_and_error_result try_truncate_existing_file(
Expand All @@ -1247,7 +1247,7 @@ inline wil::unique_hfile create_new_file(
DWORD dwShareMode = FILE_SHARE_READ,
LPSECURITY_ATTRIBUTES lpSecurityAttributes = nullptr,
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
HANDLE hTemplateFile = nullptr) noexcept
HANDLE hTemplateFile = nullptr)
{
auto result = try_create_new_file(path, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwFlagsAndAttributes, hTemplateFile);
THROW_WIN32_IF(result.last_error, !result.file.is_valid());
Expand All @@ -1265,7 +1265,7 @@ inline wil::unique_hfile open_or_create_file(
DWORD dwShareMode = FILE_SHARE_READ,
LPSECURITY_ATTRIBUTES lpSecurityAttributes = nullptr,
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
HANDLE hTemplateFile = nullptr) noexcept
HANDLE hTemplateFile = nullptr)
{
auto result = try_open_or_create_file(path, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwFlagsAndAttributes, hTemplateFile);
THROW_WIN32_IF(result.last_error, !result.file.is_valid());
Expand All @@ -1283,7 +1283,7 @@ inline wil::unique_hfile open_or_truncate_existing_file(
DWORD dwShareMode = FILE_SHARE_READ,
LPSECURITY_ATTRIBUTES lpSecurityAttributes = nullptr,
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
HANDLE hTemplateFile = nullptr) noexcept
HANDLE hTemplateFile = nullptr)
{
auto result = try_open_or_truncate_existing_file(
path, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwFlagsAndAttributes, hTemplateFile);
Expand All @@ -1302,7 +1302,7 @@ inline wil::unique_hfile truncate_existing_file(
DWORD dwShareMode = FILE_SHARE_READ,
LPSECURITY_ATTRIBUTES lpSecurityAttributes = nullptr,
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
HANDLE hTemplateFile = nullptr) noexcept
HANDLE hTemplateFile = nullptr)
{
auto result =
try_truncate_existing_file(path, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwFlagsAndAttributes, hTemplateFile);
Expand Down
Loading

0 comments on commit 3f1df0e

Please sign in to comment.