lkml.org 
[lkml]   [1999]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    Subjectpadding/alignment question.
    Hi guys,

    In some structures I noticed a strange thing:

    struct ext2_group_desc
    {
    __u32 bg_block_bitmap; /* Blocks bitmap block */
    __u32 bg_inode_bitmap; /* Inodes bitmap block */
    __u32 bg_inode_table; /* Inodes table block */
    __u16 bg_free_blocks_count; /* Free blocks count */
    __u16 bg_free_inodes_count; /* Free inodes count */
    __u16 bg_used_dirs_count; /* Directories count */
    __u16 bg_pad;
    __u32 bg_reserved[3];
    };

    why are the last 14 bytes split into __u16 and __u32[3]? Isn't it more
    economical to write:

    struct ext2_group_desc2
    {
    __u32 bg_block_bitmap; /* Blocks bitmap block */
    __u32 bg_inode_bitmap; /* Inodes bitmap block */
    __u32 bg_inode_table; /* Inodes table block */
    __u16 bg_free_blocks_count; /* Free blocks count */
    __u16 bg_free_inodes_count; /* Free inodes count */
    __u16 bg_used_dirs_count; /* Directories count */
    __u8 bg_reserved[14];
    };

    a trivial program that prints sizeof of both confirms that it is 32 bytes
    in both cases. So, why is it not done via __u8[14]? Is there some
    alignment-related issue on non-intel architecture or what?

    I saw the same thing in ext2_super_block btw.

    Regards,
    Tigran.

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:54    [W:4.753 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site