Add thiscall calling convention, mostly for hooking purpose (#14466)
* Add thiscall calling convention, mostly for hooking purpose * add changelog and documentation
This commit is contained in:
parent
cc65ae6011
commit
00fa7a5747
6 changed files with 13 additions and 4 deletions
|
|
@ -159,6 +159,8 @@ proc mydiv(a, b): int {.raises: [].} =
|
||||||
The reason for this is that `DivByZeroDefect` inherits from `Defect` and
|
The reason for this is that `DivByZeroDefect` inherits from `Defect` and
|
||||||
with `--panics:on` `Defects` become unrecoverable errors.
|
with `--panics:on` `Defects` become unrecoverable errors.
|
||||||
|
|
||||||
|
- Added `thiscall` calling convention as specified by Microsoft, mostly for hooking purpose
|
||||||
|
|
||||||
## Compiler changes
|
## Compiler changes
|
||||||
|
|
||||||
- Specific warnings can now be turned into errors via `--warningAsError[X]:on|off`.
|
- Specific warnings can now be turned into errors via `--warningAsError[X]:on|off`.
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,13 @@ type
|
||||||
ccInline, # proc should be inlined
|
ccInline, # proc should be inlined
|
||||||
ccNoInline, # proc should not be inlined
|
ccNoInline, # proc should not be inlined
|
||||||
ccFastCall, # fastcall (pass parameters in registers)
|
ccFastCall, # fastcall (pass parameters in registers)
|
||||||
|
ccThisCall, # thiscall (parameters are pushed right-to-left)
|
||||||
ccClosure, # proc has a closure
|
ccClosure, # proc has a closure
|
||||||
ccNoConvention # needed for generating proper C procs sometimes
|
ccNoConvention # needed for generating proper C procs sometimes
|
||||||
|
|
||||||
const
|
const
|
||||||
CallingConvToStr*: array[TCallingConvention, string] = ["", "stdcall",
|
CallingConvToStr*: array[TCallingConvention, string] = ["", "stdcall",
|
||||||
"cdecl", "safecall", "syscall", "inline", "noinline", "fastcall",
|
"cdecl", "safecall", "syscall", "inline", "noinline", "fastcall", "thiscall",
|
||||||
"closure", "noconv"]
|
"closure", "noconv"]
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,7 @@ const
|
||||||
"N_STDCALL", "N_CDECL", "N_SAFECALL",
|
"N_STDCALL", "N_CDECL", "N_SAFECALL",
|
||||||
"N_SYSCALL", # this is probably not correct for all platforms,
|
"N_SYSCALL", # this is probably not correct for all platforms,
|
||||||
# but one can #define it to what one wants
|
# but one can #define it to what one wants
|
||||||
"N_INLINE", "N_NOINLINE", "N_FASTCALL", "N_CLOSURE", "N_NOCONV"]
|
"N_INLINE", "N_NOINLINE", "N_FASTCALL", "N_THISCALL", "N_CLOSURE", "N_NOCONV"]
|
||||||
|
|
||||||
proc cacheGetType(tab: TypeCache; sig: SigHash): Rope =
|
proc cacheGetType(tab: TypeCache; sig: SigHash): Rope =
|
||||||
# returns nil if we need to declare this type
|
# returns nil if we need to declare this type
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ type
|
||||||
wLineDir, wStackTrace, wLineTrace, wLink, wCompile,
|
wLineDir, wStackTrace, wLineTrace, wLink, wCompile,
|
||||||
wLinksys, wDeprecated, wVarargs, wCallconv, wDebugger,
|
wLinksys, wDeprecated, wVarargs, wCallconv, wDebugger,
|
||||||
wNimcall, wStdcall, wCdecl, wSafecall, wSyscall, wInline, wNoInline,
|
wNimcall, wStdcall, wCdecl, wSafecall, wSyscall, wInline, wNoInline,
|
||||||
wFastcall, wClosure, wNoconv, wOn, wOff, wChecks, wRangeChecks,
|
wFastcall, wThiscall, wClosure, wNoconv, wOn, wOff, wChecks, wRangeChecks,
|
||||||
wBoundChecks, wOverflowChecks, wNilChecks,
|
wBoundChecks, wOverflowChecks, wNilChecks,
|
||||||
wFloatChecks, wNanChecks, wInfChecks, wStyleChecks, wStaticBoundchecks,
|
wFloatChecks, wNanChecks, wInfChecks, wStyleChecks, wStaticBoundchecks,
|
||||||
wNonReloadable, wExecuteOnReload,
|
wNonReloadable, wExecuteOnReload,
|
||||||
|
|
@ -139,7 +139,7 @@ const
|
||||||
"push", "pop", "define", "undef", "linedir", "stacktrace", "linetrace",
|
"push", "pop", "define", "undef", "linedir", "stacktrace", "linetrace",
|
||||||
"link", "compile", "linksys", "deprecated", "varargs",
|
"link", "compile", "linksys", "deprecated", "varargs",
|
||||||
"callconv", "debugger", "nimcall", "stdcall",
|
"callconv", "debugger", "nimcall", "stdcall",
|
||||||
"cdecl", "safecall", "syscall", "inline", "noinline", "fastcall", "closure",
|
"cdecl", "safecall", "syscall", "inline", "noinline", "fastcall", "thiscall", "closure",
|
||||||
"noconv", "on", "off", "checks", "rangechecks", "boundchecks",
|
"noconv", "on", "off", "checks", "rangechecks", "boundchecks",
|
||||||
"overflowchecks", "nilchecks",
|
"overflowchecks", "nilchecks",
|
||||||
"floatchecks", "nanchecks", "infchecks", "stylechecks", "staticboundchecks",
|
"floatchecks", "nanchecks", "infchecks", "stylechecks", "staticboundchecks",
|
||||||
|
|
|
||||||
|
|
@ -1917,6 +1917,10 @@ Nim supports these `calling conventions`:idx:\:
|
||||||
Fastcall means different things to different C compilers. One gets whatever
|
Fastcall means different things to different C compilers. One gets whatever
|
||||||
the C ``__fastcall`` means.
|
the C ``__fastcall`` means.
|
||||||
|
|
||||||
|
`thiscall`:idx:
|
||||||
|
This is thiscall calling convention as specified by Microsoft, used on C++
|
||||||
|
class member functions on the x86 architecture
|
||||||
|
|
||||||
`syscall`:idx:
|
`syscall`:idx:
|
||||||
The syscall convention is the same as ``__syscall`` in C. It is used for
|
The syscall convention is the same as ``__syscall`` in C. It is used for
|
||||||
interrupts.
|
interrupts.
|
||||||
|
|
|
||||||
|
|
@ -173,12 +173,14 @@ __AVR__
|
||||||
# define N_STDCALL(rettype, name) rettype __stdcall name
|
# define N_STDCALL(rettype, name) rettype __stdcall name
|
||||||
# define N_SYSCALL(rettype, name) rettype __syscall name
|
# define N_SYSCALL(rettype, name) rettype __syscall name
|
||||||
# define N_FASTCALL(rettype, name) rettype __fastcall name
|
# define N_FASTCALL(rettype, name) rettype __fastcall name
|
||||||
|
# define N_THISCALL(rettype, name) rettype __thiscall name
|
||||||
# define N_SAFECALL(rettype, name) rettype __stdcall name
|
# define N_SAFECALL(rettype, name) rettype __stdcall name
|
||||||
/* function pointers with calling convention: */
|
/* function pointers with calling convention: */
|
||||||
# define N_CDECL_PTR(rettype, name) rettype (__cdecl *name)
|
# define N_CDECL_PTR(rettype, name) rettype (__cdecl *name)
|
||||||
# define N_STDCALL_PTR(rettype, name) rettype (__stdcall *name)
|
# define N_STDCALL_PTR(rettype, name) rettype (__stdcall *name)
|
||||||
# define N_SYSCALL_PTR(rettype, name) rettype (__syscall *name)
|
# define N_SYSCALL_PTR(rettype, name) rettype (__syscall *name)
|
||||||
# define N_FASTCALL_PTR(rettype, name) rettype (__fastcall *name)
|
# define N_FASTCALL_PTR(rettype, name) rettype (__fastcall *name)
|
||||||
|
# define N_THISCALL_PTR(rettype, name) rettype (__thiscall *name)
|
||||||
# define N_SAFECALL_PTR(rettype, name) rettype (__stdcall *name)
|
# define N_SAFECALL_PTR(rettype, name) rettype (__stdcall *name)
|
||||||
|
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue