Hi Rohit, "__attribute__((__aligned__(32)))" tells the compiler to align whatever data type it is an attribute for, to a 32 byte boundary i.e the data type will start from an address that is an exact multiple of 32. In the first example static struct s ss[32] __attribute__((__aligned__(32))) ; says, align array 'ss' on a 32 byte boundary, so the compiler rightly aligns it on a 32 byte boundary (80494e0 is an exact multiple of 32). The compiler was never asked to align each element of the array, so the next element rightly starts 8 byte after the start of the array. In the 2nd example by putting the "__attribute__((__aligned__(32)))" at the structure definition, you are asking the compiler to align any instantiation of the structure to a 32 byte boundary, so all the array elements are aligned on a 32 byte boundary. try this example struct s { void (*action) (struct s *); int *data; }__attribute__((__aligned__(32))); int main() { int k; static struct s ss[32] __attribute__((__aligned__(64))) ; printf("first %x second %x \n",&ss[0],&ss[1]); } Now the compiler will align array 'ss' on a 64 byte boundary, and then each element on a 32 byte boundary. Hope that helps. tomar On Wed, 27 Aug 2003, Rohit wrote: > Hi, > In softirq.c, statement > static struct softirq_action softirq_vec[32] > __cacheline_aligned; > > I am trying to figure out why this is cacheline_alligned. > I wrote a small piece of code to see how this may work .... > > struct s { > void (*action) (struct s *); > int *data; > }; > > int main() > { > int k; > static struct s ss[32] __attribute__((__aligned__(32))) ; > printf("first %x second %x \n",&ss[0],&ss[1]); > } > > on executing this I get > >>>>first 80494e0 second 80494e8. > Which means the two elements of ss[] are 8 bytes apart. (ie sizeof > struct s) > > I achive the 32 byte alignment by modifing the code as below. > struct s { > void (*action) (struct s *); > int *data; > }__attribute__((__aligned__(32))) ; > > and declaring > static struct s ss[32]; > > on executing I get > >>>>first 80494e0 second 8049500 > ie 2 elemnts are 32 byte apart. > > Please let me know what I am missing here. > > Regards, > Rohit. > ___________________________________________________ > Art meets Army ; Swapna Weds Capt. Rajsekhar. > Rediff Matchmaker strikes another interesting match !! > Visit http://matchmaker.rediff.com?2 > > > - > : send the line "unsubscribe linux-net" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html