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>2000-11-15 09:27:48 +0300
committerChristopher Faylor <me@cgf.cx>2000-11-15 09:27:48 +0300
commit84aeff4126777c437a15c052f08be026f384ab70 (patch)
tree0d8fdcaf5f04948137e352b0f8b1e31e78925122 /winsup/cygwin/mmap.cc
parentfb0a87573362f64e9c26036f8c887c930fa9ca6a (diff)
Throughout use myself->ppid_handle rather than parent_alive.
* child_info.h (child_info): Eliminate parent_alive. * dcrt0.cc (dll_crt0_1): Call fork_init for debugging pid creation. * fork.cc (fork_child): Reflect change to fixup_mmaps_after_fork arguments. (slow_pid_reuse): New function to grab last 'n' pids to prevent pid reuse. (fork_parent): Move last_fork_proc into slow_pid_reuse. Handle fork_pids debugging. Eliminate unnecessary call to set_child_mmap_ptr. (fork_init): New debugging function. * mmap.cc (fixup_mmaps_after_fork): Renamed from recreate_mmaps_after_fork. Rely on copied data after a fork. (set_child_mmap_ptr): Eliminate. * pinfo.h (_pinfo): Eliminate parent_alive, mmap_ptr and reflect above changes. * spawn.cc (spawn_guts): Eliminate vestiges of "old way" of sending new hProc to parent process.
Diffstat (limited to 'winsup/cygwin/mmap.cc')
-rw-r--r--winsup/cygwin/mmap.cc60
1 files changed, 21 insertions, 39 deletions
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index 6d00a53f1..cfd0a0f7f 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -156,7 +156,7 @@ map::erase (int i)
* needs to be specially handled by the fork code.
*/
-static NO_COPY map *mmapped_areas;
+static map *mmapped_areas;
extern "C"
caddr_t
@@ -185,11 +185,11 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
}
#endif
- if (mmapped_areas == 0)
+ if (mmapped_areas == NULL)
{
/* First mmap call, create STL map */
mmapped_areas = new map;
- if (mmapped_areas == 0)
+ if (mmapped_areas == NULL)
{
set_errno (ENOMEM);
syscall_printf ("-1 = mmap(): ENOMEM");
@@ -271,9 +271,9 @@ munmap (caddr_t addr, size_t len)
SetResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," munmap");
/* Check if a mmap'ed area was ever created */
- if (mmapped_areas == 0)
+ if (mmapped_areas == NULL)
{
- syscall_printf ("-1 = munmap(): mmapped_areas == 0");
+ syscall_printf ("-1 = munmap(): mmapped_areas == NULL");
set_errno (EINVAL);
ReleaseResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," munmap");
return -1;
@@ -344,9 +344,9 @@ msync (caddr_t addr, size_t len, int flags)
SetResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," msync");
/* Check if a mmap'ed area was ever created */
- if (mmapped_areas == 0)
+ if (mmapped_areas == NULL)
{
- syscall_printf ("-1 = msync(): mmapped_areas == 0");
+ syscall_printf ("-1 = msync(): mmapped_areas == NULL");
set_errno (EINVAL);
ReleaseResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," msync");
return -1;
@@ -549,31 +549,26 @@ mprotect (caddr_t addr, size_t len, int prot)
/*
* Call to re-create all the file mappings in a forked
* child. Called from the child in initialization. At this
- * point we are passed a valid mmaped_areas map, and all the
+ * point we are passed a valid mmapped_areas map, and all the
* HANDLE's are valid for the child, but none of the
* mapped areas are in our address space. We need to iterate
* through the map, doing the MapViewOfFile calls.
*/
int __stdcall
-recreate_mmaps_after_fork (void *param)
+fixup_mmaps_after_fork ()
{
- map *areas = (map *)param;
- void *base;
- debug_printf ("recreate_mmaps_after_fork, mmapped_areas %p", areas);
+ debug_printf ("recreate_mmaps_after_fork, mmapped_areas %p", mmapped_areas);
/* Check if a mmapped area was ever created */
- if (areas == 0)
+ if (mmapped_areas == NULL)
return 0;
/* Iterate through the map */
-
- int it;
-
- for (it = 0; it < areas->nlists; ++it)
+ for (int it = 0; it < mmapped_areas->nlists; ++it)
{
- list *l = areas->lists[it];
+ list *l = mmapped_areas->lists[it];
if (l != 0)
{
int li;
@@ -586,34 +581,21 @@ recreate_mmaps_after_fork (void *param)
rec.get_size (), rec.get_address ());
/* Now re-create the MapViewOfFileEx call */
- base = MapViewOfFileEx (rec.get_handle (),
- rec.get_access (), 0,
- rec.get_offset (),
- rec.get_size (),
- rec.get_address ());
+ void *base = MapViewOfFileEx (rec.get_handle (),
+ rec.get_access (), 0,
+ rec.get_offset (),
+ rec.get_size (),
+ rec.get_address ());
if (base != rec.get_address ())
{
system_printf ("base address %p fails to match requested address %p",
rec.get_address ());
return -1;
}
- }
- }
- }
-
- /* Now set our mmap record in case the child forks. */
- mmapped_areas = areas;
+ }
+ }
+ }
debug_printf ("succeeded");
-
return 0;
}
-
-/* Set a child mmap ptr from our static one. Used to set child mmap
- pointer for fork. */
-
-void __stdcall
-set_child_mmap_ptr (_pinfo *child)
-{
- child->mmap_ptr = (void *) mmapped_areas;
-}