Skip to content

Commit

Permalink
Avoid renaming WINRT_CanUnloadNow and WINRT_GetActivationFactory
Browse files Browse the repository at this point in the history
They are for exporting, not importing
  • Loading branch information
cqwrteur committed Nov 25, 2024
1 parent aab28ef commit ff0539c
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions strings/base_extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,32 @@ __declspec(selectany) int32_t(__stdcall* winrt_activation_handler)(void* classId
#if defined(_MSC_VER) && !defined(__clang__)
#ifdef _M_HYBRID
#define WINRT_IMPL_LINK(function, count) __pragma(comment(linker, "/alternatename:#WINRT_IMPL_" #function "@" #count "=#" #function "@" #count))
#define WINRT_IMPL_LINK2(function1, function2, count) __pragma(comment(linker, "/alternatename:#WINRT_" #function1 "@" #count "=#" #function2 "@" #count))
#define WINRT_IMPL_DLLIMPORT
#elif _M_ARM64EC
#define WINRT_IMPL_LINK(function, count) __pragma(comment(linker, "/alternatename:#WINRT_IMPL_" #function "=#" #function))
#define WINRT_IMPL_LINK2(function1, function2, count) __pragma(comment(linker, "/alternatename:#WINRT_" #function1 "=#" #function2))
#define WINRT_IMPL_DLLIMPORT
#elif _M_IX86
#define WINRT_IMPL_LINK(function, count) __pragma(comment(linker, "/alternatename:__imp__WINRT_IMPL_" #function "@" #count "=__imp__" #function "@" #count))
#define WINRT_IMPL_LINK2(function1, function2, count) __pragma(comment(linker, "/alternatename:__imp__WINRT_" #function1 "@" #count "=__imp__" #function2 "@" #count))
#define WINRT_IMPL_DLLIMPORT __declspec(dllimport)
#else
#define WINRT_IMPL_LINK(function, count) __pragma(comment(linker, "/alternatename:__imp_WINRT_IMPL_" #function "=__imp_" #function))
#define WINRT_IMPL_LINK2(function1, function2, count) __pragma(comment(linker, "/alternatename:__imp_WINRT_" #function1 "=__imp_" #function2))
#define WINRT_IMPL_DLLIMPORT __declspec(dllimport)
#endif
#define WINRT_IMPL_EXTERN_C_BEGIN extern "C" {
#define WINRT_IMPL_EXTERN_C_END }
#elif defined(__GNUC__) || defined(__clang__)
#if defined(__arm64ec__) || defined(_M_ARM64EC)
#define WINRT_IMPL_LINK(function, count) __asm__("#" #function)
#define WINRT_IMPL_LINK2(function1, function2, count) __asm__("#" #function2)
#define WINRT_IMPL_DLLIMPORT
#elif SIZE_MAX <= UINT_LEAST32_MAX && (defined(__x86__) || defined(_M_IX86) || defined(__i386__))
#if !defined(__clang__)
#define WINRT_IMPL_LINK(function, count) __asm__(#function "@" #count)
#define WINRT_IMPL_LINK2(function1, function2, count) __asm__(#function2 "@" #count)
#else
#define WINRT_IMPL_LINK(function, count) __asm__("_" #function "@" #count)
#define WINRT_IMPL_LINK2(function1, function2, count) __asm__("_" #function2 "@" #count)
#endif
#define WINRT_IMPL_DLLIMPORT [[__gnu__::__dllimport__]]
#else
#define WINRT_IMPL_LINK(function, count) __asm__(#function)
#define WINRT_IMPL_LINK2(function1, function2, count) __asm__(#function2)
#define WINRT_IMPL_DLLIMPORT [[__gnu__::__dllimport__]]
#endif
#define WINRT_IMPL_EXTERN_C_BEGIN
Expand Down Expand Up @@ -129,19 +121,15 @@ WINRT_IMPL_DLLIMPORT void __stdcall WINRT_IMPL_SetThreadpoolThreadMaximum(winrt:
WINRT_IMPL_DLLIMPORT int32_t __stdcall WINRT_IMPL_SetThreadpoolThreadMinimum(winrt::impl::ptp_pool pool, uint32_t value) noexcept WINRT_IMPL_LINK(SetThreadpoolThreadMinimum, 8);
WINRT_IMPL_DLLIMPORT void __stdcall WINRT_IMPL_CloseThreadpool(winrt::impl::ptp_pool pool) noexcept WINRT_IMPL_LINK(CloseThreadpool, 4);

WINRT_IMPL_DLLIMPORT int32_t __stdcall WINRT_CanUnloadNow() noexcept WINRT_IMPL_LINK2(CanUnloadNow, DllCanUnloadNow, 0);
WINRT_IMPL_DLLIMPORT int32_t __stdcall WINRT_GetActivationFactory(void* classId, void** factory) noexcept WINRT_IMPL_LINK2(GetActivationFactory, GetActivationFactory, 8);

WINRT_IMPL_EXTERN_C_END

extern "C"
{
int32_t __stdcall WINRT_CanUnloadNow() noexcept;
int32_t __stdcall WINRT_GetActivationFactory(void* classId, void** factory) noexcept;
}

#undef WINRT_IMPL_DLLIMPORT
#undef WINRT_IMPL_LINK
#undef WINRT_IMPL_LINK2
#undef WINRT_IMPL_EXTERN_C_BEGIN
#undef WINRT_IMPL_EXTERN_C_END

#if defined(_MSC_VER) && !defined(_KERNEL_MODE)
#pragma comment(lib, "ole32.lib")
#pragma comment(lib, "oleaut32.lib")
#pragma comment(lib, "runtimeobject.lib")
#endif

0 comments on commit ff0539c

Please sign in to comment.