From 737a86d32fdaed1b8e29486d793a85896a5e0b95 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 5 Jul 2000 23:46:44 +0000 Subject: * 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. --- winsup/cygwin/dll_init.cc | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'winsup/cygwin/dll_init.cc') 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); } -- cgit v1.2.3