private
{
+ import memory;
import util.console;
- import stdc.stddef;
- import stdc.stdlib;
- import stdc.string;
+ import core.stdc.stddef;
+ import core.stdc.stdlib;
+ import core.stdc.string;
}
-version(Windows)
+version (Windows)
{
+ extern (Windows) alias int function() FARPROC;
+ extern (Windows) FARPROC GetProcAddress(void*, in char*);
+ extern (Windows) void* LoadLibraryA(in char*);
+ extern (Windows) int FreeLibrary(void*);
extern (Windows) void* LocalFree(void*);
extern (Windows) wchar_t* GetCommandLineW();
extern (Windows) wchar_t** CommandLineToArgvW(wchar_t*, int*);
extern (Windows) export int WideCharToMultiByte(uint, uint, wchar_t*, int, char*, int, char*, int);
- pragma(lib, "shell32.lib"); // needed for CommandLineToArgvW
+ pragma(lib, "shell32.lib"); // needed for CommandLineToArgvW
}
extern (C) void _STI_monitor_staticctor();
extern (C) void _moduleDtor();
extern (C) void thread_joinAll();
+/***********************************
+ * These are a temporary means of providing a GC hook for DLL use. They may be
+ * replaced with some other similar functionality later.
+ */
+extern (C)
+{
+ void* gc_getProxy();
+ void gc_setProxy(void* p);
+ void gc_clrProxy();
+
+ alias void* function() gcGetFn;
+ alias void function(void*) gcSetFn;
+ alias void function() gcClrFn;
+}
+
+extern (C) void* rt_loadLibrary(in char[] name)
+{
+ version (Windows)
+ {
+ char[260] temp = void;
+ temp[0 .. name.length] = name[];
+ temp[name.length] = cast(char) 0;
+ void* ptr = LoadLibraryA(temp.ptr);
+ if (ptr is null)
+ return ptr;
+ gcSetFn gcSet = cast(gcSetFn) GetProcAddress(ptr, "gc_setProxy");
+ if (gcSet !is null)
+ gcSet(gc_getProxy());
+ return ptr;
+
+ }
+ else version (linux)
+ {
+ throw new Exception("rt_loadLibrary not yet implemented on linux.");
+ }
+}
+
+extern (C) bool rt_unloadLibrary(void* ptr)
+{
+ version (Windows)
+ {
+ gcClrFn gcClr = cast(gcClrFn) GetProcAddress(ptr, "gc_clrProxy");
+ if (gcClr !is null)
+ gcClr();
+ return FreeLibrary(ptr) != 0;
+ }
+ else version (linux)
+ {
+ throw new Exception("rt_unloadLibrary not yet implemented on linux.");
+ }
+}
+
/***********************************
* These functions must be defined for any D program linked
* against this library.
*/
extern (C) void onAssertError(string file, size_t line);
extern (C) void onAssertErrorMsg(string file, size_t line, string msg);
-extern (C) void onArrayBoundsError(string file, size_t line);
+extern (C) void onRangeError(string file, size_t line);
extern (C) void onHiddenFuncError(Object o);
extern (C) void onSwitchError(string file, size_t line);
extern (C) bool runModuleUnitTests();
extern (C) void _d_array_bounds(string file, uint line)
{
- onArrayBoundsError(file, line);
+ onRangeError(file, line);
}
extern (C) void _d_switch_error(string file, uint line)
try
{
gc_init();
+ initStaticDataGC();
version (Windows)
_minit();
_moduleCtor();
bool trapExceptions = rt_trapExceptions;
- void tryExec(void delegate() dg)
+ void tryExec(scope void delegate() dg)
{
if (trapExceptions)
void runAll()
{
gc_init();
+ initStaticDataGC();
version (Windows)
_minit();
_moduleCtor();