DLL fixes for windows; fixes #175

This commit is contained in:
Zahary Karadjov
2012-07-31 18:50:53 +03:00
parent 674c05f426
commit 1d065b601c
4 changed files with 16 additions and 11 deletions

View File

@@ -861,7 +861,8 @@ proc genMainProc(m: BModule) =
CommonMainBody & "}$n"
WinCDllMain =
"BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, $n" &
" LPVOID lpvReserved) {$n" & "\tNimMain();$n" &
" LPVOID lpvReserved) {$n" &
"\tif(fwdreason == DLL_PROCESS_ATTACH) NimMain();$n" &
"\treturn 1;$n" & "}$n"
PosixNimDllMain = WinNimDllMain
PosixCDllMain =

View File

@@ -212,16 +212,22 @@ proc expectDynlibNode(c: PContext, n: PNode): PNode =
result = newEmptyStrNode(n)
proc processDynLib(c: PContext, n: PNode, sym: PSym) =
if (sym == nil) or (sym.kind == skModule):
if (sym == nil) or (sym.kind == skModule):
POptionEntry(c.optionStack.tail).dynlib = getLib(c, libDynamic,
expectDynlibNode(c, n))
elif n.kind == nkExprColonExpr:
var lib = getLib(c, libDynamic, expectDynlibNode(c, n))
addToLib(lib, sym)
incl(sym.loc.flags, lfDynamicLib)
else:
incl(sym.loc.flags, lfExportLib)
else:
if n.kind == nkExprColonExpr:
var lib = getLib(c, libDynamic, expectDynlibNode(c, n))
addToLib(lib, sym)
incl(sym.loc.flags, lfDynamicLib)
else:
incl(sym.loc.flags, lfExportLib)
# since we'll be loading the dynlib symbols dynamically, we must use
# a calling convention that doesn't introduce custom name mangling
# cdecl is the default - the use can override this explicitly
if sym.typ.callConv == ccDefault:
sym.typ.callConv = ccCDecl
proc processNote(c: PContext, n: PNode) =
if (n.kind == nkExprColonExpr) and (sonsLen(n) == 2) and
(n.sons[0].kind == nkBracketExpr) and

View File

@@ -1935,7 +1935,6 @@ when not defined(EcmaScript) and not defined(NimrodVM):
include "system/syslocks"
include "system/threads"
elif not defined(nogc):
initStackBottom()
initGC()
proc setControlCHook*(hook: proc () {.noconv.})

View File

@@ -203,7 +203,6 @@ when not defined(useNimRtl):
when not useStackMaskHack:
var mainThread: TGcThread
ThreadVarSetValue(globalsSlot, addr(mainThread))
initStackBottom()
initGC()
when emulatedThreadVars: