2000-02-17 20:38:33 +01:00
|
|
|
/* init.cc for WIN32.
|
|
|
|
|
2000-02-24 03:49:44 +01:00
|
|
|
Copyright 1996, 1997, 1998, 1999, 2000 Cygnus Solutions.
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
#include "winsup.h"
|
2000-08-02 18:28:18 +02:00
|
|
|
#include <stdlib.h>
|
2000-08-22 07:10:20 +02:00
|
|
|
#include "thread.h"
|
2000-09-08 04:56:55 +02:00
|
|
|
#include "perprocess.h"
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2000-02-24 03:49:44 +01:00
|
|
|
extern HMODULE cygwin_hmodule;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
int NO_COPY dynamically_loaded;
|
|
|
|
|
2000-02-24 03:49:44 +01:00
|
|
|
extern "C" int
|
|
|
|
WINAPI dll_entry (HANDLE h, DWORD reason, void *static_load)
|
2000-02-17 20:38:33 +01:00
|
|
|
{
|
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2000-02-24 03:49:44 +01:00
|
|
|
cygwin_hmodule = (HMODULE) h;
|
2000-02-17 20:38:33 +01:00
|
|
|
dynamically_loaded = (static_load == NULL);
|
|
|
|
break;
|
|
|
|
case DLL_THREAD_ATTACH:
|
2000-04-17 00:57:05 +02:00
|
|
|
if (user_data->threadinterface)
|
2000-04-15 05:52:24 +02:00
|
|
|
{
|
2000-09-04 19:52:42 +02:00
|
|
|
if (!TlsSetValue(user_data->threadinterface->reent_index,
|
2000-09-03 06:16:35 +02:00
|
|
|
&user_data->threadinterface->reents))
|
2000-04-15 05:52:24 +02:00
|
|
|
api_fatal("Sig proc MT init failed\n");
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
break;
|
|
|
|
case DLL_THREAD_DETACH:
|
|
|
|
#if 0 // FIXME: REINSTATE SOON
|
|
|
|
waitq *w;
|
|
|
|
if ((w = waitq_storage.get ()) != NULL)
|
|
|
|
{
|
|
|
|
if (w->thread_ev != NULL)
|
|
|
|
{
|
|
|
|
system_printf ("closing %p", w->thread_ev);
|
|
|
|
(void) CloseHandle (w->thread_ev);
|
|
|
|
}
|
|
|
|
memset (w, 0, sizeof(*w)); // FIXME: memory leak
|
|
|
|
}
|
|
|
|
// FIXME: Need to add other per_thread stuff here
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|