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>2000-07-06 03:46:44 +0400
committerChristopher Faylor <me@cgf.cx>2000-07-06 03:46:44 +0400
commit737a86d32fdaed1b8e29486d793a85896a5e0b95 (patch)
treea205999bafd7339f538b4bfa6d66da7a50675c60 /winsup/cygwin/dll_init.cc
parent4e734b208bd377dde6cfc95a342dbf8940a8919c (diff)
* dcrt0.cc (__cygwin_user_data): Initialize.
(dll_crt0_1): Eliminate user_data initialization. (dll_crt0): Set up impure_ptr_ptr for older executables. (cygwin_dll_init): Eliminate user_data initializations. (__api_fatal): Don't check for user_data initialization. * dll_init.cc (struct dll): Store entire contents of per_process rather than just a pointer. (add): Ditto. (initOneDll): Don't check for user_data initialization. (DllList::recordDll): Store contents of per_process argument. (DllList::detachDll): Pass address of per_process field. (DllList::initAll): Ditto. (DllList::doGlobalDestructorsOfDlls): Ditto. (DllListIterator::operator *): Ditto. (dll_dllcrt0): Default to __cygwin_user_data if arg is NULL. * include/sys/cygwin.h: Reorganize per_process to eliminate obsolete fields and accomodate new way of initializing. * lib/_cygwin_crt0_common: Initialize _impure_ptr from __cygwin_user_data.impure_ptr.
Diffstat (limited to 'winsup/cygwin/dll_init.cc')
-rw-r--r--winsup/cygwin/dll_init.cc34
1 files changed, 15 insertions, 19 deletions
diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc
index a1d217576..38867e18a 100644
--- a/winsup/cygwin/dll_init.cc
+++ b/winsup/cygwin/dll_init.cc
@@ -29,7 +29,7 @@ typedef enum { NONE, LINK, LOAD } dllType;
struct dll
{
- per_process *p;
+ per_process p;
HMODULE handle;
const char *name;
dllType type;
@@ -128,7 +128,7 @@ add (HMODULE h, char *name, per_process *p, dllType type)
_list[_last].name = name && type == LOAD ? strdup (name) : NULL;
_list[_last].handle = h;
- _list[_last].p = p;
+ _list[_last].p = *p;
_list[_last].type = type;
ret = _last++;
@@ -139,14 +139,6 @@ static int
initOneDll (per_process *p)
{
/* global variable user_data must be initialized */
- if (user_data == NULL)
- {
- small_printf ("WARNING: process not inited while trying to init a DLL!\n");
- return 0;
- }
-
- /* init impure_ptr */
- *(p->impure_ptr_ptr) = *(user_data->impure_ptr_ptr);
/* FIXME: init environment (useful?) */
*(p->envptr) = *(user_data->envptr);
@@ -220,7 +212,7 @@ DllList::recordDll (HMODULE h, per_process *p)
if (_dlopenIndex != -1)
{
_list[_dlopenIndex].handle = h;
- _list[_dlopenIndex].p = p;
+ _list[_dlopenIndex].p = *p;
_list[_dlopenIndex].type = type;
ret = _dlopenIndex;
_dlopenIndex = -1;
@@ -248,7 +240,7 @@ DllList::detachDll (int dll_index)
if (dll_index != -1)
{
dll *aDll = &(_list[dll_index]);
- doGlobalDTORS (aDll->p);
+ doGlobalDTORS (&aDll->p);
if (aDll->type == LOAD)
_numberOfOpenedDlls--;
aDll->type = NONE;
@@ -274,7 +266,7 @@ DllList::initAll ()
debug_printf ("call to DllList::initAll");
for (int i = 0; i < _last; i++)
{
- per_process *p = _list[i].p;
+ per_process *p = &_list[i].p;
if (p)
initOneDll (p);
}
@@ -290,7 +282,7 @@ DllList::doGlobalDestructorsOfDlls ()
{
if (_list[i].type != NONE)
{
- per_process *p = _list[i].p;
+ per_process *p = &_list[i].p;
if (p)
doGlobalDTORS (p);
}
@@ -418,7 +410,7 @@ DllListIterator::~DllListIterator ()
DllListIterator::operator per_process* ()
{
- return _list[index ()].p;
+ return &_list[index ()].p;
}
void
@@ -462,11 +454,15 @@ extern "C"
int
dll_dllcrt0 (HMODULE h, per_process *p)
{
+ struct _reent reent_data;
+ if (p == NULL)
+ p = &__cygwin_user_data;
+ else
+ *(p->impure_ptr_ptr) = &reent_data;
+
/* Partially initialize Cygwin guts for non-cygwin apps. */
- if (dynamically_loaded && (! user_data || user_data->magic_biscuit == 0))
- {
- dll_crt0 (p);
- }
+ if (dynamically_loaded && user_data->magic_biscuit == 0)
+ dll_crt0 (p);
return _the.recordDll (h, p);
}