Amd64 and va_arg
blog.nelhage.com
blog.nelhage.com
Also note that Power based architectures have been doing this for a long time.
It sounds like structs (at least the small ones?) get passed in registers also. I don't really understand that. Isn't it kinda a rule of C-programming that if you want your code to be fast, don't pass around structs? If structs just always went onto the stack, you wouldn't have to mess around figuring out whether its members are on the integer or floating point registers.
It's actually not a rule of performant C programming that you shouldn't pass structures by value. The contortions you end up going through to avoid it (decomposing the struct into arguments, creating temp structs to pass addresses instead of values, filling structs in from return-args) often cost more than just passing the damn thing to begin with.
On the subject of passing structs by value: it really comes down to whether you plan on copying the struct anyway or not, doesn't it?
typedef struct { unsigned long pte; } pte_t;
typedef struct { unsigned long pmd; } pmd_t;
typedef struct { unsigned long pud; } pud_t;
typedef struct { unsigned long pgd; } pgd_t;
That way, even though they're all represented as 64-bit values, the compiler
will catch you if you try to mix-and-match different types without doing
appropriate work.Passing small structs in registers means that Linux can do that, and pass around `pte_t`s as parameters, without having to worry about paying a runtime cost for their typechecking.
On Win32 (and presumably most other systems as well) it's perfectly kosher to require variadic functions to be declared cdecl. This all sounds like a giant nonissue to me. Add support for cdecl functions and move on.
(The relevant part of C99 is §6.5.2.2 Function Calls, p6).