diff options
-rw-r--r-- | winsup/cygwin/ChangeLog | 8 | ||||
-rw-r--r-- | winsup/cygwin/shared.cc | 37 | ||||
-rw-r--r-- | winsup/cygwin/shared_info.h | 2 |
3 files changed, 23 insertions, 24 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index d66bf8694..3b8ad6102 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,13 @@ 2006-07-26 Corinna Vinschen <corinna@vinschen.de> + * shared.cc (offsets): Define as offsets relative to cygwin_hmodule + instead of addresses. + (off_addr): New macro. + (open_shared): Use offsets array accordingly. Remove unused code. + * shared_info.h (cygwin_shared_address): Remove. + +2006-07-26 Corinna Vinschen <corinna@vinschen.de> + * cygheap.h (struct init_cygheap): Remove shared_h and mt_h members. * fhandler_tape.cc (mt): Define as DLL shared area in .cygwin_dll_common instead of as dynamically allocated area. diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index c88706a12..65965b58b 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -49,20 +49,19 @@ shared_name (char *ret_buf, const char *str, int num) #define page_const (65535) #define pround(n) (((size_t) (n) + page_const) & ~page_const) -static char *offsets[] = +static ptrdiff_t offsets[] = { - (char *) cygwin_shared_address - - pround (sizeof (user_info)) - - pround (sizeof (console_state)) - - pround (sizeof (_pinfo)), - (char *) cygwin_shared_address - - pround (sizeof (console_state)) - - pround (sizeof (_pinfo)), - (char *) cygwin_shared_address - - pround (sizeof (_pinfo)), - (char *) cygwin_shared_address + - pround (sizeof (user_info)) + - pround (sizeof (console_state)) + - pround (sizeof (_pinfo)), + - pround (sizeof (console_state)) + - pround (sizeof (_pinfo)), + - pround (sizeof (_pinfo)), + 0 }; +#define off_addr(x) ((void *)((caddr_t) cygwin_hmodule + offsets[x])) + void * __stdcall open_shared (const char *name, int n, HANDLE& shared_h, DWORD size, shared_locations& m, PSECURITY_ATTRIBUTES psa, DWORD access) @@ -75,7 +74,7 @@ open_shared (const char *name, int n, HANDLE& shared_h, DWORD size, addr = NULL; else { - addr = offsets[m]; + addr = off_addr (m); VirtualFree (addr, 0, MEM_RELEASE); } @@ -118,7 +117,7 @@ open_shared (const char *name, int n, HANDLE& shared_h, DWORD size, if (wincap.is_winnt ()) system_printf ("relocating shared object %s(%d) from %p to %p on Windows NT", name, n, addr, shared); #endif - offsets[0] = NULL; + offsets[0] = 0; } if (!shared) @@ -126,22 +125,16 @@ open_shared (const char *name, int n, HANDLE& shared_h, DWORD size, if (m == SH_USER_SHARED && offsets[0] && wincap.needs_memory_protection ()) { - unsigned delta = (char *) shared - offsets[0]; - offsets[0] = (char *) shared; + ptrdiff_t delta = (caddr_t) shared - (caddr_t) off_addr (0); + 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]; offsets[i] += delta; - if (!VirtualAlloc (offsets[i], size, MEM_RESERVE, PAGE_NOACCESS)) + if (!VirtualAlloc (off_addr (i), size, MEM_RESERVE, PAGE_NOACCESS)) continue; /* oh well */ } offsets[SH_TOTAL_SIZE] += delta; - -#if 0 - if (!child_proc_info && wincap.needs_memory_protection ()) - for (DWORD s = 0x950000; s <= 0xa40000; s += 0x1000) - VirtualAlloc ((void *) s, 4, MEM_RESERVE, PAGE_NOACCESS); -#endif } debug_printf ("name %s, n %d, shared %p (wanted %p), h %p", mapname, n, shared, addr, shared_h); diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h index ae80309cb..17a21b4cc 100644 --- a/winsup/cygwin/shared_info.h +++ b/winsup/cygwin/shared_info.h @@ -184,8 +184,6 @@ void __stdcall memory_init (); (((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \ system_info.dwAllocationGranularity))) -#define cygwin_shared_address ((void *) 0x61000000) - #ifdef _FHANDLER_H_ struct console_state { |