From 9db6276dce851dc2b6807fc81bffbec2e27acd0b Mon Sep 17 00:00:00 2001 From: Duncan Horn <40036384+dunhor@users.noreply.github.com> Date: Tue, 11 Apr 2023 12:52:38 -0700 Subject: [PATCH] Sync with the OS (#319) * Sync with OS commit b58d62a22e8b065355e83f17d32f446bac7d5e75 * Fix build issues * Fix test * Merge with OS commit 2f20a1d7f273c9242cff4bb642ac0536833c0e75 * Preprocessor fix for Tracelogging.h * EBO to make UBSan happy * Some existing consumers can't consume win32_helpers * Build issue; apparently [[nodiscard]] causes issues with coroutines --- include/wil/Tracelogging.h | 209 +++++++++++++++++++-------------- include/wil/cppwinrt_helpers.h | 2 +- include/wil/token_helpers.h | 1 + tests/ComTests.cpp | 6 +- tests/ResourceTests.cpp | 2 +- tests/wiTest.cpp | 2 +- 6 files changed, 128 insertions(+), 94 deletions(-) diff --git a/include/wil/Tracelogging.h b/include/wil/Tracelogging.h index 0022a9a7e..1348ab597 100644 --- a/include/wil/Tracelogging.h +++ b/include/wil/Tracelogging.h @@ -33,7 +33,6 @@ #ifndef TRACELOGGING_SUPPRESS_NEW #include #endif -#include #pragma warning(push) #pragma warning(disable: 26135) // Missing locking annotation, Caller failing to hold lock @@ -177,28 +176,60 @@ namespace wil public: void __cdecl cleanup() WI_NOEXCEPT { - if (wil::init_once_initialized(m_initOnce)) + void* pVoid; + BOOL pending; + + // If object is being constructed on another thread, wait until construction completes. + // Need a memory barrier here (see get() and ~Completer below) so use the result that we + // get from InitOnceBeginInitialize(..., &pVoid, ...) + if (::InitOnceBeginInitialize(&m_initOnce, INIT_ONCE_CHECK_ONLY, &pending, &pVoid) && !pending) { - reinterpret_cast(m_storage)->~T(); + static_cast(pVoid)->~T(); } } T* get(void(__cdecl *cleanupFunc)(void)) WI_NOEXCEPT { - wil::init_once_failfast(m_initOnce, [=]() -> HRESULT - { - ::new (m_storage) T(); - atexit(cleanupFunc); - reinterpret_cast(m_storage)->Create(); - return S_OK; - }); + void* pVoid{}; + BOOL pending; + if (::InitOnceBeginInitialize(&m_initOnce, 0, &pending, &pVoid) && pending) + { + // Don't do anything non-trivial from DllMain, fail fast. + // Some 3rd party code in IE calls shell functions this way, so we can only enforce + // this in DEBUG. +#ifdef DEBUG + FAIL_FAST_IMMEDIATE_IF_IN_LOADER_CALLOUT(); +#endif - return reinterpret_cast(m_storage); + Completer completer(this); + pVoid = &m_storage; + ::new(pVoid)T(); + atexit(cleanupFunc); // ignore failure (that's what the C runtime does, too) + completer.Succeed(); + } + return static_cast(pVoid); } private: - INIT_ONCE m_initOnce = INIT_ONCE_STATIC_INIT; + INIT_ONCE m_initOnce; alignas(T) BYTE m_storage[sizeof(T)]; + struct Completer + { + static_lazy *m_pSelf; + DWORD m_flags; + + explicit Completer(static_lazy *pSelf) WI_NOEXCEPT : m_pSelf(pSelf), m_flags(INIT_ONCE_INIT_FAILED) { } + void Succeed() WI_NOEXCEPT { m_flags = 0; } + + ~Completer() WI_NOEXCEPT + { + if (m_flags == 0) + { + reinterpret_cast(&m_pSelf->m_storage)->Create(); + } + ::InitOnceComplete(&m_pSelf->m_initOnce, m_flags, &m_pSelf->m_storage); + } + }; }; // This class serves as a simple RAII wrapper around CallContextInfo. It presumes that @@ -1377,7 +1408,9 @@ namespace wil }; #ifdef _GENERIC_PARTB_FIELDS_ENABLED -#define _TLGWRITE_GENERIC_PARTB_FIELDS _GENERIC_PARTB_FIELDS_ENABLED, +#define _TLGWRITE_GENERIC_PARTB_FIELDS , _GENERIC_PARTB_FIELDS_ENABLED +#else +#define _TLGWRITE_GENERIC_PARTB_FIELDS #endif #define DEFINE_TAGGED_TRACELOGGING_EVENT(EventId, ...) \ @@ -1388,14 +1421,14 @@ namespace wil #define DEFINE_TAGGED_TRACELOGGING_EVENT_CV(EventId, ...) \ void EventId(PCSTR correlationVector) \ - { __WI_TraceLoggingWriteTagged(*this, #EventId, _TLGWRITE_GENERIC_PARTB_FIELDS TraceLoggingString(correlationVector, "__TlgCV__"), __VA_ARGS__); } + { __WI_TraceLoggingWriteTagged(*this, #EventId _TLGWRITE_GENERIC_PARTB_FIELDS, TraceLoggingString(correlationVector, "__TlgCV__"), __VA_ARGS__); } #define DEFINE_TAGGED_TRACELOGGING_EVENT_PARAM1(EventId, VarType1, varName1, ...) \ template void EventId(T1 &&varName1) \ { \ __WI_TraceLoggingWriteTagged(*this, #EventId, \ - TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1403,8 +1436,8 @@ namespace wil template void EventId(T1 &&varName1, PCSTR correlationVector) \ { \ __WI_TraceLoggingWriteTagged(*this, #EventId, \ - TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), __VA_ARGS__); \ } @@ -1413,8 +1446,8 @@ namespace wil { \ __WI_TraceLoggingWriteTagged(*this, #EventId, \ TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ - TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1423,8 +1456,8 @@ namespace wil { \ __WI_TraceLoggingWriteTagged(*this, #EventId, \ TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ - TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), __VA_ARGS__); \ } @@ -1434,8 +1467,8 @@ namespace wil __WI_TraceLoggingWriteTagged(*this, #EventId, \ TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ - TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1445,8 +1478,8 @@ namespace wil __WI_TraceLoggingWriteTagged(*this, #EventId, \ TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ - TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), __VA_ARGS__); \ } @@ -1457,8 +1490,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ - TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1470,8 +1503,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ - TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), __VA_ARGS__); \ } @@ -1483,8 +1516,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ - TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1496,8 +1529,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ - TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), __VA_ARGS__); \ } @@ -1510,8 +1543,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ - TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1539,8 +1572,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)), \ - TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1554,8 +1587,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)), \ - TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), __VA_ARGS__); \ } @@ -1570,8 +1603,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)), \ TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)), \ - TraceLoggingValue(static_cast(wistd::forward(varName8)), _wiltlg_STRINGIZE(varName8)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName8)), _wiltlg_STRINGIZE(varName8)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1586,8 +1619,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)), \ TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)), \ - TraceLoggingValue(static_cast(wistd::forward(varName8)), _wiltlg_STRINGIZE(varName8)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName8)), _wiltlg_STRINGIZE(varName8)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), __VA_ARGS__); \ } @@ -1603,8 +1636,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)), \ TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)), \ TraceLoggingValue(static_cast(wistd::forward(varName8)), _wiltlg_STRINGIZE(varName8)), \ - TraceLoggingValue(static_cast(wistd::forward(varName9)), _wiltlg_STRINGIZE(varName9)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName9)), _wiltlg_STRINGIZE(varName9)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1719,16 +1752,16 @@ namespace wil #define DEFINE_TRACELOGGING_EVENT(EventId, ...) \ static void EventId() { \ - TraceLoggingWrite(TraceLoggingType::Provider(), #EventId, \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingWrite(TraceLoggingType::Provider(), #EventId \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } #define DEFINE_TRACELOGGING_EVENT_CV(EventId, ...) \ static void EventId(PCSTR correlationVector) \ { \ - TraceLoggingWrite(TraceLoggingType::Provider(), #EventId, \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingWrite(TraceLoggingType::Provider(), #EventId \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), \ __VA_ARGS__); \ } @@ -1737,8 +1770,8 @@ namespace wil template static void EventId(T1 &&varName1) \ { \ TraceLoggingWrite(TraceLoggingType::Provider(), #EventId, \ - TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1746,8 +1779,8 @@ namespace wil template static void EventId(T1 &&varName1, PCSTR correlationVector) \ { \ TraceLoggingWrite(TraceLoggingType::Provider(), #EventId, \ - TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), \ __VA_ARGS__); \ } @@ -1757,8 +1790,8 @@ namespace wil { \ TraceLoggingWrite(TraceLoggingType::Provider(), #EventId, \ TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ - TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1767,8 +1800,8 @@ namespace wil { \ TraceLoggingWrite(TraceLoggingType::Provider(), #EventId, \ TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ - TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), \ __VA_ARGS__); \ } @@ -1779,8 +1812,8 @@ namespace wil TraceLoggingWrite(TraceLoggingType::Provider(), #EventId, \ TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ - TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1790,8 +1823,8 @@ namespace wil TraceLoggingWrite(TraceLoggingType::Provider(), #EventId, \ TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ - TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), \ __VA_ARGS__); \ } @@ -1803,8 +1836,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ - TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1815,8 +1848,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName1)), _wiltlg_STRINGIZE(varName1)), \ TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ - TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), \ __VA_ARGS__); \ } @@ -1829,8 +1862,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ - TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1842,8 +1875,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName2)), _wiltlg_STRINGIZE(varName2)), \ TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ - TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), __VA_ARGS__); \ } @@ -1856,8 +1889,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ - TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1870,8 +1903,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName3)), _wiltlg_STRINGIZE(varName3)), \ TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ - TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), __VA_ARGS__); \ } @@ -1885,8 +1918,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)), \ - TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1900,8 +1933,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName4)), _wiltlg_STRINGIZE(varName4)), \ TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)), \ - TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), __VA_ARGS__); \ } @@ -1916,8 +1949,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)), \ TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)), \ - TraceLoggingValue(static_cast(wistd::forward(varName8)), _wiltlg_STRINGIZE(varName8)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName8)), _wiltlg_STRINGIZE(varName8)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1932,8 +1965,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName5)), _wiltlg_STRINGIZE(varName5)), \ TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)), \ TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)), \ - TraceLoggingValue(static_cast(wistd::forward(varName8)), _wiltlg_STRINGIZE(varName8)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName8)), _wiltlg_STRINGIZE(varName8)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), __VA_ARGS__); \ } @@ -1949,8 +1982,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)), \ TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)), \ TraceLoggingValue(static_cast(wistd::forward(varName8)), _wiltlg_STRINGIZE(varName8)), \ - TraceLoggingValue(static_cast(wistd::forward(varName9)), _wiltlg_STRINGIZE(varName9)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName9)), _wiltlg_STRINGIZE(varName9)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } @@ -1966,8 +1999,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName6)), _wiltlg_STRINGIZE(varName6)), \ TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)), \ TraceLoggingValue(static_cast(wistd::forward(varName8)), _wiltlg_STRINGIZE(varName8)), \ - TraceLoggingValue(static_cast(wistd::forward(varName9)), _wiltlg_STRINGIZE(varName9)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName9)), _wiltlg_STRINGIZE(varName9)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ TraceLoggingString(correlationVector, "__TlgCV__"), __VA_ARGS__); \ } @@ -1984,8 +2017,8 @@ namespace wil TraceLoggingValue(static_cast(wistd::forward(varName7)), _wiltlg_STRINGIZE(varName7)), \ TraceLoggingValue(static_cast(wistd::forward(varName8)), _wiltlg_STRINGIZE(varName8)), \ TraceLoggingValue(static_cast(wistd::forward(varName9)), _wiltlg_STRINGIZE(varName9)), \ - TraceLoggingValue(static_cast(wistd::forward(varName10)), _wiltlg_STRINGIZE(varName10)), \ - _TLGWRITE_GENERIC_PARTB_FIELDS \ + TraceLoggingValue(static_cast(wistd::forward(varName10)), _wiltlg_STRINGIZE(varName10)) \ + _TLGWRITE_GENERIC_PARTB_FIELDS, \ __VA_ARGS__); \ } diff --git a/include/wil/cppwinrt_helpers.h b/include/wil/cppwinrt_helpers.h index 2623473c8..c3122b29f 100644 --- a/include/wil/cppwinrt_helpers.h +++ b/include/wil/cppwinrt_helpers.h @@ -115,7 +115,7 @@ namespace wil m_priority(priority) { } - WI_NODISCARD bool await_ready() const noexcept { return false; } + bool await_ready() const noexcept { return false; } void await_suspend(details::coroutine_handle<> handle) { diff --git a/include/wil/token_helpers.h b/include/wil/token_helpers.h index 1b4e927ef..d9fb09bd9 100644 --- a/include/wil/token_helpers.h +++ b/include/wil/token_helpers.h @@ -133,6 +133,7 @@ namespace wil #endif // WIL_ENABLE_EXCEPTIONS #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + // Returns tokenHandle or the effective thread token if tokenHandle is null. // Note, this returns an token handle who's lifetime is managed independently // and it may be a pseudo token, don't free it! diff --git a/tests/ComTests.cpp b/tests/ComTests.cpp index 4c1b7f1e1..7282f04d8 100644 --- a/tests/ComTests.cpp +++ b/tests/ComTests.cpp @@ -637,7 +637,7 @@ IAlways : public IUnknown STDMETHOD_(void, Always)() = 0; }; -class __declspec(uuid("ececcc6a-5193-4d14-b38e-ed1460c20b00")) // non-implemented to allow QI for the class to be attempted (and fail) +class __declspec(empty_bases) __declspec(uuid("ececcc6a-5193-4d14-b38e-ed1460c20b00")) // non-implemented to allow QI for the class to be attempted (and fail) ComObject : witest::AllocatedObject, public Microsoft::WRL::RuntimeClass, Microsoft::WRL::ChainInterfaces, @@ -648,7 +648,7 @@ ComObject : witest::AllocatedObject, COM_DECLSPEC_NOTHROW IFACEMETHODIMP_(void) Always() {} }; -class __declspec(uuid("ececcc6a-5193-4d14-b38e-ed1460c20b01")) // non-implemented to allow QI for the class to be attempted (and fail) +class __declspec(empty_bases) __declspec(uuid("ececcc6a-5193-4d14-b38e-ed1460c20b01")) // non-implemented to allow QI for the class to be attempted (and fail) WinRtObject : witest::AllocatedObject, public Microsoft::WRL::RuntimeClass, ITest, IDerivedTest, ITestInspectable, IDerivedTestInspectable, IAlways, Microsoft::WRL::FtmBase> @@ -661,7 +661,7 @@ WinRtObject : witest::AllocatedObject, COM_DECLSPEC_NOTHROW IFACEMETHODIMP_(void) Always() {} }; -class NoCom : witest::AllocatedObject +class __declspec(empty_bases) NoCom : witest::AllocatedObject { public: ULONG __stdcall AddRef() diff --git a/tests/ResourceTests.cpp b/tests/ResourceTests.cpp index 72555f11c..42454064b 100644 --- a/tests/ResourceTests.cpp +++ b/tests/ResourceTests.cpp @@ -124,7 +124,7 @@ ITest : public IUnknown STDMETHOD_(void, Test)() = 0; }; -class PointerTestObject : witest::AllocatedObject, +class __declspec(empty_bases) PointerTestObject : witest::AllocatedObject, public Microsoft::WRL::RuntimeClass, ITest> { public: diff --git a/tests/wiTest.cpp b/tests/wiTest.cpp index b780fa37c..f87bb34d2 100644 --- a/tests/wiTest.cpp +++ b/tests/wiTest.cpp @@ -2870,7 +2870,7 @@ interface __declspec(uuid("EDCA4ADC-DF46-442A-A69D-FDFD8BC37B31")) IFakeObject : STDMETHOD_(void, DoStuff)() = 0; }; -class ArrayTestObject : witest::AllocatedObject, +class __declspec(empty_bases) ArrayTestObject : witest::AllocatedObject, public Microsoft::WRL::RuntimeClass, IFakeObject> { public: