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>2005-04-29 03:59:44 +0400
committerChristopher Faylor <me@cgf.cx>2005-04-29 03:59:44 +0400
commitc4ffa3c427f77224e8a2d58219c9de25666b0b69 (patch)
tree628c949a7dca65aea4684a1a97207f47cf9bdbd5
parente525f6d51a38d6648ebba2a2c2b25f31d7bfe5ce (diff)
* shared_info.h (cygwin_shared_address): Bump to a higher value to avoid
collision with large data areas. * fhandler_console.cc (fhandler_console::get_tty_stuff): Accommodate changes to open_shared arguments. * fhandler_tape.cc (mtinfo_init): Ditto. * pinfo.cc (pinfo::init): Use open_shared rather than win32 mmap calls. * shared.cc (user_shared_initialize): Ditto. (memory_init): Ditto. (open_shared): Change to allow use a smore general mmap handler. * shared_info.h (shared_locations): Add SH_JUSTCREATE, SH_JUSTOPEN. (open_shared): Change declaration to match new usage. * autoload.cc (LoadDLLfuncEx2): Define in terms of LoadDLLfuncEx3. (LoadDLLfuncEx3): New macro.
-rw-r--r--winsup/cygwin/ChangeLog20
-rw-r--r--winsup/cygwin/autoload.cc18
-rwxr-xr-xwinsup/cygwin/cygmagic2
-rw-r--r--winsup/cygwin/fhandler_console.cc3
-rw-r--r--winsup/cygwin/fhandler_tape.cc3
-rw-r--r--winsup/cygwin/pinfo.cc67
-rw-r--r--winsup/cygwin/shared.cc45
-rw-r--r--winsup/cygwin/shared_info.h10
8 files changed, 99 insertions, 69 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 571b64394..90e88a0da 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,23 @@
+2005-04-28 Corinna Vinschen <corinna@vinschen.de>
+
+ * shared_info.h (cygwin_shared_address): Bump to a higher value to avoid
+ collision with large data areas.
+
+2005-04-28 Christopher Faylor <cgf@timesys.com>
+
+ * fhandler_console.cc (fhandler_console::get_tty_stuff): Accommodate
+ changes to open_shared arguments.
+ * fhandler_tape.cc (mtinfo_init): Ditto.
+ * pinfo.cc (pinfo::init): Use open_shared rather than win32 mmap calls.
+ * shared.cc (user_shared_initialize): Ditto.
+ (memory_init): Ditto.
+ (open_shared): Change to allow use a smore general mmap handler.
+ * shared_info.h (shared_locations): Add SH_JUSTCREATE, SH_JUSTOPEN.
+ (open_shared): Change declaration to match new usage.
+
+ * autoload.cc (LoadDLLfuncEx2): Define in terms of LoadDLLfuncEx3.
+ (LoadDLLfuncEx3): New macro.
+
2005-04-27 Christopher Faylor <cgf@timesys.com>
* fhandler.cc (fhandler_base::open_9x): Remove (broken) check for
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index 8986c7924..f264b8608 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -75,11 +75,15 @@ details. */
/* Standard DLL load macro. May invoke a fatal error if the function isn't
found. */
-#define LoadDLLfunc(name, n, dllname) LoadDLLfuncEx (name, n, dllname, 0)
-#define LoadDLLfuncEx(name, n, dllname, notimp) LoadDLLfuncEx2(name, n, dllname, notimp, 0)
+#define LoadDLLfunc(name, n, dllname) \
+ LoadDLLfuncEx (name, n, dllname, 0)
+#define LoadDLLfuncEx(name, n, dllname, notimp) \
+ LoadDLLfuncEx2(name, n, dllname, notimp, 0)
+#define LoadDLLfuncEx2(name, n, dllname, notimp, err) \
+ LoadDLLfuncEx3(name, n, dllname, notimp, err, 0)
/* Main DLL setup stuff. */
-#define LoadDLLfuncEx2(name, n, dllname, notimp, err) \
+#define LoadDLLfuncEx3(name, n, dllname, notimp, err, fn) \
LoadDLLprime (dllname, dll_func_load) \
__asm__ (" \n\
.section ." #dllname "_text,\"wx\" \n\
@@ -91,11 +95,11 @@ _win32_" mangle (name, n) ": \n\
.byte 0xe9 \n\
.long -4 + 1f - . \n\
1:movl (2f),%eax \n\
- call *(%eax) \n\
+ call *(%eax) \n\
2:.long ." #dllname "_info \n\
- .long (" #n "+" #notimp ") | (((" #err ") & 0xffff) <<16) \n\
- .asciz \"" #name "\" \n\
- .text \n\
+ .long (" #n "+" #notimp ") | (((" #err ") & 0xff) <<16) | (((" #fn ") & 0xff) << 24) \n\
+ .asciz \"" #name "\" \n\
+ .text \n\
");
/* DLL loader helper functions used during initialization. */
diff --git a/winsup/cygwin/cygmagic b/winsup/cygwin/cygmagic
index a8ccc8c76..aed508b0f 100755
--- a/winsup/cygwin/cygmagic
+++ b/winsup/cygwin/cygmagic
@@ -24,7 +24,7 @@ sumit() {
while [ -n "$1" ]; do
define=$1; shift
struct=$1; shift
- sum=`$gcc -E $file | sed -n "/^$struct/,/^};/p" | sed -e 's/[ ]//g' -e '/^$/d' | sumit | awk '{printf "0x%xU", $1}'`
+ sum=`$gcc -E $file | tee /tmp/1 | sed -n "/^$struct/,/^};/p" | sed -e 's/[ ]//g' -e '/^$/d' | tee /tmp/2 | sumit | tee /tmp/3 | awk '{printf "0x%xU", $1}'`
echo "#define $define $sum"
curr=`sed -n "s/^#[ ]*define CURR_$define[ ][ ]*\([^ ][^ ]*\)/\1/p" $file`
[ "$curr" != "$sum" ] && echo "*** WARNING WARNING WARNING WARNING WARNING ***
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index a2f24b80d..a5fa99ede 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -81,10 +81,11 @@ fhandler_console::get_tty_stuff (int flags = 0)
if (dev_state)
return &shared_console_info->tty_min_state;
+ shared_locations sh_shared_console = SH_SHARED_CONSOLE;
shared_console_info =
(console_state *) open_shared (NULL, 0, cygheap->console_h,
sizeof (*shared_console_info),
- SH_SHARED_CONSOLE);
+ sh_shared_console);
dev_state = &shared_console_info->dev_state;
ProtectHandleINH (cygheap->console_h);
diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc
index a3c74dd71..c733a7d59 100644
--- a/winsup/cygwin/fhandler_tape.cc
+++ b/winsup/cygwin/fhandler_tape.cc
@@ -1171,7 +1171,8 @@ mtinfo *mt;
void __stdcall
mtinfo_init ()
{
- mt = (mtinfo *) open_shared ("mtinfo", MTINFO_VERSION, cygheap->mt_h, sizeof (mtinfo), SH_MTINFO);
+ shared_locations sh_mtinfo = SH_MTINFO;
+ mt = (mtinfo *) open_shared ("mtinfo", MTINFO_VERSION, cygheap->mt_h, sizeof (mtinfo), sh_mtinfo);
ProtectHandleINH (cygheap->mt_h);
mt->initialize ();
}
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index a0f7c48ec..33576e887 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -174,6 +174,7 @@ pinfo::exit (DWORD n)
void
pinfo::init (pid_t n, DWORD flag, HANDLE h0)
{
+ shared_locations shloc;
h = NULL;
if (myself && !(flag & PID_EXECED)
&& (n == myself->pid || (DWORD) n == myself->dwProcessId))
@@ -185,72 +186,60 @@ pinfo::init (pid_t n, DWORD flag, HANDLE h0)
void *mapaddr;
int createit = flag & (PID_IN_USE | PID_EXECED);
- bool created = false;
DWORD access = FILE_MAP_READ
| (flag & (PID_IN_USE | PID_EXECED | PID_MAP_RW)
? FILE_MAP_WRITE : 0);
if (!h0)
- mapaddr = NULL;
+ shloc = (flag & (PID_IN_USE | PID_EXECED)) ? SH_JUSTCREATE : SH_JUSTOPEN;
else
{
- /* Try to enforce that myself is always created in the same place */
- mapaddr = open_shared (NULL, 0, h0, 0, SH_MYSELF);
+ shloc = SH_MYSELF;
if (h0 == INVALID_HANDLE_VALUE)
h0 = NULL;
}
procinfo = NULL;
+ char sa_buf[1024];
+ PSECURITY_ATTRIBUTES sec_attribs = sec_user_nih (sa_buf, cygheap->user.sid(),
+ well_known_world_sid,
+ FILE_MAP_READ);
+
for (int i = 0; i < 20; i++)
{
+ DWORD mapsize;
+ if (flag & PID_EXECED)
+ mapsize = PINFO_REDIR_SIZE;
+ else
+ mapsize = sizeof (_pinfo);
+
+ procinfo = (_pinfo *) open_shared ("cygpid", n, h0, mapsize, shloc,
+ sec_attribs, access);
if (!h0)
{
- char mapname[CYG_MAX_PATH];
- shared_name (mapname, "cygpid", n);
-
- int mapsize;
- if (flag & PID_EXECED)
- mapsize = PINFO_REDIR_SIZE;
- else
- mapsize = sizeof (_pinfo);
-
- if (!createit)
- {
- h0 = OpenFileMapping (access, FALSE, mapname);
- created = false;
- }
- else
- {
- char sa_buf[1024];
- PSECURITY_ATTRIBUTES sec_attribs =
- sec_user_nih (sa_buf, cygheap->user.sid(), well_known_world_sid,
- FILE_MAP_READ);
- h0 = CreateFileMapping (INVALID_HANDLE_VALUE, sec_attribs,
- PAGE_READWRITE, 0, mapsize, mapname);
- created = GetLastError () != ERROR_ALREADY_EXISTS;
- }
-
- if (!h0)
- {
- if (createit)
- __seterrno ();
- return;
- }
+ if (createit)
+ __seterrno ();
+ return;
}
- procinfo = (_pinfo *) MapViewOfFileEx (h0, access, 0, 0, 0, mapaddr);
-
if (!procinfo)
{
if (exit_state)
return;
- if (GetLastError () == ERROR_INVALID_HANDLE)
- api_fatal ("MapViewOfFileEx h0 %p, i %d failed, %E", h0, i);
+ switch (GetLastError ())
+ {
+ case ERROR_INVALID_HANDLE:
+ api_fatal ("MapViewOfFileEx h0 %p, i %d failed, %E", h0, i);
+ case ERROR_INVALID_ADDRESS:
+ mapaddr = NULL;
+ }
debug_printf ("MapViewOfFileEx h0 %p, i %d failed, %E", h0, i);
continue;
}
+ bool created = shloc != SH_JUSTOPEN;
+
if ((procinfo->process_state & PID_INITIALIZING) && (flag & PID_NOREDIR)
&& cygwin_pid (procinfo->dwProcessId) != procinfo->pid)
{
diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc
index 8798b2c4c..f0daccb85 100644
--- a/winsup/cygwin/shared.cc
+++ b/winsup/cygwin/shared.cc
@@ -75,23 +75,20 @@ static char *offsets[] =
void * __stdcall
open_shared (const char *name, int n, HANDLE& shared_h, DWORD size,
- shared_locations m, PSECURITY_ATTRIBUTES psa)
+ shared_locations& m, PSECURITY_ATTRIBUTES psa, DWORD access)
{
void *shared;
void *addr;
- if (!wincap.needs_memory_protection () && offsets[0])
+ if ((m == SH_JUSTCREATE || m == SH_JUSTOPEN)
+ || !wincap.needs_memory_protection () && offsets[0])
addr = NULL;
else
- {
- addr = offsets[m];
- (void) VirtualFree (addr, 0, MEM_RELEASE);
- }
-
- if (!size)
- return addr;
+ addr = offsets[m];
- if (!shared_h)
+ if (shared_h)
+ m = SH_JUSTOPEN;
+ else
{
char *mapname;
char map_buf[CYG_MAX_PATH];
@@ -99,20 +96,32 @@ open_shared (const char *name, int n, HANDLE& shared_h, DWORD size,
mapname = NULL;
else
mapname = shared_name (map_buf, name, n);
- if (!(shared_h = CreateFileMapping (INVALID_HANDLE_VALUE, psa,
- PAGE_READWRITE, 0, size, mapname)))
+ if (m == SH_JUSTOPEN)
+ shared_h = OpenFileMapping (access, FALSE, mapname);
+ else
+ {
+ shared_h = CreateFileMapping (INVALID_HANDLE_VALUE, psa, PAGE_READWRITE,
+ 0, size, mapname);
+ if (GetLastError () == ERROR_ALREADY_EXISTS)
+ m = SH_JUSTOPEN;
+ }
+ if (shared_h)
+ /* ok! */;
+ else if (m != SH_JUSTOPEN)
api_fatal ("CreateFileMapping %s, %E. Terminating.", mapname);
+ else
+ return NULL;
}
shared = (shared_info *)
- MapViewOfFileEx (shared_h, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0, addr);
+ MapViewOfFileEx (shared_h, access, 0, 0, 0, addr);
- if (!shared)
+ if (!shared && addr)
{
/* Probably win95, so try without specifying the address. */
shared = (shared_info *) MapViewOfFileEx (shared_h,
FILE_MAP_READ|FILE_MAP_WRITE,
- 0, 0, 0, 0);
+ 0, 0, 0, NULL);
#ifdef DEBUGGING
if (wincap.is_winnt ())
system_printf ("relocating shared object %s(%d) from %p to %p on Windows NT", name, n, addr, shared);
@@ -165,9 +174,10 @@ user_shared_initialize (bool reinit)
if (!cygwin_user_h)
cygheap->user.get_windows_id (name);
+ shared_locations sh_user_shared = SH_USER_SHARED;
user_shared = (user_info *) open_shared (name, USER_VERSION,
cygwin_user_h, sizeof (user_info),
- SH_USER_SHARED, &sec_none);
+ sh_user_shared, &sec_none);
debug_printf ("opening user shared for '%s' at %p", name, user_shared);
ProtectHandleINH (cygwin_user_h);
debug_printf ("user shared version %x", user_shared->version);
@@ -236,11 +246,12 @@ memory_init ()
}
/* Initialize general shared memory */
+ shared_locations sh_cygwin_shared = SH_CYGWIN_SHARED;
cygwin_shared = (shared_info *) open_shared ("shared",
CYGWIN_VERSION_SHARED_DATA,
cygheap->shared_h,
sizeof (*cygwin_shared),
- SH_CYGWIN_SHARED);
+ sh_cygwin_shared);
cygwin_shared->initialize ();
ProtectHandleINH (cygheap->shared_h);
diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h
index 5fa00f3dd..cfe222a72 100644
--- a/winsup/cygwin/shared_info.h
+++ b/winsup/cygwin/shared_info.h
@@ -173,7 +173,10 @@ enum shared_locations
SH_SHARED_CONSOLE,
SH_MYSELF,
SH_MTINFO,
- SH_TOTAL_SIZE
+ SH_TOTAL_SIZE,
+ SH_JUSTCREATE,
+ SH_JUSTOPEN
+
};
void __stdcall memory_init ();
@@ -182,7 +185,7 @@ void __stdcall memory_init ();
(((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \
system_info.dwAllocationGranularity)))
-#define cygwin_shared_address ((void *) 0xa000000)
+#define cygwin_shared_address ((void *) 0x60000000)
#ifdef _FHANDLER_H_
struct console_state
@@ -194,6 +197,7 @@ struct console_state
char *__stdcall shared_name (char *, const char *, int);
void *__stdcall open_shared (const char *name, int n, HANDLE &shared_h, DWORD size,
- shared_locations, PSECURITY_ATTRIBUTES psa = &sec_all);
+ shared_locations&, PSECURITY_ATTRIBUTES psa = &sec_all,
+ DWORD access = FILE_MAP_READ | FILE_MAP_WRITE);
extern void user_shared_initialize (bool reinit);