ReactOS  0.4.13-dev-656-g74bcf30
tls.h File Reference
#include <stddef.h>
#include <time.h>
#include <locale.h>
#include <windef.h>
#include <winbase.h>
#include <winnt.h>
#include <internal/wine/eh.h>
Include dependency graph for tls.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  __thread_data
 

Macros

#define MSVCRT_ENABLE_PER_THREAD_LOCALE   1
 
#define MSVCRT_DISABLE_PER_THREAD_LOCALE   2
 

Typedefs

typedef struct __thread_data thread_data_t
 

Functions

BOOL msvcrt_init_tls (void)
 
BOOL msvcrt_free_tls (void)
 
thread_data_tmsvcrt_get_thread_data (void)
 
void msvcrt_free_tls_mem (void)
 

Variables

DWORD tls_index
 

Macro Definition Documentation

◆ MSVCRT_DISABLE_PER_THREAD_LOCALE

#define MSVCRT_DISABLE_PER_THREAD_LOCALE   2

Definition at line 66 of file tls.h.

◆ MSVCRT_ENABLE_PER_THREAD_LOCALE

#define MSVCRT_ENABLE_PER_THREAD_LOCALE   1

Definition at line 65 of file tls.h.

Typedef Documentation

◆ thread_data_t

Definition at line 58 of file tls.h.

Function Documentation

◆ msvcrt_free_tls()

BOOL msvcrt_free_tls ( void  )

Definition at line 21 of file tls.c.

22 {
24  {
25  ERR("TlsFree() failed!\n");
26  return FALSE;
27  }
28  return TRUE;
29 }
#define TRUE
Definition: types.h:120
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1116
static DWORD msvcrt_tls_index
Definition: tls.c:7
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by DllMain().

◆ msvcrt_free_tls_mem()

void msvcrt_free_tls_mem ( void  )

Definition at line 51 of file tls.c.

52 {
54 
55  if (tls)
56  {
57  CloseHandle(tls->handle);
58  HeapFree(GetProcessHeap(),0,tls->efcvt_buffer);
59  HeapFree(GetProcessHeap(),0,tls->asctime_buffer);
60  HeapFree(GetProcessHeap(),0,tls->wasctime_buffer);
61  HeapFree(GetProcessHeap(),0,tls->strerror_buffer);
62  HeapFree(GetProcessHeap(),0,tls->wcserror_buffer);
63  HeapFree(GetProcessHeap(),0,tls->time_buffer);
64  //if(tls->have_locale) {
65  // free_locinfo(tls->locinfo);
66  // free_mbcinfo(tls->mbcinfo);
67  //}
68  }
70 }
#define CloseHandle
Definition: compat.h:398
#define GetProcessHeap()
Definition: compat.h:395
static DWORD msvcrt_tls_index
Definition: tls.c:7
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1190
static DWORD tls
Definition: sock.c:230
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by DllMain().

◆ msvcrt_get_thread_data()

thread_data_t* msvcrt_get_thread_data ( void  )

Definition at line 31 of file tls.c.

32 {
34  DWORD err = GetLastError(); /* need to preserve last error */
35 
36  if (!(ptr = TlsGetValue( msvcrt_tls_index )))
37  {
38  if (!(ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ptr) )))
41  ptr->tid = GetCurrentThreadId();
42  ptr->handle = INVALID_HANDLE_VALUE;
43  ptr->random_seed = 1;
44  ptr->locinfo = MSVCRT_locale->locinfo;
45  ptr->mbcinfo = MSVCRT_locale->mbcinfo;
46  }
47  SetLastError( err );
48  return ptr;
49 }
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1226
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
void __cdecl _amsg_exit(int errnum)
Definition: amsg.c:47
static PVOID ptr
Definition: dispmode.c:27
MSVCRT_pthreadmbcinfo mbcinfo
Definition: msvcrt.h:153
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static DWORD msvcrt_tls_index
Definition: tls.c:7
#define err(...)
MSVCRT__locale_t MSVCRT_locale
Definition: msvcrt.h:885
MSVCRT_pthreadlocinfo locinfo
Definition: msvcrt.h:152
#define _RT_THREAD
Definition: msvcrt.h:267
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1190

◆ msvcrt_init_tls()

BOOL msvcrt_init_tls ( void  )

Definition at line 9 of file tls.c.

10 {
12 
14  {
15  ERR("TlsAlloc() failed!\n");
16  return FALSE;
17  }
18  return TRUE;
19 }
#define TRUE
Definition: types.h:120
static DWORD msvcrt_tls_index
Definition: tls.c:7
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1050
#define TLS_OUT_OF_INDEXES
Definition: winbase.h:530
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by DllMain().

Variable Documentation

◆ tls_index

DWORD tls_index

Referenced by test_import_resolution().