Skip to content

Commit

Permalink
Bug #67, ___lc_locale_name_func改用Tls实现,解决XP目标时全局变量占用过多内存
Browse files Browse the repository at this point in the history
  • Loading branch information
mingkuang-Chuyu committed Aug 4, 2024
1 parent 883a326 commit ea698ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
7 changes: 3 additions & 4 deletions Nuget/VC-LTL.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<metadata minClientVersion="2.5">
<id>VC-LTL</id>
<version>$version$</version>
<title>VC-LTL for Visual Studio 2015, 2017, 2019, 2022</title>
<summary>VC-LTL for Visual Studio 2015, 2017, 2019, 2022,编译精巧的程序原来如此简单。</summary>
<authors>YY</authors>
<owners>初雨团队</owners>
Expand All @@ -26,11 +25,11 @@
<repository type="git" url="https://github.com/Chuyu-Team/VC-LTL5.git" branch="master" commit="$commit$" />
<dependencies>
<group targetFramework="native">
<dependency id="YY.NuGet.Import.Helper" version="1.0.0.4" />
<dependency id="YY-Thunks" version="1.1.2-Beta4"/>
<dependency id="YY.NuGet.Import.Helper" version="1.0.1" />
<dependency id="YY-Thunks" version="1.1.2-Beta7"/>
</group>
<group targetFramework="net8.0-windows7.0">
<dependency id="YY-Thunks" version="1.1.2-Beta4"/>
<dependency id="YY-Thunks" version="1.1.2-Beta7"/>
</group>
</dependencies>
</metadata>
Expand Down
13 changes: 3 additions & 10 deletions ucrtbase.msvcrt/initctype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,8 @@ struct lc_locale_name_buffer

EXTERN_C wchar_t** __cdecl ___lc_locale_name_func(void)
{
#if WindowsTargetPlatformMinVersion < WindowsTargetPlatformWindows6
//XP系统 thread_local 存在限制,所以我们需要在本地弄一份很大的数组,对于这个场景很显然我们不需要太强大散列支持
static lc_locale_name_buffer ThreadBuffer[0x4000];

auto& Current = ThreadBuffer[(GetCurrentThreadId() >> 1) % __crt_countof(ThreadBuffer)];
#else
static thread_local lc_locale_name_buffer Current;
#endif

// 由YY-Thunks 为Windows XP提供完整的TLS支持
static thread_local lc_locale_name_buffer Current;

auto lc_handle = ___lc_handle_func();

Expand Down Expand Up @@ -68,4 +61,4 @@ EXTERN_C unsigned int __cdecl ___lc_collate_cp_func(void)

_LCRT_DEFINE_IAT_SYMBOL(___lc_collate_cp_func);

#endif
#endif

0 comments on commit ea698ae

Please sign in to comment.