ReactOS  0.4.14-dev-342-gdc047f9
tlssup.c File Reference
#include <sect_attribs.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <stdio.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>
Include dependency graph for tlssup.c:

Go to the source code of this file.

Classes

struct  TlsDtorNode
 

Macros

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

Typedefs

typedef void(__cdecl_PVFV) (void)
 
typedef int(__cdecl_PIFV) (void)
 
typedef void(__cdecl_PVFI) (int)
 
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 67 of file tlssup.c.

◆ __INTERNAL_FUNC_DEFINED

#define __INTERNAL_FUNC_DEFINED

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.

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

Definition at line 32 of file tlssup.c.

◆ DISABLE_MS_TLS

#define DISABLE_MS_TLS   1

Definition at line 71 of file tlssup.c.

◆ FUNCS_PER_NODE

#define FUNCS_PER_NODE   30

Definition at line 40 of file tlssup.c.

Typedef Documentation

◆ _PIFV

typedef int(__cdecl * _PIFV) (void)

Definition at line 34 of file tlssup.c.

◆ _PVFI

typedef void(__cdecl * _PVFI) (int)

Definition at line 35 of file tlssup.c.

◆ _PVFV

typedef void(__cdecl * _PVFV) (void)

Definition at line 33 of file tlssup.c.

◆ TlsDtorNode

Function Documentation

◆ __dyn_tls_dtor()

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

Definition at line 150 of file tlssup.c.

151 {
152 #if !defined (DISABLE_MS_TLS)
153  TlsDtorNode *pnode, *pnext;
154  int i;
155 #endif
156 
158  return TRUE;
159  /* As TLS variables are detroyed already by DLL_THREAD_DETACH
160  call, we have to avoid access on the possible DLL_PROCESS_DETACH
161  call the already destroyed TLS vars.
162  TODO: The used local thread based variables have to be handled
163  manually, so that we can control their lifetime here. */
164 #if !defined (DISABLE_MS_TLS)
166  {
167  for (pnode = dtor_list; pnode != NULL; pnode = pnext)
168  {
169  for (i = pnode->count - 1; i >= 0; --i)
170  {
171  if (pnode->funcs[i] != NULL)
172  (*pnode->funcs[i])();
173  }
174  pnext = pnode->next;
175  if (pnext != NULL)
176  free ((void *) pnode);
177  }
178  }
179 #endif
180  __mingw_TLScallback (hDllHandle, dwReason, lpreserved);
181  return TRUE;
182 }
struct TlsDtorNode * next
Definition: tlssup.c:44
#define TRUE
Definition: types.h:120
#define free
Definition: debug_ros.c:5
#define DLL_THREAD_DETACH
Definition: compat.h:122
DWORD dwReason
Definition: misc.cpp:154
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
smooth NULL
Definition: ftsmooth.c:416
_PVFV funcs[FUNCS_PER_NODE]
Definition: tlssup.c:45
int count
Definition: tlssup.c:43
#define DLL_PROCESS_DETACH
Definition: compat.h:119
WINBOOL __mingw_TLScallback(HANDLE hDllHandle, DWORD reason, LPVOID reserved)

◆ __mingw_TLScallback()

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

Referenced by __dyn_tls_dtor().

◆ _CRTALLOC() [1/3]

_CRTALLOC ( ".tls"  )

Definition at line 51 of file tlssup.c.

57  {
58  (ULONG_PTR) &_tls_start+1, (ULONG_PTR) &_tls_end,
59  (ULONG_PTR) &_tls_index, (ULONG_PTR) (&__xl_a+1),
60  (ULONG) 0, (ULONG) 0
61 };
uint32_t ULONG_PTR
Definition: typedefs.h:63
ULONG _tls_index
Definition: tlssup.c:48
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 73 of file tlssup.c.

91 {
92  _PVFV *pfunc;
93  uintptr_t ps;
94 
95  /* We don't let us trick here. */
96  if (_CRT_MT != 2)
97  _CRT_MT = 2;
98 
100  {
102  __mingw_TLScallback (hDllHandle, dwReason, lpreserved);
103  return TRUE;
104  }
105 
106  ps = (uintptr_t) &__xd_a;
107  ps += sizeof (uintptr_t);
108  for ( ; ps != (uintptr_t) &__xd_z; ps += sizeof (uintptr_t))
109  {
110  pfunc = (_PVFV *) ps;
111  if (*pfunc != NULL)
112  (*pfunc)();
113  }
114  return TRUE;
115 }
#define TRUE
Definition: types.h:120
#define DLL_THREAD_ATTACH
Definition: compat.h:121
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
DWORD dwReason
Definition: misc.cpp:154
unsigned int uintptr_t
Definition: crtdefs.h:300
smooth NULL
Definition: ftsmooth.c:416
int _CRT_MT
Definition: tlsmcrt.c:12
void(__cdecl * _PVFV)(void)
Definition: tlssup.c:33
WINBOOL __mingw_TLScallback(HANDLE hDllHandle, DWORD reason, LPVOID reserved)

◆ _CRTALLOC() [3/3]

_CRTALLOC ( ".CRT$XLC"  )

Definition at line 118 of file tlssup.c.

124 {
125  if (!func)
126  return 0;
127 #if !defined (DISABLE_MS_TLS)
128  if (dtor_list == NULL)
129  {
130  dtor_list = &dtor_list_head;
131  dtor_list_head.count = 0;
132  }
133  else if (dtor_list->count == FUNCS_PER_NODE)
134  {
135  TlsDtorNode *pnode = (TlsDtorNode *) malloc (sizeof (TlsDtorNode));
136  if (pnode == NULL)
137  return -1;
138  pnode->count = 0;
139  pnode->next = dtor_list;
140  dtor_list = pnode;
141 
142  dtor_list->count = 0;
143  }
144  dtor_list->funcs[dtor_list->count++] = func;
145 #endif
146  return 0;
147 }
GLenum func
Definition: glext.h:6028
struct TlsDtorNode * next
Definition: tlssup.c:44
smooth NULL
Definition: ftsmooth.c:416
int count
Definition: tlssup.c:43
#define FUNCS_PER_NODE
Definition: tlssup.c:40
#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 117 of file tlssup.c.

Referenced by __declspec().

◆ _tls_index

ULONG _tls_index = 0

Definition at line 48 of file tlssup.c.

Referenced by _CRTALLOC().