57013c31ec
* child_info.h: Rename PROC_* to _PROC_*. Define PROC_* with additional testing magic. Eliminate old PROC_FORK and rename PROC_FORK1 to PROC_FORK. * dcrt0.cc (_cygwin_testing_magic): New variable. Added to magic number in proc_info. (alloc_stack): Eliminate old PROC_FORK test. (dll_crt0_1): Ditto. Use _PROC_* enums for test. Subtract _cygwin_testing_magic from child_proc_info->type so that normal cygwin programs invoked by test suite programs do not consider themselves to be in a cygwin environment. (_dll_crt0): Ditto. Move environment checks to initial_env function to conserve on stack space. (initial_env): New function. Checks for testing and debugging environment variables. * init.cc (cygwin_hmodule): Move declaration. * winsup.h: Declare variables used for cygwin testing.
55 lines
1.2 KiB
C++
55 lines
1.2 KiB
C++
/* init.cc
|
|
|
|
Copyright 1996, 1997, 1998, 1999, 2000, 2001 Red Hat, Inc.
|
|
|
|
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"
|
|
#include <stdlib.h>
|
|
#include "thread.h"
|
|
#include "perprocess.h"
|
|
|
|
int NO_COPY dynamically_loaded;
|
|
|
|
extern "C" int
|
|
WINAPI dll_entry (HANDLE h, DWORD reason, void *static_load)
|
|
{
|
|
switch (reason)
|
|
{
|
|
case DLL_PROCESS_ATTACH:
|
|
cygwin_hmodule = (HMODULE) h;
|
|
dynamically_loaded = (static_load == NULL);
|
|
break;
|
|
case DLL_THREAD_ATTACH:
|
|
if (user_data->threadinterface)
|
|
{
|
|
if (!TlsSetValue(user_data->threadinterface->reent_index,
|
|
&user_data->threadinterface->reents))
|
|
api_fatal("Sig proc MT init failed\n");
|
|
}
|
|
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;
|
|
}
|