Skip to content

Commit d61cb15

Browse files
authored
Use compiler-specific WINRT_IMPL_NOINLINE macro for noinline functions (#893)
1 parent c70d938 commit d61cb15

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

strings/base_activation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace winrt::impl
2626

2727

2828
template <bool isSameInterfaceAsIActivationFactory>
29-
__declspec(noinline) hresult get_runtime_activation_factory_impl(param::hstring const& name, winrt::guid const& guid, void** result) noexcept
29+
WINRT_IMPL_NOINLINE hresult get_runtime_activation_factory_impl(param::hstring const& name, winrt::guid const& guid, void** result) noexcept
3030
{
3131
if (winrt_activation_handler)
3232
{
@@ -339,7 +339,7 @@ namespace winrt::impl
339339
struct factory_cache_entry : factory_cache_entry_base
340340
{
341341
template <typename F>
342-
__declspec(noinline) auto call(F&& callback)
342+
WINRT_IMPL_NOINLINE auto call(F&& callback)
343343
{
344344
#ifdef WINRT_DIAGNOSTICS
345345
get_diagnostics_info().add_factory<Class>();

strings/base_com_ptr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ WINRT_EXPORT namespace winrt
214214
}
215215
}
216216

217-
__declspec(noinline) void unconditional_release_ref() noexcept
217+
WINRT_IMPL_NOINLINE void unconditional_release_ref() noexcept
218218
{
219219
std::exchange(m_ptr, {})->Release();
220220
}

strings/base_error.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ WINRT_EXPORT namespace winrt
433433
hresult_canceled(take_ownership_from_abi_t) noexcept : hresult_error(impl::error_canceled, take_ownership_from_abi) {}
434434
};
435435

436-
[[noreturn]] inline __declspec(noinline) void throw_hresult(hresult const result)
436+
[[noreturn]] inline WINRT_IMPL_NOINLINE void throw_hresult(hresult const result)
437437
{
438438
if (winrt_throw_hresult_handler)
439439
{
@@ -513,7 +513,7 @@ WINRT_EXPORT namespace winrt
513513
throw hresult_error(result, take_ownership_from_abi);
514514
}
515515

516-
inline __declspec(noinline) hresult to_hresult() noexcept
516+
inline WINRT_IMPL_NOINLINE hresult to_hresult() noexcept
517517
{
518518
if (winrt_to_hresult_handler)
519519
{
@@ -546,7 +546,7 @@ WINRT_EXPORT namespace winrt
546546
}
547547
}
548548

549-
inline __declspec(noinline) hstring to_message()
549+
inline WINRT_IMPL_NOINLINE hstring to_message()
550550
{
551551
if (winrt_to_message_handler)
552552
{

strings/base_macros.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@
4545
#undef _WINDOWS_NUMERICS_END_NAMESPACE_
4646
#endif
4747

48+
#if defined(_MSC_VER)
49+
#define WINRT_IMPL_NOINLINE __declspec(noinline)
50+
#elif defined(__GNUC__)
51+
#define WINRT_IMPL_NOINLINE __attribute__((noinline))
52+
#else
53+
#define WINRT_IMPL_NOINLINE
54+
#endif
55+
4856
#ifdef __IUnknown_INTERFACE_DEFINED__
4957
#define WINRT_IMPL_IUNKNOWN_DEFINED
5058
#endif

strings/base_windows.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ WINRT_EXPORT namespace winrt::Windows::Foundation
257257
}
258258
}
259259

260-
__declspec(noinline) void unconditional_release_ref() noexcept
260+
WINRT_IMPL_NOINLINE void unconditional_release_ref() noexcept
261261
{
262262
std::exchange(m_ptr, {})->Release();
263263
}

0 commit comments

Comments
 (0)