lkml.org 
[lkml]   [2008]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [RFC-PATCH] lib: add byteorder helpers for the aligned case
    On Fri, 16 May 2008, Harvey Harrison wrote:

    > Some users know the pointer they are writing to are aligned,
    > rather than doing *(__le16 *)ptr = cpu_to_le16(val) add helpers
    > wrapping this up that have the same convention as put_unaligned_le/be.
    >
    > Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
    > ---
    > Alan, as requested, I'm looking around a bit to see if there are actual
    > users for this. But it does make a nice complement to the unaligned
    > versions.

    This is great -- thanks! I've wanted this sort of thing for a long
    time. There's a good chance that the SCSI core could make use of
    it. Try looking at the prep functions in sd.c and sr.c.

    > +static inline void put_le16(u16 val, void *ptr)
    > +{
    > + *(__le16 *)ptr = cpu_to_le16(val);
    > +}

    Is this able to do the byte rearrangement at compile time if val is a
    compile-time constant? I imagine it would.

    Alan Stern



    \
     
     \ /
      Last update: 2008-05-17 02:39    [W:3.168 / U:0.000 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site