15 Jan, 2009

1 commit


07 Jan, 2009

2 commits

  • The __SWAB_64_THRU_32__ case of a 64-bit byte swap was depending on the
    no-longer-existant ___swab32() method (three underscores). We got rid
    of some of the worst indirection and complexity, and now it should just
    use the 32-bit swab function that was defined right above it.

    Reported-and-tested-by: Nicolas Pitre
    Reported-by: Benjamin Herrenschmidt
    Cc: Harvey Harrison
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • The first step to make swab.h a regular header that will
    include an asm/swab.h with arch overrides.

    Avoid the gratuitous differences introduced in the new
    linux/swab.h by naming the ___constant_swabXX bits and
    __fswabXX bits exactly as found in the old implementation
    in byteorder/swab[b].h

    Use this new swab.h in byteorder/[big|little]_endian.h and
    remove the two old swab headers.

    Although the inclusion of asm/byteorder.h looks strange in
    linux/swab.h, this will allow each arch to move the actual
    arch overrides for the swab bits in an asm file and then
    the includes can be cleaned up without requiring a flag day
    for all arches at once.

    Keep providing __fswabXX in case some userspace was using them
    directly, but the revised __swabXX should be used instead in
    any new code and will always do constant folding not dependent
    on the optimization level, which means the __constant versions
    can be phased out in-kernel.

    Arches that use the old-style arch macros will lose their
    optimized versions until they move to the new style, but at
    least they will still compile. Many arches have already moved
    and the patches to move the remaining arches are trivial.

    Signed-off-by: Harvey Harrison
    Signed-off-by: Linus Torvalds

    Harvey Harrison
     

20 Oct, 2008

1 commit

  • This makes the new implementation of the byteorder helpers match the old
    in how it degraded when an arch-defined version was not available:

    1) swab()
    - look for arch defined
    - if not, use generic c version

    2) swabp()
    - look for arch-defined
    - if not, deref pointer and use swab()

    3) swabs()
    - look for arch defined
    - if not, use swabp

    Signed-off-by: Harvey Harrison
    Cc: "David S. Miller"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Harvey Harrison
     

13 Aug, 2008

1 commit

  • Collect the implementations from include/linux/byteorder/swab.h, swabb.h
    in swab.h

    The functionality provided covers:
    u16 swab16(u16 val) - return a byteswapped 16 bit value
    u32 swab32(u32 val) - return a byteswapped 32 bit value
    u64 swab64(u64 val) - return a byteswapped 64 bit value
    u32 swahw32(u32 val) - return a wordswapped 32 bit value
    u32 swahb32(u32 val) - return a high/low byteswapped 32 bit value

    Similar to above, but return swapped value from a naturally-aligned pointer
    u16 swab16p(u16 *p)
    u32 swab32p(u32 *p)
    u64 swab64p(u64 *p)
    u32 swahw32p(u32 *p)
    u32 swahb32p(u32 *p)

    Similar to above, but swap the value in-place (in-situ)
    void swab16s(u16 *p)
    void swab32s(u32 *p)
    void swab64s(u64 *p)
    void swahw32s(u32 *p)
    void swahb32s(u32 *p)

    Arches can override any of these with an optimized version by defining an
    inline in their asm/byteorder.h (example given for swab16()):

    u16 __arch_swab16() {}
    #define __arch_swab16 __arch_swab16

    Signed-off-by: Harvey Harrison
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Harvey Harrison