1. 07 1月, 2009 2 次提交
    • L
      Fix up 64-bit byte swaps for most 32-bit architectures · ede6f5ae
      Linus Torvalds 提交于
      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: NNicolas Pitre <nico@cam.org>
      Reported-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Harvey Harrison <harvey.harrison@gmail.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ede6f5ae
    • H
      byteorder: only use linux/swab.h · 991c0e6d
      Harvey Harrison 提交于
      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: NHarvey Harrison <harvey.harrison@gmail.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      991c0e6d
  2. 20 10月, 2008 1 次提交
  3. 13 8月, 2008 1 次提交
    • H
      byteorder: add a new include/linux/swab.h to define byteswapping functions · 40c9f222
      Harvey Harrison 提交于
      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: NHarvey Harrison <harvey.harrison@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      40c9f222