mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
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:
@@ -159,6 +159,8 @@ proc mydiv(a, b): int {.raises: [].} =
|
||||
The reason for this is that `DivByZeroDefect` inherits from `Defect` and
|
||||
with `--panics:on` `Defects` become unrecoverable errors.
|
||||
|
||||
- Added `thiscall` calling convention as specified by Microsoft, mostly for hooking purpose
|
||||
|
||||
## Compiler changes
|
||||
|
||||
- Specific warnings can now be turned into errors via `--warningAsError[X]:on|off`.
|
||||
|
||||
@@ -25,12 +25,13 @@ type
|
||||
ccInline, # proc should be inlined
|
||||
ccNoInline, # proc should not be inlined
|
||||
ccFastCall, # fastcall (pass parameters in registers)
|
||||
ccThisCall, # thiscall (parameters are pushed right-to-left)
|
||||
ccClosure, # proc has a closure
|
||||
ccNoConvention # needed for generating proper C procs sometimes
|
||||
|
||||
const
|
||||
CallingConvToStr*: array[TCallingConvention, string] = ["", "stdcall",
|
||||
"cdecl", "safecall", "syscall", "inline", "noinline", "fastcall",
|
||||
"cdecl", "safecall", "syscall", "inline", "noinline", "fastcall", "thiscall",
|
||||
"closure", "noconv"]
|
||||
|
||||
type
|
||||
|
||||
@@ -238,7 +238,7 @@ const
|
||||
"N_STDCALL", "N_CDECL", "N_SAFECALL",
|
||||
"N_SYSCALL", # this is probably not correct for all platforms,
|
||||
# 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 =
|
||||
# returns nil if we need to declare this type
|
||||
|
||||
@@ -51,7 +51,7 @@ type
|
||||
wLineDir, wStackTrace, wLineTrace, wLink, wCompile,
|
||||
wLinksys, wDeprecated, wVarargs, wCallconv, wDebugger,
|
||||
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,
|
||||
wFloatChecks, wNanChecks, wInfChecks, wStyleChecks, wStaticBoundchecks,
|
||||
wNonReloadable, wExecuteOnReload,
|
||||
@@ -139,7 +139,7 @@ const
|
||||
"push", "pop", "define", "undef", "linedir", "stacktrace", "linetrace",
|
||||
"link", "compile", "linksys", "deprecated", "varargs",
|
||||
"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",
|
||||
"overflowchecks", "nilchecks",
|
||||
"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
|
||||
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:
|
||||
The syscall convention is the same as ``__syscall`` in C. It is used for
|
||||
interrupts.
|
||||
|
||||
@@ -173,12 +173,14 @@ __AVR__
|
||||
# define N_STDCALL(rettype, name) rettype __stdcall name
|
||||
# define N_SYSCALL(rettype, name) rettype __syscall 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
|
||||
/* function pointers with calling convention: */
|
||||
# define N_CDECL_PTR(rettype, name) rettype (__cdecl *name)
|
||||
# define N_STDCALL_PTR(rettype, name) rettype (__stdcall *name)
|
||||
# define N_SYSCALL_PTR(rettype, name) rettype (__syscall *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)
|
||||
|
||||
# ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user