Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Mar 2004 16:01:45 +0900
From:      Alexander Nedotsukov <bland@FreeBSD.org>
To:        alpha@FreeBSD.org
Subject:   Is the way static data alligned correct?
Message-ID:  <405554D9.4000208@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
Guys,

Recently doing some development I hit alignment problem on alpha 
machines. Problem solved but the way I did it in fact the reason why I 
asking pros to judge who is wrong here.
Inside code I have linked-in data blocks generated by external tool. 
They looks like this:
    const unsigned char raw_data_block[] = { bla-bla-bla };
Internal block content is 8 bytes aligned. Each block resides in a 
single .c file. So after compilation I have a set of .o files linked 
later into single shared object (library). Taking an address of such 
data block and casting it to pointer to some real structure was a 
problem because it is not necesary 8 byte aligned. Obvious solution was 
to ask explicitly for such alignment:
    const unsigned char raw_data_block[] __attribute__ ((alligned(8))) = 
{ bla-bla-bla };
But I wonder is this gcc bug or space optimization for char arrays only?

Thanks,
Alexander.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?405554D9.4000208>