This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB 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]

Re: long long considered harmful?


On Tue, Apr 22, 2003 at 03:25:21PM -0400, Kris Warkentin wrote:
> > > > typedef struct mips_cpu_registers
> > > > {
> > > >   unsigned regs[74];
> > > >   unsigned long long regs_alignment;
> > > > } MIPS_CPU_REGISTERS;
> > >
> > > What's the purpose of the alignment entry?  I doubt it does what you
> > > want it to.
> >
> > I was more or less correct on this one.  Apparently this was not even
> > defined by us but by one of our very large chip vendors who shall remain
> > nameless.  Rather than the nicer solution of just defining an array of 64
> > bit regs, they did this which necessitates some nastiness when dealing
> with
> > different endians.  The alignment field ensures that the overall structure
> > is 64 bit aligned which is a handy thing to be on mips.
> 
> Pardon me, by overall structure, I mean the starting address of the
> structure.  Having a 64 bit entry causes the compiler to align the structure
> on a 64 bit boundary.

Whoever told you this is mistaken.  A long long member of a structure
only has four byte alignment on i386-linux, for example.  That's
mandated by the psABI.

This is exactly one of those reasons why you can not use structures
on the host to describe data on the target.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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