Skip to contentSkip to conversation

byteorder: only use linux/swab.h

PATCH In review Harvey Harrison 2 participants 3 messages Jan 6, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/23 byteorder: only use linux/swab.h

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.

This, and the trivial arch patches fix the problem introduced with the consolidated linux/byteorder.h when included in userspace that was defining both __LITTLE_ENDIAN and __BIG_ENDIAN.

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.

---
Linus, this series is vs. linux-next and is meant to be applied after the following arches get pulled (all others I was waiting on have already gone in):
parisc, cris (conversion to new arch style)
xtensa (headers being moved to arch/xtensa/ and conversion to new arch style) sparc (additional changes to avoid leaking some symbols to userspace)

Patches 2-12 hit the arches that have already converted and are pure code movements into an asm/swab.h

Patches 13-21 do the code movement _and_ conversion of arch-overrides.

Patches 22-23 clean up the swab.h additions to each arch's KBuild by adding it to KBuild.asm and making asm/swab.h get included from linux/swab.h and removes the conditional linux/byteorder.h that you objected to and caused the userspace problems.

I will CC the arch maintainers on each patch, but they are all small enough (at least with git diff -M -C that I hope you'll take them directly)

 include/linux/byteorder/Kbuild          |    2 -
 include/linux/byteorder/big_endian.h    |    3 +-
 include/linux/byteorder/little_endian.h |    3 +-
 include/linux/byteorder/swab.h          |  222 -------------------------------
 include/linux/byteorder/swabb.h         |  135 -------------------
 include/linux/swab.h                    |   50 ++++----
 6 files changed, 27 insertions(+), 388 deletions(-)
include/linux/byteorder/Kbuild +0 -2
index fbaa7f9..3843722 100644
@@ -1,4 +1,2 @@
 unifdef-y += big_endian.h
 unifdef-y += little_endian.h
-unifdef-y += swab.h
-unifdef-y += swabb.h
include/linux/byteorder/big_endian.h +1 -2
index 1cba3f3..3c80fd7 100644
@@ -9,8 +9,7 @@
 #endif
 
 #include <linux/types.h>
-#include <linux/byteorder/swab.h>
-#include <linux/byteorder/swabb.h>
+#include <linux/swab.h>
 
 #define __constant_htonl(x) ((__force __be32)(__u32)(x))
 #define __constant_ntohl(x) ((__force __u32)(__be32)(x))
include/linux/byteorder/little_endian.h +1 -2
index cedc1b5..83195fb 100644
@@ -9,8 +9,7 @@
 #endif
 
 #include <linux/types.h>
-#include <linux/byteorder/swab.h>
-#include <linux/byteorder/swabb.h>
+#include <linux/swab.h>
 
 #define __constant_htonl(x) ((__force __be32)___constant_swab32((x)))
 #define __constant_ntohl(x) ___constant_swab32((__force __be32)(x))
include/linux/byteorder/swab.h deleted +0 -222

222 lines not on this page · raw message

include/linux/byteorder/swabb.h deleted +0 -135

135 lines not on this page · raw message

include/linux/swab.h +25 -25

143 lines not on this page · raw message

Signature · 1 line
1.6.1.94.g9388
#1 lore raw
Quoted 3 lines · Harvey Harrison

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

Btw, was there some reason why you didn't just do the <asm/swab.h> files first? That would seem to simplify the whole sequence, and in fact it would also allow me to just apply all the "create asm/swab.h" patches first regardless of any other work..

Linus

#2 lore raw
Quoted 6 lines · Linus Torvalds
Quoted 3 lines · Harvey Harrison

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

Quoted 6 lines

Btw, was there some reason why you didn't just do the <asm/swab.h> files first? That would seem to simplify the whole sequence, and in fact it would also allow me to just apply all the "create asm/swab.h" patches first regardless of any other work..

Linus

My goal was the elimination of the linux/byteorder.h you objected to while not breaking the arch overrides of the arches that had already converted.

So it's not just moving to swab.h, it also eliminates the linux/byteorder.h includes, for this to work, I need to fix swab.h first.

Harvey