Permalink
Browse files

Win64 module info

  • Loading branch information...
1 parent 655f33d commit 3c9cf0815c61740be80c187c8d6130bdf305d31b @WalterBright WalterBright committed Oct 6, 2012
Showing with 32 additions and 14 deletions.
  1. +32 −14 src/rt/minfo.d
View
@@ -102,18 +102,6 @@ private:
ModuleInfo*[] _tlsctors;
}
-version (Windows)
-{
- // Windows: this gets initialized by minit.asm
- // Posix: this gets initialized in _moduleCtor()
- extern(C) __gshared ModuleInfo*[] _moduleinfo_array;
- extern(C) void _minit();
-}
-version (OSX)
-{
- extern (C) __gshared ModuleInfo*[] _moduleinfo_array;
-}
-
__gshared ModuleGroup _moduleGroup;
/********************************************
@@ -170,7 +158,25 @@ extern (C) void rt_moduleDtor()
* Access compiler generated list of modules.
*/
-version (OSX) {}
+version (Win32)
+{
+ // Windows: this gets initialized by minit.asm
+ // Posix: this gets initialized in _moduleCtor()
+ extern(C) __gshared ModuleInfo*[] _moduleinfo_array;
+ extern(C) void _minit();
+}
+else version (Win64)
+{
+ extern (C)
+ {
+ extern void* _minfo_beg;
+ extern void* _minfo_end;
+ }
+}
+else version (OSX)
+{
+ extern (C) __gshared ModuleInfo*[] _moduleinfo_array;
+}
else version (Posix)
{
// This linked list is created by a compiler generated function inserted
@@ -183,6 +189,10 @@ else version (Posix)
extern (C) __gshared ModuleReference* _Dmodule_ref; // start of linked list
}
+else
+{
+ static assert(0);
+}
ModuleInfo*[] getModuleInfos()
out (result)
@@ -228,12 +238,20 @@ body
len++;
}
}
- else version (Windows)
+ else version (Win32)
{
// _minit directly alters the global _moduleinfo_array
_minit();
result = _moduleinfo_array;
}
+ else version (Win64)
+ {
+ result = (cast(ModuleInfo**)&_minfo_beg)[1 .. &_minfo_end - &_minfo_end];
@MartinNowak

MartinNowak Oct 6, 2012

Member

This looks wrong.

How about

auto p = cast(ModuleInfo**)&_minfo_beg + 1;
immutable cnt = cast(ModuleInfo**)&_minfo_end - p;
result = p[0 .. cnt];
+ }
+ else
+ {
+ static assert(0);
+ }
return result;
}

0 comments on commit 3c9cf08

Please sign in to comment.