OSDN Git Service

* cygheap.h (mini_cygheap): New struct.
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / dll_init.h
1 /* dll_init.h
2
3    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008,
4    2009 Red Hat, Inc.
5
6 This file is part of Cygwin.
7
8 This software is a copyrighted work licensed under the terms of the
9 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
10 details. */
11
12 struct per_module
13 {
14   char ***envptr;
15   void (**ctors)(void);
16   void (**dtors)(void);
17   void *data_start;
18   void *data_end;
19   void *bss_start;
20   void *bss_end;
21   int (*main)(int, char **, char **);
22   per_module &operator = (per_process *p)
23   {
24     envptr = p->envptr;
25     ctors = p->ctors;
26     dtors = p->dtors;
27     data_start = p->data_start;
28     data_end = p->data_end;
29     bss_start = p->bss_start;
30     bss_end = p->bss_end;
31     main = p->main;
32     return *this;
33   }
34   void run_ctors ();
35   void run_dtors ();
36 };
37
38
39 typedef enum
40 {
41   DLL_NONE,
42   DLL_LINK,
43   DLL_LOAD,
44   DLL_ANY
45 } dll_type;
46
47 struct dll
48 {
49   struct dll *next, *prev;
50   per_module p;
51   HMODULE handle;
52   int count;
53   dll_type type;
54   WCHAR name[1];
55   void detach ();
56   int init ();
57 };
58
59 #define MAX_DLL_BEFORE_INIT     100
60
61 class dll_list
62 {
63   dll *end;
64   dll *hold;
65   dll_type hold_type;
66 public:
67   dll start;
68   int tot;
69   int loaded_dlls;
70   int reload_on_fork;
71   dll *operator [] (const PWCHAR name);
72   dll *alloc (HINSTANCE, per_process *, dll_type);
73   void detach (void *);
74   void init ();
75   void load_after_fork (HANDLE);
76   dll *inext ()
77   {
78     while ((hold = hold->next))
79       if (hold_type == DLL_ANY || hold->type == hold_type)
80         break;
81     return hold;
82   }
83   dll *istart (dll_type t)
84   {
85     hold_type = t;
86     hold = &start;
87     return inext ();
88   }
89   friend void dll_global_dtors ();
90 };
91
92 extern dll_list dlls;
93 void dll_global_dtors ();