OSDN Git Service

gas/opcodes: blackfin: move dsp mac func defines to common header
[pf3gnuchains/sourceware.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   bool has_dtors;
54   dll_type type;
55   WCHAR name[1];
56   void detach ();
57   int init ();
58   void run_dtors ()
59   {
60     if (has_dtors)
61       {
62         has_dtors = 0;
63         p.run_dtors ();
64       }
65   }
66 };
67
68 #define MAX_DLL_BEFORE_INIT     100
69
70 class dll_list
71 {
72   dll *end;
73   dll *hold;
74   dll_type hold_type;
75 public:
76   dll start;
77   int tot;
78   int loaded_dlls;
79   int reload_on_fork;
80   dll *operator [] (const PWCHAR name);
81   dll *alloc (HINSTANCE, per_process *, dll_type);
82   dll *find (void *);
83   void detach (void *);
84   void init ();
85   void load_after_fork (HANDLE);
86   dll *inext ()
87   {
88     while ((hold = hold->next))
89       if (hold_type == DLL_ANY || hold->type == hold_type)
90         break;
91     return hold;
92   }
93   dll *istart (dll_type t)
94   {
95     hold_type = t;
96     hold = &start;
97     return inext ();
98   }
99   friend void dll_global_dtors ();
100 };
101
102 extern dll_list dlls;
103 void dll_global_dtors ();
104
105 /* These probably belong in a newlib header but we can keep them here
106    for now.  */
107 extern "C" int __cxa_atexit(void (*)(void*), void*, void*);
108 extern "C" int __cxa_finalize(void*);