ReactOS  0.4.15-dev-3294-ge98684e
tlssup.c File Reference
#include <sect_attribs.h>
#include <windows.h>
#include <stdio.h>
#include <memory.h>
#include <malloc.h>
#include <corecrt_startup.h>
Include dependency graph for tlssup.c:

Go to the source code of this file.

Classes

struct  TlsDtorNode
 

Macros

#define WIN32_LEAN_AND_MEAN
 
#define FUNCS_PER_NODE   30
 
#define __CRT_THREAD   __thread
 
#define DISABLE_MS_TLS   1
 

Typedefs

typedef struct TlsDtorNode TlsDtorNode
 

Functions

WINBOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved)
 
 _CRTALLOC (".tls")
 
static _CRTALLOC (".CRT$XDA")
 
 _CRTALLOC (".CRT$XLC")
 
static BOOL WINAPI __dyn_tls_dtor (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
 

Variables

ULONG _tls_index = 0
 
const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback = (const PIMAGE_TLS_CALLBACK) __dyn_tls_init
 

Macro Definition Documentation

◆ __CRT_THREAD

#define __CRT_THREAD   __thread

Definition at line 61 of file tlssup.c.

◆ DISABLE_MS_TLS

#define DISABLE_MS_TLS   1

Definition at line 65 of file tlssup.c.

◆ FUNCS_PER_NODE

#define FUNCS_PER_NODE   30

Definition at line 31 of file tlssup.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

This file has no copyright assigned and is placed in the Public Domain. This file is part of the mingw-w64 runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Written by Kai Tietz kai.t.nosp@m.ietz.nosp@m.@onev.nosp@m.isio.nosp@m.n.com

Definition at line 16 of file tlssup.c.

Typedef Documentation

◆ TlsDtorNode

Function Documentation

◆ __dyn_tls_dtor()

static BOOL WINAPI __dyn_tls_dtor ( HANDLE  hDllHandle,
DWORD  dwReason,
LPVOID  lpreserved 
)
static

Definition at line 140 of file tlssup.c.

141 {
142 #if !defined (DISABLE_MS_TLS)
143  TlsDtorNode *pnode, *pnext;
144  int i;
145 #endif
146 
148  return TRUE;
149  /* As TLS variables are detroyed already by DLL_THREAD_DETACH
150  call, we have to avoid access on the possible DLL_PROCESS_DETACH
151  call the already destroyed TLS vars.
152  TODO: The used local thread based variables have to be handled
153  manually, so that we can control their lifetime here. */
154 #if !defined (DISABLE_MS_TLS)
156  {
157  for (pnode = dtor_list; pnode != NULL; pnode = pnext)
158  {
159  for (i = pnode->count - 1; i >= 0; --i)
160  {
161  if (pnode->funcs[i] != NULL)
162  (*pnode->funcs[i])();
163  }
164  pnext = pnode->next;
165  if (pnext != NULL)
166  free ((void *) pnode);
167  }
168  }
169 #endif
170  __mingw_TLScallback (hDllHandle, dwReason, lpreserved);
171  return TRUE;
172 }
struct TlsDtorNode * next
Definition: tlssup.c:35
#define TRUE
Definition: types.h:120
#define free
Definition: debug_ros.c:5
#define DLL_THREAD_DETACH
Definition: compat.h:133
DWORD dwReason
Definition: misc.cpp:154
_PVFV funcs[FUNCS_PER_NODE]
Definition: tlssup.c:36
int count
Definition: tlssup.c:34
#define DLL_PROCESS_DETACH
Definition: compat.h:130
WINBOOL __mingw_TLScallback(HANDLE hDllHandle, DWORD reason, LPVOID reserved)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112

◆ __mingw_TLScallback()

WINBOOL __mingw_TLScallback ( HANDLE  hDllHandle,
DWORD  reason,
LPVOID  reserved 
)

Referenced by __dyn_tls_dtor().

◆ _CRTALLOC() [1/3]

_CRTALLOC ( ".tls"  )

Definition at line 45 of file tlssup.c.

51  {
52  (ULONG_PTR) &_tls_start, (ULONG_PTR) &_tls_end,
53  (ULONG_PTR) &_tls_index, (ULONG_PTR) (&__xl_a+1),
54  (ULONG) 0, (ULONG) 0
55 };
uint32_t ULONG_PTR
Definition: typedefs.h:65
ULONG _tls_index
Definition: tlssup.c:39
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101

◆ _CRTALLOC() [2/3]

static _CRTALLOC ( ".CRT$XDA"  )
static

Definition at line 67 of file tlssup.c.

81 {
82  _PVFV *pfunc;
83  uintptr_t ps;
84 
85  /* We don't let us trick here. */
86  if (_CRT_MT != 2)
87  _CRT_MT = 2;
88 
90  {
92  __mingw_TLScallback (hDllHandle, dwReason, lpreserved);
93  return TRUE;
94  }
95 
96  ps = (uintptr_t) &__xd_a;
97  ps += sizeof (uintptr_t);
98  for ( ; ps != (uintptr_t) &__xd_z; ps += sizeof (uintptr_t))
99  {
100  pfunc = (_PVFV *) ps;
101  if (*pfunc != NULL)
102  (*pfunc)();
103  }
104  return TRUE;
105 }
void(__cdecl * _PVFV)(void)
Definition: internal.h:33
#define TRUE
Definition: types.h:120
#define DLL_THREAD_ATTACH
Definition: compat.h:132
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
DWORD dwReason
Definition: misc.cpp:154
unsigned int uintptr_t
Definition: crtdefs.h:321
int _CRT_MT
Definition: tlsmcrt.c:12
WINBOOL __mingw_TLScallback(HANDLE hDllHandle, DWORD reason, LPVOID reserved)
#define NULL
Definition: types.h:112

◆ _CRTALLOC() [3/3]

_CRTALLOC ( ".CRT$XLC"  )

Definition at line 108 of file tlssup.c.

114 {
115  if (!func)
116  return 0;
117 #if !defined (DISABLE_MS_TLS)
118  if (dtor_list == NULL)
119  {
120  dtor_list = &dtor_list_head;
121  dtor_list_head.count = 0;
122  }
123  else if (dtor_list->count == FUNCS_PER_NODE)
124  {
125  TlsDtorNode *pnode = (TlsDtorNode *) malloc (sizeof (TlsDtorNode));
126  if (pnode == NULL)
127  return -1;
128  pnode->count = 0;
129  pnode->next = dtor_list;
130  dtor_list = pnode;
131 
132  dtor_list->count = 0;
133  }
134  dtor_list->funcs[dtor_list->count++] = func;
135 #endif
136  return 0;
137 }
GLenum func
Definition: glext.h:6028
struct TlsDtorNode * next
Definition: tlssup.c:35
int count
Definition: tlssup.c:34
#define FUNCS_PER_NODE
Definition: tlssup.c:31
#define NULL
Definition: types.h:112
#define malloc
Definition: debug_ros.c:4

Variable Documentation

◆ __dyn_tls_init_callback

const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback = (const PIMAGE_TLS_CALLBACK) __dyn_tls_init

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 107 of file tlssup.c.

Referenced by __declspec().

◆ _tls_index

ULONG _tls_index = 0

Definition at line 39 of file tlssup.c.

Referenced by _CRTALLOC().