aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/shared.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-10-15 17:04:20 +0000
committerChristopher Faylor <me@cgf.cx>2002-10-15 17:04:20 +0000
commit6c6c3b90e9a8f0b0ffa9d6f1e064613afe43ccb6 (patch)
tree65694f4ae6e38b635fcfee55a0adf63fb45ed587 /winsup/cygwin/shared.cc
parentfdb28b5e5f813721add3ba2b261dfe78f3b895cb (diff)
downloadnewlib-6c6c3b90e9a8f0b0ffa9d6f1e064613afe43ccb6.zip
newlib-6c6c3b90e9a8f0b0ffa9d6f1e064613afe43ccb6.tar.gz
newlib-6c6c3b90e9a8f0b0ffa9d6f1e064613afe43ccb6.tar.bz2
* shared.cc (open_shared): Revert to "old" method for shared memory location if
!wincap.needs_memory_protection. * wincap.cc: Implement needs_memory_protection throughout. * wincap.h: Ditto.
Diffstat (limited to 'winsup/cygwin/shared.cc')
-rw-r--r--winsup/cygwin/shared.cc33
1 files changed, 22 insertions, 11 deletions
diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc
index 113e7f5..59ca349 100644
--- a/winsup/cygwin/shared.cc
+++ b/winsup/cygwin/shared.cc
@@ -70,20 +70,15 @@ open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, shared_locat
+ pround (sizeof (_pinfo))
};
- if (m == SH_CYGWIN_SHARED)
+ void *addr;
+ if (!wincap.needs_memory_protection ())
+ addr = NULL;
+ else
{
- for (int i = SH_CYGWIN_SHARED; i < SH_TOTAL_SIZE; i++)
- if (!VirtualAlloc (offsets[i], offsets[i + 1] - offsets[i],
- MEM_RESERVE, PAGE_NOACCESS))
- continue; /* oh well */
- if (!child_proc_info)
- for (DWORD s = 0x950000; s <= 0xa40000; s += 0x1000)
- VirtualAlloc ((void *) s, 4, MEM_RESERVE, PAGE_NOACCESS);
+ addr = offsets[m];
+ (void) VirtualFree (addr, 0, MEM_RELEASE);
}
- void *addr = offsets[m];
- (void) VirtualFree (addr, 0, MEM_RELEASE);
-
if (!size)
return addr;
@@ -118,6 +113,22 @@ open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, shared_locat
if (!shared)
api_fatal ("MapViewOfFileEx '%s'(%p), %E. Terminating.", name, shared_h);
+ if (m == SH_CYGWIN_SHARED)
+ {
+ for (int i = SH_CYGWIN_SHARED + 1; i < SH_TOTAL_SIZE; i++)
+ {
+ offsets[i] += (char *) shared - offsets[0];
+ if (!VirtualAlloc (offsets[i], offsets[i + 1] - offsets[i],
+ MEM_RESERVE, PAGE_NOACCESS))
+ continue; /* oh well */
+ offsets[0] = (char *) shared;
+ }
+
+ if (!child_proc_info && wincap.needs_memory_protection ())
+ for (DWORD s = 0x950000; s <= 0xa40000; s += 0x1000)
+ VirtualAlloc ((void *) s, 4, MEM_RESERVE, PAGE_NOACCESS);
+ }
+
debug_printf ("name %s, shared %p (wanted %p), h %p", name, shared, addr, shared_h);
/* FIXME: I couldn't find anywhere in the documentation a note about