From d5340282e609c627d16ae3e1552fd5cc8c7c0a2e Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 6 Aug 2023 11:52:51 +0300 Subject: [PATCH 1/2] More declarations! --- stl/src/StlCompareStringA.cpp | 2 +- stl/src/StlCompareStringW.cpp | 2 +- stl/src/StlLCMapStringA.cpp | 2 +- stl/src/StlLCMapStringW.cpp | 2 +- stl/src/xmtx.cpp | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stl/src/StlCompareStringA.cpp b/stl/src/StlCompareStringA.cpp index 81eb6e41c57..dac2cc61607 100644 --- a/stl/src/StlCompareStringA.cpp +++ b/stl/src/StlCompareStringA.cpp @@ -29,7 +29,7 @@ // 2 - if lpString1 == lpString2 // 3 - if lpString1 > lpString2 // Failure: 0 -extern "C" int __cdecl __crtCompareStringA(_In_z_ LPCWSTR LocaleName, _In_ DWORD dwCmpFlags, +extern "C" _CRTIMP2 int __cdecl __crtCompareStringA(_In_z_ LPCWSTR LocaleName, _In_ DWORD dwCmpFlags, _In_reads_(cchCount1) LPCSTR lpString1, _In_ int cchCount1, _In_reads_(cchCount2) LPCSTR lpString2, _In_ int cchCount2, _In_ int code_page) { // CompareString will compare past null terminator. Must find null terminator if in string before cchCountn chars. diff --git a/stl/src/StlCompareStringW.cpp b/stl/src/StlCompareStringW.cpp index 424593c03a0..4b259968e9a 100644 --- a/stl/src/StlCompareStringW.cpp +++ b/stl/src/StlCompareStringW.cpp @@ -24,7 +24,7 @@ // 2 - if lpString1 == lpString2 // 3 - if lpString1 > lpString2 // Failure: 0 -extern "C" int __cdecl __crtCompareStringW(_In_z_ LPCWSTR LocaleName, _In_ DWORD dwCmpFlags, +extern "C" _CRTIMP2 int __cdecl __crtCompareStringW(_In_z_ LPCWSTR LocaleName, _In_ DWORD dwCmpFlags, _In_reads_(cchCount1) LPCWSTR lpString1, _In_ int cchCount1, _In_reads_(cchCount2) LPCWSTR lpString2, _In_ int cchCount2) { // CompareString will compare past null terminator. Must find null terminator if in string before cchCountn wide diff --git a/stl/src/StlLCMapStringA.cpp b/stl/src/StlLCMapStringA.cpp index 2ddf8258b5d..fab0c4d9181 100644 --- a/stl/src/StlLCMapStringA.cpp +++ b/stl/src/StlLCMapStringA.cpp @@ -28,7 +28,7 @@ // Exit: // Success: number of chars written to lpDestStr (including null terminator) // Failure: 0 -extern "C" int __cdecl __crtLCMapStringA(_In_opt_z_ LPCWSTR LocaleName, _In_ DWORD dwMapFlags, +extern "C" _CRTIMP2 int __cdecl __crtLCMapStringA(_In_opt_z_ LPCWSTR LocaleName, _In_ DWORD dwMapFlags, _In_reads_(cchSrc) LPCSTR lpSrcStr, _In_ int cchSrc, _Out_writes_opt_(cchDest) char* lpDestStr, _In_ int cchDest, _In_ int code_page, _In_ BOOL bError) { // LCMapString will map past the null terminator. We must find the null diff --git a/stl/src/StlLCMapStringW.cpp b/stl/src/StlLCMapStringW.cpp index 625e8f8075c..5bf4d1155f9 100644 --- a/stl/src/StlLCMapStringW.cpp +++ b/stl/src/StlLCMapStringW.cpp @@ -30,7 +30,7 @@ // else // number of wide characters written to destination (including null terminator) // Failure: 0 -extern "C" int __cdecl __crtLCMapStringW(_In_opt_z_ LPCWSTR const locale_name, _In_ DWORD const map_flags, +extern "C" _CRTIMP2 int __cdecl __crtLCMapStringW(_In_opt_z_ LPCWSTR const locale_name, _In_ DWORD const map_flags, _In_reads_(source_count) LPCWSTR const source, _In_ int source_count, _Out_writes_opt_(destination_count) wchar_t* const destination, _In_ int const destination_count) { // LCMapString will map past the null terminator. We must find the null terminator if it occurs in the string diff --git a/stl/src/xmtx.cpp b/stl/src/xmtx.cpp index a28195af92b..9ea65fb4d10 100644 --- a/stl/src/xmtx.cpp +++ b/stl/src/xmtx.cpp @@ -11,16 +11,16 @@ _EXTERN_C_UNLESS_PURE // Win32 critical sections are recursive -void __CLRCALL_PURE_OR_CDECL _Mtxinit(_Rmtx* _Mtx) noexcept { // initialize mutex +_MRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Mtxinit(_Rmtx* _Mtx) noexcept { // initialize mutex InitializeCriticalSectionEx(_Mtx, 4000, 0); } -void __CLRCALL_PURE_OR_CDECL _Mtxdst(_Rmtx* _Mtx) noexcept { // delete mutex +_MRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Mtxdst(_Rmtx* _Mtx) noexcept { // delete mutex DeleteCriticalSection(_Mtx); } _RELIABILITY_CONTRACT -void __CLRCALL_PURE_OR_CDECL _Mtxlock(_Rmtx* _Mtx) noexcept { // lock mutex +_MRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Mtxlock(_Rmtx* _Mtx) noexcept { // lock mutex #ifdef _M_CEE System::Threading::Thread::BeginThreadAffinity(); #endif // _M_CEE @@ -28,7 +28,7 @@ void __CLRCALL_PURE_OR_CDECL _Mtxlock(_Rmtx* _Mtx) noexcept { // lock mutex } _RELIABILITY_CONTRACT -void __CLRCALL_PURE_OR_CDECL _Mtxunlock(_Rmtx* _Mtx) noexcept { // unlock mutex +_MRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Mtxunlock(_Rmtx* _Mtx) noexcept { // unlock mutex LeaveCriticalSection(_Mtx); #ifdef _M_CEE System::Threading::Thread::EndThreadAffinity(); From 9fd695048266d19b6004c14c8df93c60a1212145 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 7 Aug 2023 15:34:35 -0700 Subject: [PATCH 2/2] Simplify xmtx.hpp declarations. Handling this variation is exactly what `_MRTIMP2_PURE` and `__CLRCALL_PURE_OR_CDECL` do. --- stl/src/xmtx.hpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/stl/src/xmtx.hpp b/stl/src/xmtx.hpp index 44eb904eba5..f36af7acfcd 100644 --- a/stl/src/xmtx.hpp +++ b/stl/src/xmtx.hpp @@ -13,17 +13,9 @@ _EXTERN_C_UNLESS_PURE using _Rmtx = CRITICAL_SECTION; -#ifdef _M_CEE_PURE -void __clrcall _Mtxinit(_Rmtx*) noexcept; -void __clrcall _Mtxdst(_Rmtx*) noexcept; -void __clrcall _Mtxlock(_Rmtx*) noexcept; -void __clrcall _Mtxunlock(_Rmtx*) noexcept; - -#else // _M_CEE_PURE -_MRTIMP2 void __cdecl _Mtxinit(_Rmtx*) noexcept; -_MRTIMP2 void __cdecl _Mtxdst(_Rmtx*) noexcept; -_MRTIMP2 void __cdecl _Mtxlock(_Rmtx*) noexcept; -_MRTIMP2 void __cdecl _Mtxunlock(_Rmtx*) noexcept; -#endif // _M_CEE_PURE +_MRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Mtxinit(_Rmtx*) noexcept; +_MRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Mtxdst(_Rmtx*) noexcept; +_MRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Mtxlock(_Rmtx*) noexcept; +_MRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Mtxunlock(_Rmtx*) noexcept; _END_EXTERN_C_UNLESS_PURE