Mercurial > projects > ldc
comparison tango/lib/compiler/llvmdc/dmain2.d @ 409:8d62834490d8
Fixed (I hope) problem with monitor/synchronized stuff not being properly initialized on Windows.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sun, 27 Jul 2008 15:03:04 +0200 |
parents | 56a1c1c52142 |
children |
comparison
equal
deleted
inserted
replaced
408:dc7dff3ce72e | 409:8d62834490d8 |
---|---|
85 | 85 |
86 extern (C) bool rt_trapExceptions = true; | 86 extern (C) bool rt_trapExceptions = true; |
87 | 87 |
88 void _d_criticalInit() | 88 void _d_criticalInit() |
89 { | 89 { |
90 version (linux) | 90 _STI_monitor_staticctor(); |
91 { | 91 _STI_critical_init(); |
92 _STI_monitor_staticctor(); | 92 } |
93 _STI_critical_init(); | 93 |
94 } | 94 // this is here so users can manually initialize the runtime |
95 } | 95 // for example, when there is no main function etc. |
96 | |
97 extern (C) bool rt_init( void delegate( Exception ) dg = null ) | 96 extern (C) bool rt_init( void delegate( Exception ) dg = null ) |
98 { | 97 { |
99 _d_criticalInit(); | 98 _d_criticalInit(); |
100 | 99 |
101 try | 100 try |
117 return false; | 116 return false; |
118 } | 117 } |
119 | 118 |
120 void _d_criticalTerm() | 119 void _d_criticalTerm() |
121 { | 120 { |
122 version (linux) | 121 _STD_critical_term(); |
123 { | 122 _STD_monitor_staticdtor(); |
124 _STD_critical_term(); | 123 } |
125 _STD_monitor_staticdtor(); | 124 |
126 } | 125 // this is here so users can manually terminate the runtime |
127 } | 126 // for example, when there is no main function etc. |
128 | |
129 extern (C) bool rt_term( void delegate( Exception ) dg = null ) | 127 extern (C) bool rt_term( void delegate( Exception ) dg = null ) |
130 { | 128 { |
131 try | 129 try |
132 { | 130 { |
133 thread_joinAll(); | 131 thread_joinAll(); |
166 extern (C) int main(int argc, char **argv, char** env) | 164 extern (C) int main(int argc, char **argv, char** env) |
167 { | 165 { |
168 char[][] args; | 166 char[][] args; |
169 int result; | 167 int result; |
170 | 168 |
171 version (linux) | 169 debug(PRINTF) printf("main ctors\n"); |
172 { | 170 _STI_monitor_staticctor(); |
173 debug(PRINTF) printf("main ctors\n"); | 171 _STI_critical_init(); |
174 _STI_monitor_staticctor(); | |
175 _STI_critical_init(); | |
176 } | |
177 | 172 |
178 debug(PRINTF) printf("main args\n"); | 173 debug(PRINTF) printf("main args\n"); |
179 version (Win32) | 174 version (Win32) |
180 { | 175 { |
181 wchar_t* wcbuf = GetCommandLineW(); | 176 wchar_t* wcbuf = GetCommandLineW(); |
286 gc_term(); | 281 gc_term(); |
287 } | 282 } |
288 | 283 |
289 tryExec(&runAll); | 284 tryExec(&runAll); |
290 | 285 |
291 version (linux) | 286 debug(PRINTF) printf("main dtor\n"); |
292 { | 287 _STD_critical_term(); |
293 debug(PRINTF) printf("main dtor\n"); | 288 _STD_monitor_staticdtor(); |
294 _STD_critical_term(); | 289 |
295 _STD_monitor_staticdtor(); | |
296 } | |
297 return result; | 290 return result; |
298 } | 291 } |