From 0ad71d51365b9326ba2f2e2a6ccaa20fb5b33f2a Mon Sep 17 00:00:00 2001 From: LIU Hao Date: Wed, 13 Nov 2024 14:27:54 +0800 Subject: [PATCH] Revert "xglobals: Work around build issues with old Clang" This reverts commit f296ddf52764c36e743f4cdc563d1ff26215e144. GCC exports a wrong name if `__asm__` and `__declspec(dllexport)` are used together. Moreover, the buggy Clang, shipped with Clang-CL with Visual Studio 2022, invokes the Microsoft linker and is not functional at all. --- mcfgthread/xglobals.c | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/mcfgthread/xglobals.c b/mcfgthread/xglobals.c index a22552a8f..b38faa69c 100644 --- a/mcfgthread/xglobals.c +++ b/mcfgthread/xglobals.c @@ -328,62 +328,36 @@ __MCF_dll_startup(PVOID instance, ULONG reason, PVOID reserved) } } -/* GCC requires these functions for a freestanding implementation: - * https://gcc.gnu.org/onlinedocs/gcc/Standards.html */ -__MCF_DLLEXPORT -void* -__cdecl -__MCF_memcpy(void* dst, const void* src, size_t size) - __asm__(__MCF_USYM "memcpy"); - -__MCF_DLLEXPORT +__declspec(dllexport) void* __cdecl -__MCF_memcpy(void* dst, const void* src, size_t size) +memcpy(void* dst, const void* src, size_t size) { return __MCF_mcopy(dst, src, size); } -__MCF_DLLEXPORT -void* -__cdecl -__MCF_memmove(void* dst, const void* src, size_t size) - __asm__(__MCF_USYM "memmove"); - -__MCF_DLLEXPORT +__declspec(dllexport) void* __cdecl -__MCF_memmove(void* dst, const void* src, size_t size) +memmove(void* dst, const void* src, size_t size) { return ((uintptr_t) dst - (uintptr_t) src >= size) ? __MCF_mcopy(dst, src, size) : __MCF_mcopy_backward(dst, src, size); } -__MCF_DLLEXPORT -int -__cdecl -__MCF_memcmp(const void* src, const void* cmp, size_t size) - __asm__(__MCF_USYM "memcmp"); - -__MCF_DLLEXPORT +__declspec(dllexport) int __cdecl -__MCF_memcmp(const void* src, const void* cmp, size_t size) +memcmp(const void* src, const void* cmp, size_t size) { return __MCF_mcompare(src, cmp, size); } -__MCF_DLLEXPORT -void* -__cdecl -__MCF_memset(void* dst, int val, size_t size) - __asm__(__MCF_USYM "memset"); - -__MCF_DLLEXPORT +__declspec(dllexport) void* __cdecl -__MCF_memset(void* dst, int val, size_t size) +memset(void* dst, int val, size_t size) { return __MCF_mfill(dst, val, size); }