2001-09-12 04:01:02 +08:00
|
|
|
/* init.cc
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2002-09-17 00:09:54 +08:00
|
|
|
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
2000-02-18 03:38:33 +08: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-03 00:28:18 +08:00
|
|
|
#include <stdlib.h>
|
2000-08-22 13:10:20 +08:00
|
|
|
#include "thread.h"
|
2000-09-08 10:56:55 +08:00
|
|
|
#include "perprocess.h"
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
int NO_COPY dynamically_loaded;
|
|
|
|
|
2000-02-24 10:49:44 +08:00
|
|
|
extern "C" int
|
|
|
|
WINAPI dll_entry (HANDLE h, DWORD reason, void *static_load)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2000-02-24 10:49:44 +08:00
|
|
|
cygwin_hmodule = (HMODULE) h;
|
2000-02-18 03:38:33 +08:00
|
|
|
dynamically_loaded = (static_load == NULL);
|
|
|
|
break;
|
|
|
|
case DLL_THREAD_ATTACH:
|
2000-04-17 06:57:05 +08:00
|
|
|
if (user_data->threadinterface)
|
2000-04-15 11:52:24 +08:00
|
|
|
{
|
2002-09-22 11:38:57 +08:00
|
|
|
if (!TlsSetValue (user_data->threadinterface->reent_index,
|
|
|
|
&user_data->threadinterface->reents))
|
|
|
|
api_fatal ("Sig proc MT init failed\n");
|
2000-04-15 11:52:24 +08:00
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
break;
|
|
|
|
case DLL_THREAD_DETACH:
|
2002-09-22 11:38:57 +08:00
|
|
|
#if 0
|
|
|
|
pthread *thisthread = (pthread *)
|
|
|
|
TlsGetValue (user_data->threadinterface->thread_self_dwTlsIndex);
|
2002-09-16 18:53:29 +08:00
|
|
|
if (thisthread) {
|
2002-09-17 00:09:54 +08:00
|
|
|
/* Some non-pthread call created this thread,
|
2002-09-16 18:53:29 +08:00
|
|
|
* but we need to clean it up */
|
2002-09-22 11:38:57 +08:00
|
|
|
thisthread->exit (0);
|
2002-09-16 18:53:29 +08:00
|
|
|
}
|
2002-09-22 11:38:57 +08:00
|
|
|
#endif
|
2000-02-18 03:38:33 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|