71f53a2f62
(init_cygheap): Inherit locale field via mini_cygheap. * cygheap.cc (cygheap_at_start): Define new variable. (cygheap): Initialize as cygheap_at_start so that locale information is always available. (cygheap_init): Initialize cygheap iff it is set to cygheap_at_start. * shared_info.h (memory_init): Accommodate argument change. * memory.cc (memory_init): Accept an argument indicating whether cygheap should be initialized or not. * dcrt0.cc (child_info_fork::handle_fork): Pass false to memory_init(). (child_info_spawn::handle_spawn): Ditto. (dll_crt0_0): Pass true to memory_init when not forking or execing. * cygheap.h (cygheap_types::HEAP_2_DLL): New enum. * dll_init.h (dll): Remove unused namelen field. (dll_list::load_after_fork): Accommodate change in arguments. * dll_init.cc (dll_list::alloc): Allocate dll information in the cygwin heap. (dll_list::detach): Free dll information from the cygwin heap. (dll_list::load_after_fork): Use dll information in the cygwin heap directly rather than querying parent. * fork.cc (frok::first_dll): Delete. (frok::child): Don't report on first_dll. Don't pass it to load_on_fork. (frok::parent): Don't set first_dll. (fork): Ditto.
94 lines
1.6 KiB
C++
94 lines
1.6 KiB
C++
/* dll_init.h
|
|
|
|
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008,
|
|
2009 Red Hat, Inc.
|
|
|
|
This file is part of Cygwin.
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
details. */
|
|
|
|
struct per_module
|
|
{
|
|
char ***envptr;
|
|
void (**ctors)(void);
|
|
void (**dtors)(void);
|
|
void *data_start;
|
|
void *data_end;
|
|
void *bss_start;
|
|
void *bss_end;
|
|
int (*main)(int, char **, char **);
|
|
per_module &operator = (per_process *p)
|
|
{
|
|
envptr = p->envptr;
|
|
ctors = p->ctors;
|
|
dtors = p->dtors;
|
|
data_start = p->data_start;
|
|
data_end = p->data_end;
|
|
bss_start = p->bss_start;
|
|
bss_end = p->bss_end;
|
|
main = p->main;
|
|
return *this;
|
|
}
|
|
void run_ctors ();
|
|
void run_dtors ();
|
|
};
|
|
|
|
|
|
typedef enum
|
|
{
|
|
DLL_NONE,
|
|
DLL_LINK,
|
|
DLL_LOAD,
|
|
DLL_ANY
|
|
} dll_type;
|
|
|
|
struct dll
|
|
{
|
|
struct dll *next, *prev;
|
|
per_module p;
|
|
HMODULE handle;
|
|
int count;
|
|
dll_type type;
|
|
WCHAR name[1];
|
|
void detach ();
|
|
int init ();
|
|
};
|
|
|
|
#define MAX_DLL_BEFORE_INIT 100
|
|
|
|
class dll_list
|
|
{
|
|
dll *end;
|
|
dll *hold;
|
|
dll_type hold_type;
|
|
public:
|
|
dll start;
|
|
int tot;
|
|
int loaded_dlls;
|
|
int reload_on_fork;
|
|
dll *operator [] (const PWCHAR name);
|
|
dll *alloc (HINSTANCE, per_process *, dll_type);
|
|
void detach (void *);
|
|
void init ();
|
|
void load_after_fork (HANDLE);
|
|
dll *inext ()
|
|
{
|
|
while ((hold = hold->next))
|
|
if (hold_type == DLL_ANY || hold->type == hold_type)
|
|
break;
|
|
return hold;
|
|
}
|
|
dll *istart (dll_type t)
|
|
{
|
|
hold_type = t;
|
|
hold = &start;
|
|
return inext ();
|
|
}
|
|
friend void dll_global_dtors ();
|
|
};
|
|
|
|
extern dll_list dlls;
|
|
void dll_global_dtors ();
|