Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-10-10 06:32:12 +0400
committerChristopher Faylor <me@cgf.cx>2001-10-10 06:32:12 +0400
commit57013c31ecdc90515d8fabf1842831a9ab2ffca9 (patch)
treedf20a782a28fbb9fe27297f6814f7a4ea0c1a501 /winsup
parentb2a8510b89313bbac97385863e87fc19d73f2004 (diff)
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.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog20
-rw-r--r--winsup/cygwin/child_info.h12
-rw-r--r--winsup/cygwin/dcrt0.cc74
-rw-r--r--winsup/cygwin/fork.cc2
-rw-r--r--winsup/cygwin/init.cc2
-rw-r--r--winsup/cygwin/winsup.h4
6 files changed, 73 insertions, 41 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index f8b57c505..457dacb20 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -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>
* uinfo.cc (internal_getlogin): Reorganize slightly to minimize work in
diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h
index 983675877..e744f5bcf 100644
--- a/winsup/cygwin/child_info.h
+++ b/winsup/cygwin/child_info.h
@@ -13,18 +13,20 @@ details. */
enum
{
PROC_MAGIC = 0xaf12f000,
- PROC_FORK = PROC_MAGIC + 1,
- PROC_EXEC = PROC_MAGIC + 2,
- PROC_SPAWN = PROC_MAGIC + 3,
- PROC_FORK1 = PROC_MAGIC + 4, // Newer versions provide stack
+ _PROC_EXEC = PROC_MAGIC + 2,
+ _PROC_SPAWN = PROC_MAGIC + 3,
+ _PROC_FORK = PROC_MAGIC + 4, // Newer versions provide stack
// location information
- PROC_SPAWN1 = PROC_MAGIC + 5
};
#define PROC_MAGIC_MASK 0xff00f000
#define PROC_MAGIC_GENERIC 0xaf00f000
#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)
class child_info
{
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 17898b858..3e8e3ca99 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -72,6 +72,7 @@ ResourceLocks _reslock NO_COPY;
MTinterface _mtinterf;
bool NO_COPY _cygwin_testing;
+unsigned NO_COPY _cygwin_testing_magic;
extern "C"
{
@@ -515,18 +516,13 @@ alloc_stack (child_info_fork *ci)
fork on Win95, but I don't know exactly why yet. DJ */
volatile char b[ci->stacksize + 16384];
- if (ci->type == PROC_FORK)
- ci->stacksize = 0; // flag to fork not to do any funny business
- else
- {
- if (!VirtualQuery ((LPCVOID) &b, &sm, sizeof sm))
- api_fatal ("fork: couldn't get stack info, %E");
+ if (!VirtualQuery ((LPCVOID) &b, &sm, sizeof sm))
+ api_fatal ("fork: couldn't get stack info, %E");
- if (sm.AllocationBase != ci->stacktop)
- alloc_stack_hard_way (ci, b + sizeof (b) - 1);
- else
- ci->stacksize = 0;
- }
+ if (sm.AllocationBase != ci->stacktop)
+ alloc_stack_hard_way (ci, b + sizeof (b) - 1);
+ else
+ ci->stacksize = 0;
return;
}
@@ -588,20 +584,19 @@ dll_crt0_1 ()
if (child_proc_info)
{
- switch (child_proc_info->type)
+ switch (child_proc_info->type - _cygwin_testing_magic)
{
- case PROC_FORK:
- case PROC_FORK1:
+ case _PROC_FORK:
cygheap_fixup_in_child (child_proc_info, 0);
alloc_stack (fork_info);
set_myself (mypid);
ProtectHandle (child_proc_info->forker_finished);
break;
- case PROC_SPAWN:
+ case _PROC_SPAWN:
if (spawn_info->hexec_proc)
CloseHandle (spawn_info->hexec_proc);
goto around;
- case PROC_EXEC:
+ case _PROC_EXEC:
hexec_proc = spawn_info->hexec_proc;
around:
HANDLE h;
@@ -773,6 +768,31 @@ dll_crt0_1 ()
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
two symbols with the same name, but different addresses.
@@ -782,18 +802,7 @@ dll_crt0_1 ()
extern "C" void __stdcall
_dll_crt0 ()
{
- char envbuf[8];
-#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;
-
+ initial_env ();
char zeros[sizeof (fork_info->zero)] = {0};
#ifdef DEBUGGING
strace.microseconds ();
@@ -815,15 +824,14 @@ _dll_crt0 ()
if (si.cbReserved2 >= EXEC_MAGIC_SIZE &&
memcmp (fork_info->zero, zeros, sizeof (zeros)) == 0)
{
- switch (fork_info->type)
+ switch (fork_info->type - _cygwin_testing_magic)
{
- case PROC_FORK:
- case PROC_FORK1:
+ case _PROC_FORK:
user_data->forkee = fork_info->cygpid;
- case PROC_SPAWN:
+ case _PROC_SPAWN:
if (fork_info->pppid_handle)
CloseHandle (fork_info->pppid_handle);
- case PROC_EXEC:
+ case _PROC_EXEC:
{
child_proc_info = fork_info;
cygwin_mount_h = child_proc_info->mount_h;
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index 78d1abe01..0fa70814c 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -429,7 +429,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
ProtectHandle (subproc_ready);
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;
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc
index 5d2c75056..525ec29b1 100644
--- a/winsup/cygwin/init.cc
+++ b/winsup/cygwin/init.cc
@@ -13,8 +13,6 @@ details. */
#include "thread.h"
#include "perprocess.h"
-extern HMODULE cygwin_hmodule;
-
int NO_COPY dynamically_loaded;
extern "C" int
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 755d302bb..10f652dcb 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -261,4 +261,8 @@ extern BOOL display_title;
extern HANDLE hMainThread;
extern HANDLE hMainProc;
+extern bool cygwin_testing;
+extern unsigned _cygwin_testing_magic;
+extern HMODULE cygwin_hmodule;
+
#endif /* defined __cplusplus */