Date: Thu, 13 Jan 2005 09:15:59 +0200 From: Ville-Pertti Keinonen <will@exomi.com> To: freebsd-amd64@freebsd.org Cc: wpaul@windriver.com Subject: Re: RFC: if_ndis on amd64 Message-ID: <1105600559.662.56.camel@localhost> In-Reply-To: <20050112233323.GA29445@dragon.nuxi.com> References: <1105569437.670.45.camel@localhost> <20050112233323.GA29445@dragon.nuxi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 2005-01-12 at 15:33 -0800, David O'Brien wrote: > What are "calling conventions that everyone else uses"?? Such things > really don't exist as x86 CPU's don't force a particular way. It is up > to the compiler writer to do what he wants. Note that I didn't even try to claim "standard" calling conventions; however AFAIK all of the released operating systems that run on amd64 (*BSD, Linux, Solaris) use the same C ABI (SysV (ELF) ABI). Often at least the basic C calling conventions are compatible across ABIs. > Both the AMD64 ELF and AMD64 PE (mswin) ABI's specify that the first X > parameters are passed in registers (beyond that on the stack). So both > ELF (ie, FreeBSD) and MSwin passes parameters differently on 32-bit > "i386" vs. 64-bit AMD64. The different i386 conventions are at least partly to historical reasons. Since 64-bit mode is inevitably incompatible with 32-bit mode, I was hoping 64-bit mode would be somewhat more consistent. Anyhow, having to create wrappers isn't that bad, and should be possible to be coerced to work correctly. The varargs kludge I used should be possible to eliminate by transforming the arguments into a va_list instead of trying to preserve it as a varargs call. Something like: ENTRY(sprintf_x64) subq $40,%rsp mov %rdi,32(%rsp) mov %rsi,24(%rsp) mov %r8,40+8+16(%rsp) mov %r9,40+8+24(%rsp) movl $48,(%rsp) movl $0,4(%rsp) lea 40+8+16(%rsp),%rax mov %rax,8(%rsp) mov %rax,16(%rsp) mov %rcx,%rdi mov %rdx,%rsi mov %rsp,%rdx call vsprintf mov 32(%rsp),%rdi mov 24(%rsp),%rsi addq $40,%rsp ret
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1105600559.662.56.camel>