~steve-sk2/mingw-w64/oneiric

« back to all changes in this revision

Viewing changes to mingw-w64-crt/crt/tlssup.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Kitt
  • Date: 2010-11-18 00:04:46 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101118000446-xe24b423su55onyl
Tags: 1.0+20101003-1
* New maintainer. (Closes: #594371.)
* New upstream snapshot:
  - Includes getopt.h. (Closes: #569914.)
* Build g++ for Win64. (Closes: #600451.)
* Standards-Version 3.9.1 (new packaging).
* Include patch from
  http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64?view=revision&revision=3715
  as suggested by Rafaël Carré.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
#undef CRTDLL
11
11
#endif
12
12
 
 
13
#include <internal.h>
 
14
#include <sect_attribs.h>
 
15
 
 
16
#ifndef WIN32_LEAN_AND_MEAN
 
17
#define WIN32_LEAN_AND_MEAN
 
18
#endif
13
19
#include <windows.h>
14
 
#include <stdio.h>
15
 
#include <memory.h>
 
20
 
16
21
#include <malloc.h>
17
 
 
18
 
#ifndef _CRTALLOC
19
 
#define _CRTALLOC(x) __attribute__ ((section (x) ))
20
 
#endif
21
 
 
22
 
#ifndef __INTERNAL_FUNC_DEFINED
23
 
#define __INTERNAL_FUNC_DEFINED
24
 
  typedef void (__cdecl *_PVFV)(void);
25
 
  typedef int (__cdecl *_PIFV)(void);
26
 
  typedef void (__cdecl *_PVFI)(int);
27
 
#endif
 
22
#include <crtdbg.h>
28
23
 
29
24
extern WINBOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved);
30
25
 
78
73
 
79
74
extern int _CRT_MT;
80
75
 
81
 
#ifndef _WIN64
82
 
#define MINGWM10_DLL "mingwm10.dll"
83
 
typedef int (*fMTRemoveKeyDtor)(DWORD key);
84
 
typedef int (*fMTKeyDtor)(DWORD key, void (*dtor)(void *));
85
 
fMTRemoveKeyDtor __mingw_gMTRemoveKeyDtor;
86
 
fMTKeyDtor __mingw_gMTKeyDtor;
87
 
int __mingw_usemthread_dll;
88
 
static HANDLE __mingw_mthread_hdll;
89
 
#endif
90
 
 
91
76
BOOL WINAPI __dyn_tls_init (HANDLE, DWORD, LPVOID);
92
77
 
93
78
BOOL WINAPI
94
79
__dyn_tls_init (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
95
80
{
96
81
  _PVFV *pfunc;
 
82
  uintptr_t ps;
97
83
 
98
 
#ifndef _WIN64
99
 
  if (_winmajor < 4)
100
 
  {
101
 
    __mingw_usemthread_dll = 1;
102
 
    __mingw_mthread_hdll = LoadLibrary (MINGWM10_DLL);
103
 
    if (__mingw_mthread_hdll != NULL)
104
 
    {
105
 
      __mingw_gMTRemoveKeyDtor = (fMTRemoveKeyDtor) GetProcAddress (__mingw_mthread_hdll, "__mingwthr_remove_key_dtor");
106
 
      __mingw_gMTKeyDtor = (fMTKeyDtor)  GetProcAddress (__mingw_mthread_hdll, "__mingwthr_key_dtor");
107
 
    }
108
 
    if (__mingw_mthread_hdll == NULL || !__mingw_gMTRemoveKeyDtor || !__mingw_gMTKeyDtor)
109
 
      {
110
 
        __mingw_gMTKeyDtor = NULL;
111
 
        __mingw_gMTRemoveKeyDtor = NULL;
112
 
        if (__mingw_mthread_hdll)
113
 
          FreeLibrary (__mingw_mthread_hdll);
114
 
        __mingw_mthread_hdll = NULL;
115
 
        _CRT_MT = 0;
116
 
        return TRUE;
117
 
      }
118
 
    _CRT_MT = 1;
119
 
    return TRUE;
120
 
  }
121
 
#endif
122
84
  /* We don't let us trick here.  */
123
85
  if (_CRT_MT != 2)
124
86
   _CRT_MT = 2;
130
92
      return TRUE;
131
93
    }
132
94
 
133
 
  for (pfunc = &__xd_a + 1; pfunc != &__xd_z; ++pfunc)
 
95
  ps = (uintptr_t) &__xd_a;
 
96
  ps += sizeof (uintptr_t);
 
97
  for ( ; ps != (uintptr_t) &__xd_z; ps += sizeof (uintptr_t))
134
98
    {
 
99
      pfunc = (_PVFV *) ps;
135
100
      if (*pfunc != NULL)
136
101
        (*pfunc)();
137
102
    }
209
174
 
210
175
 
211
176
int mingw_initltsdrot_force = 0;
212
 
int mingw_initltsdyn_force=0;
 
177
int mingw_initltsdyn_force = 0;
213
178
int mingw_initltssuo_force = 0;