mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-18 12:29:32 +08:00
* 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.
This commit is contained in:
parent
e525f6d51a
commit
c4ffa3c427
@ -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
|
||||
|
@ -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. */
|
||||
|
@ -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 ***
|
||||
|
@ -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);
|
||||
|
@ -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 ();
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
addr = offsets[m];
|
||||
|
||||
if (!size)
|
||||
return addr;
|
||||
|
||||
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);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user