This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

va_arg and Alignment


Hi all,

I am porting gcc to a 16-bit DSP. This can can only load/store 32-bit
values when they are aligned on 32-bit boundaries. Suppose I have the
following:

void f (int n, ...)
{
  long l;

  va_list ap;
  va_start (ap,n);

  l = va_arg(ap, long);

  va_end (ap);
}

int main ()
{
  f (3, (long) 123);
}

The call to `f' is correctly initialised, with the long value being
aligned on a 32-bit boundary. However, within `f', the va_arg line will
try to load the long value from a location which isn't on the correct
boundary (i.e., the 16-bit address of the last named parameter + 16-bits).
Why doesn't va_arg respect the aligment requirements of the arguments, and
what is the easiest way to fix this problem?

Thanks

dan.

=============================================================================
Daniel Towner
picoChip Designs Ltd., Riverside Buildings, 108, Walcot Street, BATH, BA1
5BG
dant@picochip.com
07786 702589



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]