Changeset 514
- Timestamp:
- 01/16/11 07:18:28 (14 years ago)
- Files:
-
- trunk/src/rt/dmain2.d (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/rt/dmain2.d
r508 r514 14 14 module rt.dmain2; 15 15 16 16 private 17 17 { 18 18 import rt.memory; 19 19 import rt.util.console; 20 20 import rt.util.string; 21 21 import core.stdc.stddef; 22 22 import core.stdc.stdlib; 23 23 import core.stdc.string; 24 //import core.stdc.stdio; // for printf()24 import core.stdc.stdio; // for printf() 25 25 } 26 26 27 27 version (Windows) 28 28 { 29 29 private import core.stdc.wchar_; 30 30 31 31 extern (Windows) alias int function() FARPROC; 32 32 extern (Windows) FARPROC GetProcAddress(void*, in char*); 33 33 extern (Windows) void* LoadLibraryA(in char*); 34 34 extern (Windows) int FreeLibrary(void*); … … 106 106 107 107 alias void* function() gcGetFn; 108 108 alias void function(void*) gcSetFn; 109 109 alias void function() gcClrFn; 110 110 } 111 111 112 112 extern (C) void* rt_loadLibrary(in char[] name) 113 113 { 114 114 version (Windows) 115 115 { 116 // Load a DLL at runtime 116 117 char[260] temp = void; 117 118 temp[0 .. name.length] = name[]; 118 119 temp[name.length] = cast(char) 0; 120 // BUG: LoadLibraryA() call calls rt_init(), which fails if proxy is not set! 119 121 void* ptr = LoadLibraryA(temp.ptr); 120 122 if (ptr is null) 121 123 return ptr; 122 124 gcSetFn gcSet = cast(gcSetFn) GetProcAddress(ptr, "gc_setProxy"); 123 125 if (gcSet !is null) 126 { // BUG: Set proxy, but too late 124 127 gcSet(gc_getProxy()); 128 } 125 129 return ptr; 126 130 127 131 } 128 132 else version (Posix) 129 133 { 130 134 throw new Exception("rt_loadLibrary not yet implemented on Posix."); 131 135 } 132 136 } 133 137 134 138 extern (C) bool rt_unloadLibrary(void* ptr) … … 271 275 _minit(); 272 276 _moduleCtor(); 273 277 _moduleTlsCtor(); 274 278 runModuleUnitTests(); 275 279 return true; 276 280 } 277 281 catch (Throwable e) 278 282 { 279 283 if (dg) 280 284 dg(e); 285 else 286 throw e; // rethrow, don't silently ignore error 281 287 } 282 288 _d_criticalTerm(); 283 289 return false; 284 290 } 285 291 286 292 void _d_criticalTerm() 287 293 { 288 294 version (Posix) 289 295 { 290 296 _STD_critical_term();
