From 0791c40b209d5622b300320e11f2bf2af8b2b775 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Tue, 7 Jun 2011 20:55:10 +0000 Subject: [PATCH] * fhandler_console.cc (fhandler_console::open_shared_console): Semi-revert to using fixed location for console stuff. * shared.cc (offsets): Ditto. Comment. * shared_info (shared_locations): Re-add SH_SHARED_CONSOLE. --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/fhandler_console.cc | 4 ++-- winsup/cygwin/shared.cc | 16 ++++++++++------ winsup/cygwin/shared_info.h | 1 + 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index add882874..88d005de1 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2011-06-07 Christopher Faylor + + * fhandler_console.cc (fhandler_console::open_shared_console): + Semi-revert to using fixed location for console stuff. + * shared.cc (offsets): Ditto. Comment. + * shared_info (shared_locations): Re-add SH_SHARED_CONSOLE. + 2011-06-05 Christopher Faylor * fhandler_disk_file.cc (fhandler_disk_file::pread): Reset windows file diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 83ce24652..4d37c0d06 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -83,10 +83,10 @@ fhandler_console::open_shared_console (HWND hw, HANDLE& h, bool& create) wchar_t namebuf[(sizeof "XXXXXXXXXXXXXXXXXX-consNNNNNNNNNN")]; __small_swprintf (namebuf, L"%S-cons%p", &installation_key, hw); - shared_locations m = create ? SH_JUSTCREATE: SH_JUSTOPEN; + shared_locations m = create ? SH_SHARED_CONSOLE : SH_JUSTOPEN; console_state *res = (console_state *) open_shared (namebuf, 0, h, sizeof (*shared_console_info), &m); - create = m == SH_JUSTCREATE; + create = m != SH_JUSTOPEN; return res; } class console_unit diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index a4b5b006a..b538af56f 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -206,18 +206,22 @@ shared_name (WCHAR *ret_buf, const WCHAR *str, int num) /* 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. */ + 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 (shared_info)), /* SH_CYGWIN_SHARED */ + - pround (sizeof (shared_info)) /* SH_USER_SHARED */ - pround (sizeof (user_info)), - - pround (sizeof (shared_info)) + - pround (sizeof (shared_info)) /* SH_MYSELF */ - pround (sizeof (user_info)) - pround (sizeof (_pinfo)), - - pround (sizeof (shared_info)) + - pround (sizeof (shared_info)) /* SH_SHARED_CONSOLE */ - pround (sizeof (user_info)) - - pround (sizeof (_pinfo)), + - pround (sizeof (_pinfo)) + - pround (sizeof (fhandler_console::console_state)), 0 }; diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h index d1260e633..b18625d1a 100644 --- a/winsup/cygwin/shared_info.h +++ b/winsup/cygwin/shared_info.h @@ -65,6 +65,7 @@ enum shared_locations SH_CYGWIN_SHARED, SH_USER_SHARED, SH_MYSELF, + SH_SHARED_CONSOLE, SH_TOTAL_SIZE, SH_JUSTCREATE, SH_JUSTOPEN