3 ms·
Are functions with more than 6 arguments really forbidden on x86-64? How do things like CreateFile or CreateWindow from the Windows API get compiled then?
by aninteger 12y ago
Are functions with more than 6 arguments really forbidden on x86-64? How do things like CreateFile or CreateWindow from the Windows API get compiled then?
- kryptiskt 12y agoThat's the syscall calling convention, not the C one (though it's more like a platform ABI than something exclusive to C these days). In that, on Linux x64 all the args after the first six are pushed to the stack, on Windows it's after four args.
- nkurz 12y agoIt's probably worth clarifying that on 64-bit Windows, the first first four arguments are passed in registers regardless of type, and the remainder (if any) are pushed to the stack. But on 64-bit Linux/BSD/OSX, depending on the mix of types, you might have as many as 14 register arguments. You get 6 "integer" registers, plus 8 "vector" registers, where "vector" registers are also used for floating point. http://www.agner.org/optimize/calling_conventions.pdf http://www.agner.org/optimize/calling_conventions.pdf
- deleted 12y ago[deleted]