This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


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

data alignment issues


I figured I should start a new thread for this since it's slightly off
topic for that other question.

For those of you that are searching the archives, there's a bunch of
data alignment discussions under the subject "Network programming for
eCos under Linux". :)

Anyhow, I just ran a test.  I have the structure below.  All the char
fields are just dummy values to test data alignment issues when sending
the structure over the network to my PC.  Apparently, the PC compiler
and the arm-elf-gcc compiler align the floats the same because I didn't
have a problem at all.  I believe it was aligning them to 4-byte
boundaries because the sizeof () the structure was 40 where it should
have been 28.  So, that means 3 extra padding bytes per char.  I never
bothered to look at it in memory because I've forgotten how to read
floats in hex! :)

Any comments on this alignment?  I thought the gcc compiler didn't do
any alignment?

typedef struct
{
    /* version minor */
    unsigned short versionLS,
    /* version major */
        versionMS;

    /* current accelerometer voltage level */
    float accelerometerVoltage;
    char test1;
    /* current analog 1 voltage level */
    float analogVoltage1;
    char test2;
    /* current analog 2 voltage level */
    float analogVoltage2;
    char test3;
    /* current digital board voltage level */
    float boardVoltage;
    char test4;
    /* current rig temperature level */
     float rigTemperature;
} TStatusSignals;


Trenton D. Adams
Extreme Engineering
#17, 6025 - 12 St. SE
Calgary, Alberta, Canada
T2H 2K1

Phone: 403 640 9494 ext-208
Fax: 403 640 9599

http://www.extremeeng.com



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