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>2002-11-14 07:29:39 +0300
committerChristopher Faylor <me@cgf.cx>2002-11-14 07:29:39 +0300
commit052990e6b3cedbe869a66dd70e41a681a056eb76 (patch)
tree29e83d6f150b20440f80c12c53a3ea55cb45266f
parenta2dea5c33349d4c5b2c0dfc410ae7536e36c0fac (diff)
* dll_init.cc (dll_list::detach): Eliminate reliance on passed in dll address.
Infer from module of caller instead. (cygwin_detach_dll): Ignore dll_index argument. * dll_init.h (dll_list::detach): Reflect argument change above.
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/dll_init.cc43
-rw-r--r--winsup/cygwin/dll_init.h2
3 files changed, 34 insertions, 18 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 5b631592b..b5c62194a 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,12 @@
2002-11-13 Christopher Faylor <cgf@redhat.com>
+ * dll_init.cc (dll_list::detach): Eliminate reliance on passed in dll
+ address. Infer from module of caller instead.
+ (cygwin_detach_dll): Ignore dll_index argument.
+ * dll_init.h (dll_list::detach): Reflect argument change above.
+
+2002-11-13 Christopher Faylor <cgf@redhat.com>
+
* ioctl.cc (ioctl): Always print ioctl results, even when it's a tty.
2002-11-13 Christopher Faylor <cgf@redhat.com>
diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc
index 61711e86d..ebb9edbdb 100644
--- a/winsup/cygwin/dll_init.cc
+++ b/winsup/cygwin/dll_init.cc
@@ -182,25 +182,34 @@ dll_list::alloc (HINSTANCE h, per_process *p, dll_type type)
/* Detach a DLL from the chain. */
void
-dll_list::detach (dll *d)
+dll_list::detach (void *retaddr)
{
if (!myself || myself->process_state == PID_EXITED)
return;
+ MEMORY_BASIC_INFORMATION m;
+ if (!VirtualQuery (retaddr, &m, sizeof m))
+ return;
+ HMODULE h = (HMODULE) m.AllocationBase;
- if (d->count <= 0)
- system_printf ("WARNING: try to detach an already detached dll ...");
- else if (--d->count == 0)
- {
- d->p.run_dtors ();
- d->prev->next = d->next;
- if (d->next)
- d->next->prev = d->prev;
- if (d->type == DLL_LOAD)
- loaded_dlls--;
- if (end == d)
- end = d->prev;
- VirtualFree (d, 0, MEM_RELEASE);
- }
+ dll *d = &start;
+ while ((d = d->next))
+ if (d->handle != h)
+ continue;
+ else if (d->count <= 0)
+ system_printf ("WARNING: try to detach an already detached dll ...");
+ else if (--d->count == 0)
+ {
+ d->p.run_dtors ();
+ d->prev->next = d->next;
+ if (d->next)
+ d->next->prev = d->prev;
+ if (d->type == DLL_LOAD)
+ loaded_dlls--;
+ if (end == d)
+ end = d->prev;
+ VirtualFree (d, 0, MEM_RELEASE);
+ break;
+ }
}
/* Initialization for all linked DLLs, called by dll_crt0_1. */
@@ -390,9 +399,9 @@ dll_noncygwin_dllcrt0 (HMODULE h, per_process *p)
}
extern "C" void
-cygwin_detach_dll (dll *d)
+cygwin_detach_dll (dll *)
{
- dlls.detach (d);
+ dlls.detach (__builtin_return_address (0));
}
extern "C" void
diff --git a/winsup/cygwin/dll_init.h b/winsup/cygwin/dll_init.h
index bc9687bf7..24cd79bf2 100644
--- a/winsup/cygwin/dll_init.h
+++ b/winsup/cygwin/dll_init.h
@@ -70,7 +70,7 @@ public:
int reload_on_fork;
dll *operator [] (const char *name);
dll *alloc (HINSTANCE, per_process *, dll_type);
- void detach (dll *);
+ void detach (void *);
void init ();
void load_after_fork (HANDLE, dll *);
dll *inext ()