4 ms·
There is no such thing as a C calling convention. It isn't in the language spec. Also I am not sure which one in common use behaves exactly as you say. On ia32
by asveikau 12y ago
There is no such thing as a C calling convention. It isn't in the language spec.
Also I am not sure which one in common use behaves exactly as you say. On ia32 it's usually all stack. (Though I think Microsoft uses ECX for the c++ this pointer.) On amd64 it's common to use registers for the first few integers. (Say, 4 of them.)
Further, within a non-exported function it's fair game to break ABIs/calling conventions.
- Retra 12y agoA convention is a convention. It doesn't need a spec.
- asveikau 12y agoC is a language with a spec. When you say "c calling convention" this implies that it is C, and not something else. There are various ABIs, some with specs and some with unwritten rules, but two C programs can run on the same platform conforming to differing ABIs and still be both C. If this sounds far fetched, consider for example that it's common to experience a lot of pain trying to link code compiled with GCC against code compiled with the ms compiler or vice-versa. Same language, CPU, OS. Differing abi.
- asuffield 12y agoThe C language spec alone is not sufficient to build a useful system. You're also going to need some kind of operating system interface (defined in POSIX), binary format (ELF), and so on. The specification that you're both trying to find is called the "System V Application Binary Interface, AMD64 Architecture Processor Supplement" and is found here: http://www.x86-64.org/documentation/abi.pdf http://www.x86-64.org/documentation/abi.pdf There are similar variations for other architectures. Microsoft does something different, I don't know where their spec lives.
- asveikau 12y agoThat is the sysv abi, popular with unixy platforms. It's one abi. You have already mentioned there are others. So how is it "what I was trying to find"? My point is there is not one that is called "C".