summaryrefslogtreecommitdiffstats
path: root/winsup
diff options
context:
space:
mode:
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog9
-rw-r--r--winsup/cygwin/child_info.h4
-rw-r--r--winsup/cygwin/dcrt0.cc39
3 files changed, 31 insertions, 21 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index eda9f431e..c2d95236b 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,12 @@
+2006-04-03 Christopher Faylor <cgf@timesys.com>
+
+ * child_info.h (CURR_CHILD_INFO_MAGIC): Update.
+ (child_info_fork::alloc_stack): Move into this class.
+ (child_info_fork::alloc_stack_hard_way): Ditto.
+ * dcrt0.cc (child_info_fork::alloc_stack): Ditto.
+ (child_info_fork::alloc_stack_hard_way): Ditto.
+ (_dll_crt0): Reference alloc_stack via fork_info.
+
2006-04-03 Corinna Vinschen <corinna@vinschen.de>
* spawn.cc (linebuf::finish): Drop argument. Don't check command line
diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h
index c9f6eae2f..4d0ea0195 100644
--- a/winsup/cygwin/child_info.h
+++ b/winsup/cygwin/child_info.h
@@ -36,7 +36,7 @@ enum child_status
#define EXEC_MAGIC_SIZE sizeof(child_info)
/* Change this value if you get a message indicating that it is out-of-sync. */
-#define CURR_CHILD_INFO_MAGIC 0x1630848cU
+#define CURR_CHILD_INFO_MAGIC 0x110015eaU
/* NOTE: Do not make gratuitous changes to the names or organization of the
below class. The layout is checksummed to determine compatibility between
@@ -84,6 +84,8 @@ public:
child_info_fork ();
void handle_fork () __attribute__ ((regparm (1)));;
bool handle_failure (DWORD) __attribute__ ((regparm (2)));
+ void alloc_stack ();
+ void alloc_stack_hard_way (volatile char *);
};
class fhandler_base;
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 564e6efbd..6a6ced98a 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -456,8 +456,8 @@ child_info NO_COPY *child_proc_info = NULL;
#define CYGWIN_GUARD ((wincap.has_page_guard ()) ? \
PAGE_EXECUTE_READWRITE|PAGE_GUARD : PAGE_NOACCESS)
-static void
-alloc_stack_hard_way (child_info_fork *ci, volatile char *b)
+void
+child_info_fork::alloc_stack_hard_way (volatile char *b)
{
void *new_stack_pointer;
MEMORY_BASIC_INFORMATION m;
@@ -470,28 +470,27 @@ alloc_stack_hard_way (child_info_fork *ci, volatile char *b)
LPBYTE curbot = (LPBYTE) m.BaseAddress + m.RegionSize;
- if (ci->stacktop > (LPBYTE) m.AllocationBase && ci->stacktop < curbot)
+ if (stacktop > (LPBYTE) m.AllocationBase && stacktop < curbot)
{
newbase = curbot;
- newlen = (LPBYTE) ci->stackbottom - (LPBYTE) curbot;
+ newlen = (LPBYTE) stackbottom - (LPBYTE) curbot;
noguard = 1;
}
else
{
- newbase = ci->stacktop;
- newlen = (DWORD) ci->stackbottom - (DWORD) ci->stacktop;
+ newbase = stacktop;
+ newlen = (DWORD) stackbottom - (DWORD) stacktop;
noguard = 0;
}
if (!VirtualAlloc (newbase, newlen, MEM_RESERVE, PAGE_NOACCESS))
api_fatal ("fork: can't reserve memory for stack %p - %p, %E",
- ci->stacktop, ci->stackbottom);
-
- new_stack_pointer = (void *) ((LPBYTE) ci->stackbottom - ci->stacksize);
+ stacktop, stackbottom);
- if (!VirtualAlloc (new_stack_pointer, ci->stacksize, MEM_COMMIT,
+ new_stack_pointer = (void *) ((LPBYTE) stackbottom - stacksize);
+ if (!VirtualAlloc (new_stack_pointer, stacksize, MEM_COMMIT,
PAGE_EXECUTE_READWRITE))
api_fatal ("fork: can't commit memory for stack %p(%d), %E",
- new_stack_pointer, ci->stacksize);
+ new_stack_pointer, stacksize);
if (!VirtualQuery ((LPCVOID) new_stack_pointer, &m, sizeof m))
api_fatal ("fork: couldn't get new stack info, %E");
if (!noguard)
@@ -504,7 +503,7 @@ alloc_stack_hard_way (child_info_fork *ci, volatile char *b)
}
if (!VirtualQuery ((LPCVOID) m.BaseAddress, &m, sizeof m))
api_fatal ("fork: couldn't get new stack info, %E");
- ci->stacktop = m.BaseAddress;
+ stacktop = m.BaseAddress;
b[0] = '\0';
}
@@ -519,19 +518,19 @@ getstack (volatile char * volatile p)
/* extend the stack prior to fork longjmp */
-static void
-alloc_stack (child_info_fork *ci)
+void
+child_info_fork::alloc_stack ()
{
volatile char * volatile esp;
__asm__ volatile ("movl %%esp,%0": "=r" (esp));
- if (_tlsbase != ci->stackbottom)
- alloc_stack_hard_way (ci, esp);
+ if (_tlsbase != stackbottom)
+ alloc_stack_hard_way (esp);
else
{
- char *stacktop = (char *) ci->stacktop - 4096;
- while (_tlstop >= stacktop)
+ char *st = (char *) stacktop - 4096;
+ while (_tlstop >= st)
esp = getstack (esp);
- ci->stacksize = 0;
+ stacksize = 0;
}
}
@@ -978,7 +977,7 @@ _dll_crt0 ()
char padding[CYGTLS_PADSIZE];
if (in_forkee)
- alloc_stack (fork_info);
+ fork_info->alloc_stack ();
else
__sinit (_impure_ptr);