new file mode 100644
@@ -0,0 +1,15 @@
+#ifndef TOOLS_BE_SWAP_H
+#define TOOLS_BE_SWAP_H
+
+#ifdef htole64
+/* Prefer the <endian.h> infrastructure if it exists */
+# include <tools/unaligned/be_endian.h>
+#elif TOOLS_UNALIGNED_GCC >= 0x040800
+/* This version of gcc is new enough to have __builtin_bswap*() */
+# include <tools/unaligned/be_bswap.h>
+#else
+/* This always works */
+# include <tools/unaligned/be_byteshift.h>
+#endif
+
+#endif /* TOOLS_BE_SWAP_H */
new file mode 100644
@@ -0,0 +1,15 @@
+#ifndef TOOLS_LE_SWAP_H
+#define TOOLS_LE_SWAP_H
+
+#ifdef htobe64
+/* Prefer the <endian.h> infrastructure if it exists */
+# include <tools/unaligned/le_endian.h>
+#elif TOOLS_UNALIGNED_GCC >= 0x040800
+/* This version of gcc is new enough to have __builtin_bswap*() */
+# include <tools/unaligned/le_bswap.h>
+#else
+/* This always works */
+# include <tools/unaligned/le_byteshift.h>
+#endif
+
+#endif /* TOOLS_LE_SWAP_H */
Common selection infrastructure for picking the best byte swap method. Signed-off-by: H. Peter Anvin <hpa@zytor.com> --- tools/include/tools/unaligned/be_swap.h | 15 +++++++++++++++ tools/include/tools/unaligned/le_swap.h | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tools/include/tools/unaligned/be_swap.h create mode 100644 tools/include/tools/unaligned/le_swap.h