OSDN Git Service

* dll_init.cc (dll_global_dtors): Add an additional test to avoid walking the
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / dll_init.h
1 /* dll_init.h
2
3    Copyright 1998, 1999, 2000, 2001 Red Hat, Inc.
4
5 This file is part of Cygwin.
6
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
9 details. */
10
11 struct per_module
12 {
13   char ***envptr;
14   void (**ctors)(void);
15   void (**dtors)(void);
16   void *data_start;
17   void *data_end;
18   void *bss_start;
19   void *bss_end;
20   int (*main)(int, char **, char **);
21   per_module &operator = (per_process *p)
22   {
23     envptr = p->envptr;
24     ctors = p->ctors;
25     dtors = p->dtors;
26     data_start = p->data_start;
27     data_end = p->data_end;
28     bss_start = p->bss_start;
29     bss_end = p->bss_end;
30     main = p->main;
31     return *this;
32   }
33   void run_ctors ();
34   void run_dtors ();
35 };
36
37
38 typedef enum
39 {
40   DLL_NONE,
41   DLL_LINK,
42   DLL_LOAD,
43   DLL_ANY
44 } dll_type;
45
46 struct dll
47 {
48   struct dll *next, *prev;
49   per_module p;
50   HMODULE handle;
51   int count;
52   dll_type type;
53   int namelen;
54   char name[NT_MAX_PATH];
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 char *name);
72   dll *alloc (HINSTANCE, per_process *, dll_type);
73   void detach (void *);
74   void init ();
75   void load_after_fork (HANDLE, dll *);
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 ();