Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
3fbfddbd
Commit
3fbfddbd
authored
Feb 02, 2022
by
Piotr Caban
Committed by
Alexandre Julliard
Feb 03, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Use InitOnceExecuteOnce to allocate TLS index.
Signed-off-by:
Piotr Caban
<
piotr@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
2a74dc51
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
concurrency.c
dlls/msvcrt/concurrency.c
+14
-12
No files found.
dlls/msvcrt/concurrency.c
View file @
3fbfddbd
...
...
@@ -345,7 +345,7 @@ enum ConcRT_EventType
CONCRT_EVENT_DETACH
};
static
int
context_tls_index
=
TLS_OUT_OF_INDEXES
;
static
DWORD
context_tls_index
=
TLS_OUT_OF_INDEXES
;
static
CRITICAL_SECTION
default_scheduler_cs
;
static
CRITICAL_SECTION_DEBUG
default_scheduler_cs_debug
=
...
...
@@ -620,21 +620,23 @@ static Context* try_get_current_context(void)
return
TlsGetValue
(
context_tls_index
);
}
static
BOOL
WINAPI
init_context_tls_index
(
INIT_ONCE
*
once
,
void
*
param
,
void
**
context
)
{
context_tls_index
=
TlsAlloc
();
return
context_tls_index
!=
TLS_OUT_OF_INDEXES
;
}
static
Context
*
get_current_context
(
void
)
{
static
INIT_ONCE
init_once
=
INIT_ONCE_STATIC_INIT
;
Context
*
ret
;
if
(
context_tls_index
==
TLS_OUT_OF_INDEXES
)
{
int
tls_index
=
TlsAlloc
();
if
(
tls_index
==
TLS_OUT_OF_INDEXES
)
{
scheduler_resource_allocation_error
e
;
scheduler_resource_allocation_error_ctor_name
(
&
e
,
NULL
,
HRESULT_FROM_WIN32
(
GetLastError
()));
_CxxThrowException
(
&
e
,
&
scheduler_resource_allocation_error_exception_type
);
}
if
(
InterlockedCompareExchange
(
&
context_tls_index
,
tls_index
,
TLS_OUT_OF_INDEXES
)
!=
TLS_OUT_OF_INDEXES
)
TlsFree
(
tls_index
);
if
(
!
InitOnceExecuteOnce
(
&
init_once
,
init_context_tls_index
,
NULL
,
NULL
))
{
scheduler_resource_allocation_error
e
;
scheduler_resource_allocation_error_ctor_name
(
&
e
,
NULL
,
HRESULT_FROM_WIN32
(
GetLastError
()));
_CxxThrowException
(
&
e
,
&
scheduler_resource_allocation_error_exception_type
);
}
ret
=
TlsGetValue
(
context_tls_index
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment