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
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-09-09 07:34:36 +0400
committerChristopher Faylor <me@cgf.cx>2001-09-09 07:34:36 +0400
commite2ea684e4ecca39aae13d3cdcdcb12cf32621889 (patch)
treed5dcb4a9b1bfb8fe47b57de3ec380312e838c5a7
parentc12a96d12fb912d3da7e1b6d9e68decf7b45b335 (diff)
* fork.cc (fork_parent): Stop malloc activity while fork is in control of the
heap. * sigproc.cc (NZOMBIES): Rename from ZOMBIEMAX for clarity. (zombies): Revert to original behavior. Allocating zombie array resulted in performance hit. * winsup.h: Declare malloc lock routines.
-rw-r--r--winsup/cygwin/ChangeLog9
-rw-r--r--winsup/cygwin/fork.cc2
-rw-r--r--winsup/cygwin/malloc_wrapper.cc18
-rw-r--r--winsup/cygwin/sigproc.cc15
-rw-r--r--winsup/cygwin/winsup.h3
5 files changed, 25 insertions, 22 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index fc7e54bdc..6d9afe096 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,12 @@
+Sat Sep 8 23:32:18 2001 Christopher Faylor <cgf@cygnus.com>
+
+ * fork.cc (fork_parent): Stop malloc activity while fork is in control
+ of the heap.
+ * sigproc.cc (NZOMBIES): Rename from ZOMBIEMAX for clarity.
+ (zombies): Revert to original behavior. Allocating zombie array
+ resulted in performance hit.
+ * winsup.h: Declare malloc lock routines.
+
Fri Sep 7 21:35:35 2001 Christopher Faylor <cgf@cygnus.com>
* cygwin.din: Add gamm*_r function exports.
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index b72b441dc..3a63e3901 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -462,6 +462,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
char sa_buf[1024];
syscall_printf ("CreateProcess (%s, %s, 0, 0, 1, %x, 0, 0, %p, %p)",
myself->progname, myself->progname, c_flags, &si, &pi);
+ __malloc_lock (_reent_clib ());
cygheap_setup_for_child (&ch);
rc = CreateProcess (myself->progname, /* image to run */
myself->progname, /* what we send in arg0 */
@@ -557,6 +558,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
dll_data_start, dll_data_end,
dll_bss_start, dll_bss_end, NULL);
+ __malloc_unlock (_reent_clib ());
MALLOC_CHECK;
if (!rc)
goto cleanup;
diff --git a/winsup/cygwin/malloc_wrapper.cc b/winsup/cygwin/malloc_wrapper.cc
index 783fec956..7aa29f5c6 100644
--- a/winsup/cygwin/malloc_wrapper.cc
+++ b/winsup/cygwin/malloc_wrapper.cc
@@ -154,8 +154,7 @@ _strdup_r (struct _reent *, const char *s)
/* These routines are used by the application if it
doesn't provide its own malloc. */
-extern "C"
-void
+extern "C" void
export_free (void *p)
{
malloc_printf ("(%p), called by %x", p, ((int *)&p)[-1]);
@@ -165,8 +164,7 @@ export_free (void *p)
user_data->free (p);
}
-extern "C"
-void *
+extern "C" void *
export_malloc (int size)
{
void *res;
@@ -179,8 +177,7 @@ export_malloc (int size)
return res;
}
-extern "C"
-void *
+extern "C" void *
export_realloc (void *p, int size)
{
void *res;
@@ -192,8 +189,7 @@ export_realloc (void *p, int size)
return res;
}
-extern "C"
-void *
+extern "C" void *
export_calloc (size_t nmemb, size_t size)
{
void *res;
@@ -234,15 +230,13 @@ malloc_init ()
}
}
-extern "C"
-void
+extern "C" void
__malloc_lock (struct _reent *)
{
mprotect->acquire ();
}
-extern "C"
-void
+extern "C" void
__malloc_unlock (struct _reent *)
{
mprotect->release ();
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 39a300bf2..a4b9168e4 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -46,7 +46,7 @@ details. */
#define no_signals_available() (!hwait_sig || !sig_loop_wait)
-#define ZOMBIEMAX 4096
+#define NZOMBIES 4096
/*
* Global variables
@@ -99,12 +99,12 @@ Static HANDLE wait_sig_inited = NULL; // Control synchronization of
/* Used by WaitForMultipleObjects. These are handles to child processes.
*/
-Static HANDLE events[PSIZE + 1] = {0}; // All my children's handles++
+Static HANDLE events[PSIZE + 1] = {0}; // All my children's handles++
#define hchildren (events + 1) // Where the children handles begin
Static pinfo pchildren[PSIZE]; // All my children info
Static int nchildren = 0; // Number of active children
-static pinfo *zombies; // All my deceased children info
-static int nzombies; // Number of deceased children
+Static pinfo zombies[NZOMBIES]; // All my deceased children info
+Static int nzombies = 0; // Number of deceased children
Static waitq waitq_head = {0, 0, 0, 0, 0, 0, 0};// Start of queue for wait'ing threads
Static waitq waitq_main; // Storage for main thread
@@ -318,7 +318,7 @@ proc_subproc (DWORD what, DWORD val)
filled up our table or if we're ignoring SIGCHLD, then we immediately
remove the process and move on. Otherwise, this process becomes a zombie
which must be reaped by a wait() call. */
- if (nzombies >= ZOMBIEMAX
+ if (nzombies >= NZOMBIES
|| myself->getsig (SIGCHLD).sa_handler == (void *) SIG_IGN)
{
sigproc_printf ("automatically removing zombie %d", thiszombie);
@@ -543,11 +543,6 @@ sig_dispatch_pending (int justwake)
void __stdcall
sigproc_init ()
{
- if (!zombies)
- zombies = (pinfo *) malloc (sizeof (pinfo) * ZOMBIEMAX);
- else
- nzombies = 0;
-
wait_sig_inited = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
ProtectHandle (wait_sig_inited);
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 1b8c15579..657aa883e 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -211,6 +211,9 @@ extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn));
extern "C" int __small_sprintf (char *dst, const char *fmt, ...) /*__attribute__ ((regparm (2)))*/;
extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap) /*__attribute__ ((regparm (3)))*/;
+extern "C" void __malloc_lock (struct _reent *);
+extern "C" void __malloc_unlock (struct _reent *);
+
/**************************** Exports ******************************/
extern "C" {