summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/shared.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2011-05-27 06:11:05 +0000
committerCorinna Vinschen <corinna@vinschen.de>2011-05-27 06:11:05 +0000
commitbfce73c261fd9da02ce1d25a4a466ece1b3a55ea (patch)
treeb6d92670ebd2f8c73279b01c3cee61a5d49144d9 /winsup/cygwin/shared.cc
parent28667da372fb11bc8df08e1991a814005977e99f (diff)
downloadcygnal-bfce73c261fd9da02ce1d25a4a466ece1b3a55ea.tar.gz
cygnal-bfce73c261fd9da02ce1d25a4a466ece1b3a55ea.tar.bz2
cygnal-bfce73c261fd9da02ce1d25a4a466ece1b3a55ea.zip
* shared.cc (offsets): Reorder so that console_state is lowest in
memory. Explain why. (open_shared): Accommodate reordering of offsets array. * shared_info.h (shared_locations): Reorder SH_SHARED_CONSOLE after SH_MYSELF.
Diffstat (limited to 'winsup/cygwin/shared.cc')
-rw-r--r--winsup/cygwin/shared.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc
index 0bfd4be8d..b505cc947 100644
--- a/winsup/cygwin/shared.cc
+++ b/winsup/cygwin/shared.cc
@@ -204,18 +204,24 @@ shared_name (WCHAR *ret_buf, const WCHAR *str, int num)
#define page_const (65535)
#define pround(n) (((size_t) (n) + page_const) & ~page_const)
+/* The order in offsets is so that the constant blocks shared_info
+ and user_info are right below the cygwin DLL, then the pinfo block
+ which changes with each process. Below that is the console_state,
+ an optional block which only exists when running in a Windows console
+ window. Therefore, if we are not running in a console, we have 64K
+ more of contiguous memory below the Cygwin DLL. */
static ptrdiff_t offsets[] =
{
+ - pround (sizeof (shared_info)),
+ - pround (sizeof (shared_info))
+ - pround (sizeof (user_info)),
- pround (sizeof (shared_info))
- pround (sizeof (user_info))
- - pround (sizeof (console_state))
- pround (sizeof (_pinfo)),
+ - pround (sizeof (shared_info))
- pround (sizeof (user_info))
- - pround (sizeof (console_state))
- - pround (sizeof (_pinfo)),
- - pround (sizeof (console_state))
- - pround (sizeof (_pinfo)),
- - pround (sizeof (_pinfo)),
+ - pround (sizeof (_pinfo))
+ - pround (sizeof (console_state)),
0
};
@@ -269,8 +275,7 @@ open_shared (const WCHAR *name, int n, HANDLE& shared_h, DWORD size,
return NULL;
}
- shared = (shared_info *)
- MapViewOfFileEx (shared_h, access, 0, 0, 0, addr);
+ shared = (shared_info *) MapViewOfFileEx (shared_h, access, 0, 0, 0, addr);
if (!shared && addr)
{
@@ -292,7 +297,7 @@ open_shared (const WCHAR *name, int n, HANDLE& shared_h, DWORD size,
offsets[0] = (caddr_t) shared - (caddr_t) cygwin_hmodule;
for (int i = SH_USER_SHARED + 1; i < SH_TOTAL_SIZE; i++)
{
- unsigned size = offsets[i + 1] - offsets[i];
+ unsigned size = offsets[i] - offsets[i + 1];
offsets[i] += delta;
if (!VirtualAlloc (off_addr (i), size, MEM_RESERVE, PAGE_NOACCESS))
continue; /* oh well */