[coreboot] __attribute__((stdcall)) vs. __attribute__((regparm(0)))
mylesgw at gmail.com
Thu Oct 16 16:58:39 CEST 2008
> > Segher: How do regparm(0) and stdcall differ for i386?
> "stdcall" means the callee pops the args from the stack when it returns;
> "cdecl" (the default) means the caller has to pop them. "stdcall" gives
> smaller code, but cannot work for functions without prototype (you
> shouldn't have such anyway, with ISO C -- but in olden days it was the
> norm). If you would like stdcall by default, use -mrtd.
> "regparm" says how many integer arguments are passed in registers
> of on the stack. 0 is the default, and 3 is the maximum. The registers
> used are A, D, C. Use -mregparm=N to get some other default.
> So, "stdcall" and "regparm" are orthogonal. stdcall would be good for
> coreboot (smaller code size), but regparm > 0 probably increases code
> size (try it though). Whatever you use, "special" code (context
> etc. -- but also all assembler routines in general) need to be aware of
> the calling sequence in use, of course -- but they can always override
> it to something of their liking.
> What is the actual problem you are trying to solve here?
We are compiling with -mregparm=3 and that breaks the assembly files that
support interrupts in vm86.c because they expect the other calling
The question is what attribute can be used to make those functions have the
normal calling convention when compiling with -mregparm=3. We're using
-mregparm=3 for speed reasons.
More information about the coreboot