Throughout, rename PROC_FORK1 to PROC_FORK.
* 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.
This commit is contained in:
parent
b2a8510b89
commit
57013c31ec
|
@ -1,3 +1,23 @@
|
||||||
|
Tue Oct 9 22:22:45 2001 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
Throughout, rename PROC_FORK1 to PROC_FORK.
|
||||||
|
* 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.
|
||||||
|
|
||||||
Tue Oct 9 19:17:53 2001 Christopher Faylor <cgf@cygnus.com>
|
Tue Oct 9 19:17:53 2001 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* uinfo.cc (internal_getlogin): Reorganize slightly to minimize work in
|
* uinfo.cc (internal_getlogin): Reorganize slightly to minimize work in
|
||||||
|
|
|
@ -13,18 +13,20 @@ details. */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROC_MAGIC = 0xaf12f000,
|
PROC_MAGIC = 0xaf12f000,
|
||||||
PROC_FORK = PROC_MAGIC + 1,
|
_PROC_EXEC = PROC_MAGIC + 2,
|
||||||
PROC_EXEC = PROC_MAGIC + 2,
|
_PROC_SPAWN = PROC_MAGIC + 3,
|
||||||
PROC_SPAWN = PROC_MAGIC + 3,
|
_PROC_FORK = PROC_MAGIC + 4, // Newer versions provide stack
|
||||||
PROC_FORK1 = PROC_MAGIC + 4, // Newer versions provide stack
|
|
||||||
// location information
|
// location information
|
||||||
PROC_SPAWN1 = PROC_MAGIC + 5
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PROC_MAGIC_MASK 0xff00f000
|
#define PROC_MAGIC_MASK 0xff00f000
|
||||||
#define PROC_MAGIC_GENERIC 0xaf00f000
|
#define PROC_MAGIC_GENERIC 0xaf00f000
|
||||||
#define PROC_MAGIC_VER_MASK 0x0ff0000
|
#define PROC_MAGIC_VER_MASK 0x0ff0000
|
||||||
|
|
||||||
|
#define PROC_EXEC (_PROC_EXEC + _cygwin_testing_magic)
|
||||||
|
#define PROC_SPAWN (_PROC_SPAWN + _cygwin_testing_magic)
|
||||||
|
#define PROC_FORK (_PROC_FORK + _cygwin_testing_magic)
|
||||||
|
|
||||||
#define EXEC_MAGIC_SIZE sizeof(child_info)
|
#define EXEC_MAGIC_SIZE sizeof(child_info)
|
||||||
class child_info
|
class child_info
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,6 +72,7 @@ ResourceLocks _reslock NO_COPY;
|
||||||
MTinterface _mtinterf;
|
MTinterface _mtinterf;
|
||||||
|
|
||||||
bool NO_COPY _cygwin_testing;
|
bool NO_COPY _cygwin_testing;
|
||||||
|
unsigned NO_COPY _cygwin_testing_magic;
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
@ -515,18 +516,13 @@ alloc_stack (child_info_fork *ci)
|
||||||
fork on Win95, but I don't know exactly why yet. DJ */
|
fork on Win95, but I don't know exactly why yet. DJ */
|
||||||
volatile char b[ci->stacksize + 16384];
|
volatile char b[ci->stacksize + 16384];
|
||||||
|
|
||||||
if (ci->type == PROC_FORK)
|
if (!VirtualQuery ((LPCVOID) &b, &sm, sizeof sm))
|
||||||
ci->stacksize = 0; // flag to fork not to do any funny business
|
api_fatal ("fork: couldn't get stack info, %E");
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!VirtualQuery ((LPCVOID) &b, &sm, sizeof sm))
|
|
||||||
api_fatal ("fork: couldn't get stack info, %E");
|
|
||||||
|
|
||||||
if (sm.AllocationBase != ci->stacktop)
|
if (sm.AllocationBase != ci->stacktop)
|
||||||
alloc_stack_hard_way (ci, b + sizeof (b) - 1);
|
alloc_stack_hard_way (ci, b + sizeof (b) - 1);
|
||||||
else
|
else
|
||||||
ci->stacksize = 0;
|
ci->stacksize = 0;
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -588,20 +584,19 @@ dll_crt0_1 ()
|
||||||
|
|
||||||
if (child_proc_info)
|
if (child_proc_info)
|
||||||
{
|
{
|
||||||
switch (child_proc_info->type)
|
switch (child_proc_info->type - _cygwin_testing_magic)
|
||||||
{
|
{
|
||||||
case PROC_FORK:
|
case _PROC_FORK:
|
||||||
case PROC_FORK1:
|
|
||||||
cygheap_fixup_in_child (child_proc_info, 0);
|
cygheap_fixup_in_child (child_proc_info, 0);
|
||||||
alloc_stack (fork_info);
|
alloc_stack (fork_info);
|
||||||
set_myself (mypid);
|
set_myself (mypid);
|
||||||
ProtectHandle (child_proc_info->forker_finished);
|
ProtectHandle (child_proc_info->forker_finished);
|
||||||
break;
|
break;
|
||||||
case PROC_SPAWN:
|
case _PROC_SPAWN:
|
||||||
if (spawn_info->hexec_proc)
|
if (spawn_info->hexec_proc)
|
||||||
CloseHandle (spawn_info->hexec_proc);
|
CloseHandle (spawn_info->hexec_proc);
|
||||||
goto around;
|
goto around;
|
||||||
case PROC_EXEC:
|
case _PROC_EXEC:
|
||||||
hexec_proc = spawn_info->hexec_proc;
|
hexec_proc = spawn_info->hexec_proc;
|
||||||
around:
|
around:
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
|
@ -773,6 +768,31 @@ dll_crt0_1 ()
|
||||||
exit (user_data->main (__argc, __argv, *user_data->envptr));
|
exit (user_data->main (__argc, __argv, *user_data->envptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
initial_env ()
|
||||||
|
{
|
||||||
|
char buf[MAX_PATH + 1];
|
||||||
|
#ifdef DEBUGGING
|
||||||
|
if (GetEnvironmentVariable ("CYGWIN_SLEEP", buf, sizeof (buf) - 1))
|
||||||
|
{
|
||||||
|
console_printf ("Sleeping %d, pid %u\n", atoi (buf), GetCurrentProcessId ());
|
||||||
|
Sleep (atoi (buf));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (GetEnvironmentVariable ("CYGWIN_TESTING", buf, sizeof (buf) - 1))
|
||||||
|
{
|
||||||
|
_cygwin_testing = 1;
|
||||||
|
DWORD len;
|
||||||
|
if ((len = GetModuleFileName (cygwin_hmodule, buf, MAX_PATH))
|
||||||
|
&& len > sizeof ("new-cygwin1.dll")
|
||||||
|
&& strcasematch (buf + len - sizeof ("new-cygwin1.dll"),
|
||||||
|
"\\new-cygwin1.dll"))
|
||||||
|
_cygwin_testing_magic = 0x10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Wrap the real one, otherwise gdb gets confused about
|
/* Wrap the real one, otherwise gdb gets confused about
|
||||||
two symbols with the same name, but different addresses.
|
two symbols with the same name, but different addresses.
|
||||||
|
|
||||||
|
@ -782,18 +802,7 @@ dll_crt0_1 ()
|
||||||
extern "C" void __stdcall
|
extern "C" void __stdcall
|
||||||
_dll_crt0 ()
|
_dll_crt0 ()
|
||||||
{
|
{
|
||||||
char envbuf[8];
|
initial_env ();
|
||||||
#ifdef DEBUGGING
|
|
||||||
if (GetEnvironmentVariable ("CYGWIN_SLEEP", envbuf, sizeof (envbuf) - 1))
|
|
||||||
{
|
|
||||||
console_printf ("Sleeping %d, pid %u\n", atoi (envbuf), GetCurrentProcessId ());
|
|
||||||
Sleep (atoi (envbuf));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (GetEnvironmentVariable ("CYGWIN_TESTING", envbuf, sizeof (envbuf) - 1))
|
|
||||||
_cygwin_testing = 1;
|
|
||||||
|
|
||||||
char zeros[sizeof (fork_info->zero)] = {0};
|
char zeros[sizeof (fork_info->zero)] = {0};
|
||||||
#ifdef DEBUGGING
|
#ifdef DEBUGGING
|
||||||
strace.microseconds ();
|
strace.microseconds ();
|
||||||
|
@ -815,15 +824,14 @@ _dll_crt0 ()
|
||||||
if (si.cbReserved2 >= EXEC_MAGIC_SIZE &&
|
if (si.cbReserved2 >= EXEC_MAGIC_SIZE &&
|
||||||
memcmp (fork_info->zero, zeros, sizeof (zeros)) == 0)
|
memcmp (fork_info->zero, zeros, sizeof (zeros)) == 0)
|
||||||
{
|
{
|
||||||
switch (fork_info->type)
|
switch (fork_info->type - _cygwin_testing_magic)
|
||||||
{
|
{
|
||||||
case PROC_FORK:
|
case _PROC_FORK:
|
||||||
case PROC_FORK1:
|
|
||||||
user_data->forkee = fork_info->cygpid;
|
user_data->forkee = fork_info->cygpid;
|
||||||
case PROC_SPAWN:
|
case _PROC_SPAWN:
|
||||||
if (fork_info->pppid_handle)
|
if (fork_info->pppid_handle)
|
||||||
CloseHandle (fork_info->pppid_handle);
|
CloseHandle (fork_info->pppid_handle);
|
||||||
case PROC_EXEC:
|
case _PROC_EXEC:
|
||||||
{
|
{
|
||||||
child_proc_info = fork_info;
|
child_proc_info = fork_info;
|
||||||
cygwin_mount_h = child_proc_info->mount_h;
|
cygwin_mount_h = child_proc_info->mount_h;
|
||||||
|
|
|
@ -429,7 +429,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
|
||||||
ProtectHandle (subproc_ready);
|
ProtectHandle (subproc_ready);
|
||||||
ProtectHandle (forker_finished);
|
ProtectHandle (forker_finished);
|
||||||
|
|
||||||
init_child_info (PROC_FORK1, &ch, 1, subproc_ready);
|
init_child_info (PROC_FORK, &ch, 1, subproc_ready);
|
||||||
|
|
||||||
ch.forker_finished = forker_finished;
|
ch.forker_finished = forker_finished;
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,6 @@ details. */
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
|
|
||||||
extern HMODULE cygwin_hmodule;
|
|
||||||
|
|
||||||
int NO_COPY dynamically_loaded;
|
int NO_COPY dynamically_loaded;
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
|
|
|
@ -261,4 +261,8 @@ extern BOOL display_title;
|
||||||
extern HANDLE hMainThread;
|
extern HANDLE hMainThread;
|
||||||
extern HANDLE hMainProc;
|
extern HANDLE hMainProc;
|
||||||
|
|
||||||
|
extern bool cygwin_testing;
|
||||||
|
extern unsigned _cygwin_testing_magic;
|
||||||
|
extern HMODULE cygwin_hmodule;
|
||||||
|
|
||||||
#endif /* defined __cplusplus */
|
#endif /* defined __cplusplus */
|
||||||
|
|
Loading…
Reference in New Issue