[sldev] alignment problems in the viewer

Dana Fagerstrom Dana.Fagerstrom at Sun.COM
Mon Jun 11 07:51:48 PDT 2007


Folks,

One of the largest problems I've had in porting the viewer to SPARC are 
  alignment problems assumed throughout the source.  For example, 
llmath/lluuid.h defines mData as:

	U8 mData[[UUID_BYTES];

Tricks are used using U32 so that 4 byte chunks can be manipulated. 
This is all well and good when the CPU in question aligns properly but 
it fails miserably on other CPUs.  It's not a weakness of the CPU but 
poor coding practice.

I've been able to get around these issues using:

        U8 mData[UUID_BYTES] __attribute__ ((aligned(8)));

which forces the compiler to ensure all bytes are aligned and no padding 
is added.

I'd like to ask those much more familiar with the code to identify other 
areas where this alignment is assumed so I can fix the code accordingly. 
As expected, I am wrapping these changes in #if's so that x86 users get 
the original code and so that the Lindens can decide if the changes 
should be made permanent across all platform.

Thanks,
D


-- 
=====================================================================
Dana Fagerstrom                        Phone: 877.851.6343
Sun Services                             Fax: 877.851.6343
400 Atrium Dr.                         Email: dana.fagerstrom at Sun.COM
Somerset, NJ  08873               SneakerNet: USMT01
=====================================================================
    Pressure - It can turn a lump of coal into a flawless diamond,
               and an average person into a perfect basketcase.
               -- www.despair.com
=====================================================================



More information about the SLDev mailing list