Messages in this thread | | | Date | Fri, 16 May 2008 20:35:56 -0400 (EDT) | From | Alan Stern <> | Subject | Re: [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
| |