OSDN Git Service

Break out more header info into separate files. Use appropriate header files
[pf3gnuchains/pf3gnuchains3x.git] / winsup / cygwin / init.cc
1 /* init.cc for WIN32.
2
3    Copyright 1996, 1997, 1998, 1999, 2000 Cygnus Solutions.
4
5 This file is part of Cygwin.
6
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
9 details. */
10
11 #include "winsup.h"
12 #include <stdlib.h>
13 #include "thread.h"
14 #include "perprocess.h"
15
16 extern HMODULE cygwin_hmodule;
17
18 int NO_COPY dynamically_loaded;
19
20 extern "C" int
21 WINAPI dll_entry (HANDLE h, DWORD reason, void *static_load)
22 {
23   switch (reason)
24     {
25     case DLL_PROCESS_ATTACH:
26       cygwin_hmodule = (HMODULE) h;
27       dynamically_loaded = (static_load == NULL);
28       break;
29     case DLL_THREAD_ATTACH:
30       if (user_data->threadinterface)
31         {
32           if (!TlsSetValue(user_data->threadinterface->reent_index,
33                     &user_data->threadinterface->reents))
34             api_fatal("Sig proc MT init failed\n");
35         }
36       break;
37     case DLL_PROCESS_DETACH:
38       break;
39     case DLL_THREAD_DETACH:
40 #if 0 // FIXME: REINSTATE SOON
41       waitq *w;
42       if ((w = waitq_storage.get ()) != NULL)
43         {
44           if (w->thread_ev != NULL)
45             {
46               system_printf ("closing %p", w->thread_ev);
47               (void) CloseHandle (w->thread_ev);
48             }
49           memset (w, 0, sizeof(*w));    // FIXME: memory leak
50         }
51         // FIXME: Need to add other per_thread stuff here
52 #endif
53       break;
54     }
55   return 1;
56 }