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
e272b31b
Commit
e272b31b
authored
Dec 15, 2010
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Ensure alignment of static TLS data and free it at thread exit.
parent
156f611b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
14 deletions
+10
-14
loader.c
dlls/ntdll/loader.c
+10
-14
No files found.
dlls/ntdll/loader.c
View file @
e272b31b
...
...
@@ -97,6 +97,8 @@ static HANDLE main_exe_file;
static
UINT
tls_module_count
;
/* number of modules with TLS directory */
static
UINT
tls_total_size
;
/* total size of TLS storage */
static
const
IMAGE_TLS_DIRECTORY
**
tls_dirs
;
/* array of TLS directories */
#define TLS_ALIGNMENT (2 * sizeof(void *))
#define TLS_ALIGN(size) (((size) + TLS_ALIGNMENT - 1) & ~(TLS_ALIGNMENT - 1))
static
RTL_CRITICAL_SECTION
loader_section
;
static
RTL_CRITICAL_SECTION_DEBUG
critsect_debug
=
...
...
@@ -843,7 +845,7 @@ static NTSTATUS alloc_process_tls(void)
continue
;
size
=
(
dir
->
EndAddressOfRawData
-
dir
->
StartAddressOfRawData
)
+
dir
->
SizeOfZeroFill
;
if
(
!
size
&&
!
dir
->
AddressOfCallBacks
)
continue
;
tls_total_size
+=
size
;
tls_total_size
+=
TLS_ALIGN
(
size
)
;
tls_module_count
++
;
}
if
(
!
tls_module_count
)
return
STATUS_SUCCESS
;
...
...
@@ -878,24 +880,19 @@ static NTSTATUS alloc_thread_tls(void)
{
void
**
pointers
;
char
*
data
;
UINT
i
;
UINT
i
,
size
;
if
(
!
tls_module_count
)
return
STATUS_SUCCESS
;
if
(
!
(
pointers
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
tls_module_count
*
sizeof
(
*
pointers
)
)))
size
=
TLS_ALIGN
(
tls_module_count
*
sizeof
(
*
pointers
)
);
if
(
!
(
pointers
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
size
+
tls_total_size
)))
return
STATUS_NO_MEMORY
;
if
(
!
(
data
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
tls_total_size
)))
{
RtlFreeHeap
(
GetProcessHeap
(),
0
,
pointers
);
return
STATUS_NO_MEMORY
;
}
data
=
(
char
*
)
pointers
+
size
;
for
(
i
=
0
;
i
<
tls_module_count
;
i
++
)
{
const
IMAGE_TLS_DIRECTORY
*
dir
=
tls_dirs
[
i
];
ULONG
size
=
dir
->
EndAddressOfRawData
-
dir
->
StartAddressOfRawData
;
size
=
dir
->
EndAddressOfRawData
-
dir
->
StartAddressOfRawData
;
TRACE
(
"thread %04x idx %d: %d/%d bytes from %p to %p
\n
"
,
GetCurrentThreadId
(),
i
,
size
,
dir
->
SizeOfZeroFill
,
...
...
@@ -903,9 +900,8 @@ static NTSTATUS alloc_thread_tls(void)
pointers
[
i
]
=
data
;
memcpy
(
data
,
(
void
*
)
dir
->
StartAddressOfRawData
,
size
);
data
+=
size
;
memset
(
data
,
0
,
dir
->
SizeOfZeroFill
);
data
+=
dir
->
SizeOfZeroFill
;
memset
(
data
+
size
,
0
,
dir
->
SizeOfZeroFill
);
data
+=
TLS_ALIGN
(
size
+
dir
->
SizeOfZeroFill
);
}
NtCurrentTeb
()
->
ThreadLocalStoragePointer
=
pointers
;
return
STATUS_SUCCESS
;
...
...
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