~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/msvcrt/main.c

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * msvcrt.dll initialisation functions
  3  *
  4  * Copyright 2000 Jon Griffiths
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 #include "msvcrt.h"
 21 
 22 #include "wine/debug.h"
 23 
 24 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
 25 
 26 /* Index to TLS */
 27 DWORD msvcrt_tls_index;
 28 
 29 static const char* msvcrt_get_reason(DWORD reason)
 30 {
 31   switch (reason)
 32   {
 33   case DLL_PROCESS_ATTACH: return "DLL_PROCESS_ATTACH";
 34   case DLL_PROCESS_DETACH: return "DLL_PROCESS_DETACH";
 35   case DLL_THREAD_ATTACH:  return "DLL_THREAD_ATTACH";
 36   case DLL_THREAD_DETACH:  return "DLL_THREAD_DETACH";
 37   }
 38   return "UNKNOWN";
 39 }
 40 
 41 static inline BOOL msvcrt_init_tls(void)
 42 {
 43   msvcrt_tls_index = TlsAlloc();
 44 
 45   if (msvcrt_tls_index == TLS_OUT_OF_INDEXES)
 46   {
 47     ERR("TlsAlloc() failed!\n");
 48     return FALSE;
 49   }
 50   return TRUE;
 51 }
 52 
 53 static inline BOOL msvcrt_free_tls(void)
 54 {
 55   if (!TlsFree(msvcrt_tls_index))
 56   {
 57     ERR("TlsFree() failed!\n");
 58     return FALSE;
 59   }
 60   return TRUE;
 61 }
 62 
 63 /*********************************************************************
 64  *                  Init
 65  */
 66 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 67 {
 68   thread_data_t *tls;
 69 
 70   TRACE("(%p, %s, %p) pid(%x), tid(%x), tls(%u)\n",
 71         hinstDLL, msvcrt_get_reason(fdwReason), lpvReserved,
 72         GetCurrentProcessId(), GetCurrentThreadId(),
 73         msvcrt_tls_index);
 74 
 75   switch (fdwReason)
 76   {
 77   case DLL_PROCESS_ATTACH:
 78     if (!msvcrt_init_tls())
 79       return FALSE;
 80     msvcrt_init_mt_locks();
 81     msvcrt_init_io();
 82     msvcrt_init_console();
 83     msvcrt_init_args();
 84     msvcrt_init_signals();
 85     MSVCRT_setlocale(0, "C");
 86     _setmbcp(_MB_CP_LOCALE);
 87     TRACE("finished process init\n");
 88     break;
 89   case DLL_THREAD_ATTACH:
 90     break;
 91   case DLL_PROCESS_DETACH:
 92     msvcrt_free_mt_locks();
 93     msvcrt_free_io();
 94     msvcrt_free_console();
 95     msvcrt_free_args();
 96     msvcrt_free_signals();
 97     if (!msvcrt_free_tls())
 98       return FALSE;
 99     TRACE("finished process free\n");
100     break;
101   case DLL_THREAD_DETACH:
102     /* Free TLS */
103     tls = TlsGetValue(msvcrt_tls_index);
104     if (tls)
105     {
106         HeapFree(GetProcessHeap(),0,tls->efcvt_buffer);
107         HeapFree(GetProcessHeap(),0,tls->asctime_buffer);
108         HeapFree(GetProcessHeap(),0,tls->wasctime_buffer);
109         HeapFree(GetProcessHeap(),0,tls->strerror_buffer);
110     }
111     HeapFree(GetProcessHeap(), 0, tls);
112     TRACE("finished thread free\n");
113     break;
114   }
115   return TRUE;
116 }
117 
118 /*********************************************************************
119  *              $I10_OUTPUT (MSVCRT.@)
120  * Function not really understood but needed to make the DLL work
121  */
122 void CDECL MSVCRT_I10_OUTPUT(void)
123 {
124   /* FIXME: This is probably data, not a function */
125   /* no it is a function. I10 is an Int of 10 bytes */
126   /* also known as 80 bit floating point (long double */
127   /* for some compilers, not MSVC) */
128 }
129 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.