ReactOS 0.4.16-dev-2252-gb2c1dd8
ucrt_tls_sup.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS msvcrt
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: TLS support code for use with ucrtbase
5 * COPYRIGHT: Copyright 2025 Timo Kreuzer <timo.kreuzer@reactos.org>
6 */
7
8#include <process.h>
9#include <assert.h>
10#include "msvcrt.h"
11#include "wine/debug.h"
12
14
16
18{
21 {
22 ERR("TlsAlloc() failed!\n");
23 return FALSE;
24 }
25
26 return TRUE;
27}
28
30{
32 {
33 ERR("TlsFree() failed!\n");
34 return FALSE;
35 }
36
37 return TRUE;
38}
39
41{
43 if (tls)
44 {
45 free(tls->efcvt_buffer);
46 assert(tls->asctime_buffer == NULL);
47 assert(tls->wasctime_buffer == NULL);
48 assert(tls->strerror_buffer == NULL);
49 assert(tls->wcserror_buffer == NULL);
50 assert(tls->time_buffer == NULL);
51 assert(tls->tmpnam_buffer == NULL);
52 assert(tls->wtmpnam_buffer == NULL);
53 assert(tls->locinfo == NULL);
54 assert(tls->mbcinfo == NULL);
56 }
57}
58
60{
62 DWORD err = GetLastError(); /* need to preserve last error */
63
65 if (ptr == NULL)
66 {
68 if (ptr == NULL)
70
73
74 ptr->tid = GetCurrentThreadId();
75 ptr->handle = INVALID_HANDLE_VALUE;
76 ptr->random_seed = 1;
77 }
78
80 return ptr;
81}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ERR(fmt,...)
Definition: precomp.h:57
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CDECL
Definition: compat.h:29
#define GetProcessHeap()
Definition: compat.h:736
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1240
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1276
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1166
DWORD WINAPI DECLSPEC_HOTPATCH TlsAlloc(void)
Definition: thread.c:657
#define assert(_expr)
Definition: assert.h:32
#define _RT_THREAD
Definition: msvcrt.h:308
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
static PVOID ptr
Definition: dispmode.c:27
#define err(...)
#define exit(n)
Definition: config.h:202
static DWORD tls
Definition: sock.c:229
thread_data_t *CDECL msvcrt_get_thread_data(void)
Definition: ucrt_tls_sup.c:59
void msvcrt_free_tls_mem(void)
Definition: ucrt_tls_sup.c:40
DWORD msvcrt_tls_index
Definition: ucrt_tls_sup.c:15
BOOL msvcrt_free_tls(void)
Definition: ucrt_tls_sup.c:29
BOOL msvcrt_init_tls(void)
Definition: ucrt_tls_sup.c:17
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
#define TLS_OUT_OF_INDEXES
Definition: winbase.h:529