Fixing nimRawSetJmp for vcc and clangcl on Windows (#19959)
* fix vcc rawsetjmp * changing `_longjmp()` to `longjmp()` and `_setjmp()` to `setjmp()` * fix * fix setjmp to clangcl on Windows * fix genTrySetjmp() to clangcl on Windows
This commit is contained in:
parent
4897c47c80
commit
d2d8f1342b
2 changed files with 31 additions and 22 deletions
|
|
@ -1367,6 +1367,11 @@ proc genTrySetjmp(p: BProc, t: PNode, d: var TLoc) =
|
||||||
linefmt(p, cpsStmts, "$1.status = __builtin_setjmp($1.context);$n", [safePoint])
|
linefmt(p, cpsStmts, "$1.status = __builtin_setjmp($1.context);$n", [safePoint])
|
||||||
elif isDefined(p.config, "nimRawSetjmp"):
|
elif isDefined(p.config, "nimRawSetjmp"):
|
||||||
if isDefined(p.config, "mswindows"):
|
if isDefined(p.config, "mswindows"):
|
||||||
|
if isDefined(p.config, "vcc") or isDefined(p.config, "clangcl"):
|
||||||
|
# For the vcc compiler, use `setjmp()` with one argument.
|
||||||
|
# See https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setjmp?view=msvc-170
|
||||||
|
linefmt(p, cpsStmts, "$1.status = setjmp($1.context);$n", [safePoint])
|
||||||
|
else:
|
||||||
# The Windows `_setjmp()` takes two arguments, with the second being an
|
# The Windows `_setjmp()` takes two arguments, with the second being an
|
||||||
# undocumented buffer used by the SEH mechanism for stack unwinding.
|
# undocumented buffer used by the SEH mechanism for stack unwinding.
|
||||||
# Mingw-w64 has been trying to get it right for years, but it's still
|
# Mingw-w64 has been trying to get it right for years, but it's still
|
||||||
|
|
|
||||||
|
|
@ -118,10 +118,14 @@ elif defined(nimBuiltinSetjmp):
|
||||||
c_builtin_setjmp(unsafeAddr jmpb[0])
|
c_builtin_setjmp(unsafeAddr jmpb[0])
|
||||||
|
|
||||||
elif defined(nimRawSetjmp) and not defined(nimStdSetjmp):
|
elif defined(nimRawSetjmp) and not defined(nimStdSetjmp):
|
||||||
when defined(windows) and not defined(vcc):
|
when defined(windows):
|
||||||
# No `_longjmp()` on Windows.
|
# No `_longjmp()` on Windows.
|
||||||
proc c_longjmp*(jmpb: C_JmpBuf, retval: cint) {.
|
proc c_longjmp*(jmpb: C_JmpBuf, retval: cint) {.
|
||||||
header: "<setjmp.h>", importc: "longjmp".}
|
header: "<setjmp.h>", importc: "longjmp".}
|
||||||
|
when defined(vcc) or defined(clangcl):
|
||||||
|
proc c_setjmp*(jmpb: C_JmpBuf): cint {.
|
||||||
|
header: "<setjmp.h>", importc: "setjmp".}
|
||||||
|
else:
|
||||||
# The Windows `_setjmp()` takes two arguments, with the second being an
|
# The Windows `_setjmp()` takes two arguments, with the second being an
|
||||||
# undocumented buffer used by the SEH mechanism for stack unwinding.
|
# undocumented buffer used by the SEH mechanism for stack unwinding.
|
||||||
# Mingw-w64 has been trying to get it right for years, but it's still
|
# Mingw-w64 has been trying to get it right for years, but it's still
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue