From 5bc584ba65db809b22dd2e10eb2cef922ca60d26 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 17 Jul 2000 19:18:21 +0000 Subject: Throughout, eliminate third argument to path_conv and use new PC_* constants for second argument. * path.h: Generalize SYMLINK_* constants to PC_*. (path_conv): Create a new method. Fold third argument into second. * dll_init.cc (dll_list::alloc): Try harder to find space to allocate dll struct. (dll_dllcrt0): Don't check sanity if we've already called dll_crt0. * path.cc (path_conv::check): Don't check for a null or empty path unless specifically told with a flag setting. (check_null_empty_path): New function, adapted from macro. * syscalls.cc (_rename): Use already-determined file attributes rather than checking again. * lib/cygwin/cygwin_attach.dll.c (cygwin_attach_dll): Use a static per_process structure since this is apparently supposed to be zeroed. * lib/cygwin_crt0.c (cygwin_crt0): Zero per_process structure sent to older DLLs. --- winsup/cygwin/dll_init.cc | 52 ++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'winsup/cygwin/dll_init.cc') diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index 8f9f4349e..f525a1070 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -106,43 +106,46 @@ dll_list::alloc (HINSTANCE h, per_process *p, dll_type type) return d; /* Return previously allocated pointer. */ } + SYSTEM_INFO s1; + GetSystemInfo (&s1); + int i; void *s = p->bss_end; + DWORD n; MEMORY_BASIC_INFORMATION m; /* Search for space after the DLL */ - for (i = 0; i <= RETRIES; i++) + for (i = 0; i <= RETRIES; i++, s = (char *) m.BaseAddress + m.RegionSize) { if (!VirtualQuery (s, &m, sizeof (m))) return NULL; /* Can't do it. */ if (m.State == MEM_FREE) - break; /* Found some free space */ - s = (char *) m.BaseAddress + m.RegionSize; + { + /* Couldn't find any. Uh oh. FIXME: Issue an error? */ + if (i == RETRIES) + return NULL; /* Oh well. Couldn't locate free space. */ + + /* Ensure that this is rounded to the nearest page boundary. + FIXME: Should this be ensured by VirtualQuery? */ + n = (DWORD) m.BaseAddress; + DWORD r = n % s1.dwAllocationGranularity; + + if (r) + n = ((n - r) + s1.dwAllocationGranularity); + + /* First reserve the area of memory, then commit it. */ + if (VirtualAlloc ((void *) n, sizeof (dll), MEM_RESERVE, PAGE_READWRITE)) + d = (dll *) VirtualAlloc ((void *) n, sizeof (dll), MEM_COMMIT, + PAGE_READWRITE); + if (d) + break; + } } - /* Couldn't find any. Uh oh. FIXME: Issue an error? */ - if (i == RETRIES) - return NULL; /* Oh well. Couldn't locate free space. */ - - SYSTEM_INFO s1; - GetSystemInfo (&s1); - - /* Ensure that this is rounded to the nearest page boundary. - FIXME: Should this be ensured by VirtualQuery? */ - DWORD n = (DWORD) m.BaseAddress; - DWORD r = n % s1.dwAllocationGranularity; - - if (r) - n = ((n - r) + s1.dwAllocationGranularity); - - /* First reserve the area of memory, then commit it. */ - if (VirtualAlloc ((void *) n, sizeof (dll), MEM_RESERVE, PAGE_READWRITE)) - d = (dll *) VirtualAlloc ((void *) n, sizeof (dll), MEM_COMMIT, PAGE_READWRITE); - /* Did we succeed? */ if (d == NULL) { /* Nope. */ #ifdef DEBUGGING - system_printf ("VirtualAlloc failed for %p, %E", n); + system_printf ("VirtualAlloc failed for %E"); #endif __seterrno (); return NULL; @@ -330,8 +333,7 @@ dll_dllcrt0 (HMODULE h, per_process *p) /* Partially initialize Cygwin guts for non-cygwin apps. */ if (dynamically_loaded && user_data->magic_biscuit == 0) dll_crt0 (p); - - if (p) + else check_sanity_and_sync (p); dll_type type; -- cgit v1.2.3