lkml.org 
[lkml]   [2006]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 2/3] Import fw-ohci driver.
    Kristian Høgsberg wrote:
    > Stefan Richter wrote:
    >> Kristian Høgsberg wrote:
    >>> Yup, I've done away with the bitfields and switched to a mix of __le16
    >>> and __le32 struct fields.
    >>
    >> I suppose the struct should get __attribute__((packed)) then.
    >
    > I guess it wouldn't harm, but is it really necessary? Would gcc ever
    > insert padding here, all the 32 bit fields a 32 bit aligned, and so are
    > the 16 bit fields.

    Is 2-byte alignment of 16bit struct members guaranteed on all platforms?

    A related question:
    If I specify a struct which, among else, contains 32bit quantities, then
    any variable of this struct type is supposed to be at least 4-byte-aligned.
    No if I specifiy this struct as packed, will variables of this type still
    be aligned on 4 byte boundaries or will the compiler assume no alignment?
    In other words, should it be __attribute__((packed,aligned(4))) then?
    I'm speaking about situations where I not only wish to avoid unnecessarily
    bad machine code due to unaligned access but where the device requires
    4-byte alignment too.
    --
    Stefan Richter
    -=====-=-==- ==-- -=-=-
    http://arcgraph.de/sr/
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2006-12-11 00:01    [W:0.020 / U:29.764 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site