@@ -29,7 +29,7 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
-#include <tools/le_byteshift.h>
+#include <tools/unaligned.h>
int main(int argc, char *argv[])
{
@@ -33,7 +33,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
-#include <tools/le_byteshift.h>
+#include <tools/unaligned.h>
typedef unsigned char u8;
typedef unsigned short u16;
@@ -14,7 +14,7 @@
#define USE_BSD
#include <endian.h>
#include <regex.h>
-#include <tools/le_byteshift.h>
+#include <tools/unaligned.h>
void die(char *fmt, ...);
@@ -28,8 +28,7 @@
#include <string.h>
#include <unistd.h>
-#include <tools/be_byteshift.h>
-#include <tools/le_byteshift.h>
+#include <tools/unaligned.h>
#ifndef EM_ARCOMPACT
#define EM_ARCOMPACT 93
deleted file mode 100644
@@ -1,52 +0,0 @@
-#ifndef _TOOLS_BE_BYTESHIFT_H
-#define _TOOLS_BE_BYTESHIFT_H
-
-#include <stdint.h>
-
-static inline uint16_t get_unaligned_be16(const void *_p)
-{
- const uint8_t *p = _p;
-
- return p[0] << 8 | p[1];
-}
-
-static inline uint32_t get_unaligned_be32(const void *_p)
-{
- const uint8_t *p = _p;
-
- return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
-}
-
-static inline uint64_t get_unaligned_be64(const void *_p)
-{
- const uint8_t *p = _p;
-
- return (uint64_t)get_unaligned_be32(p) << 32 |
- get_unaligned_be32(p + 4);
-}
-
-static inline void put_unaligned_be16(uint16_t val, void *_p)
-{
- uint8_t *p = _p;
-
- *p++ = val >> 8;
- *p++ = val;
-}
-
-static inline void put_unaligned_be32(uint32_t val, void *_p)
-{
- uint8_t *p = _p;
-
- put_unaligned_be16(val >> 16, p);
- put_unaligned_be16(val, p + 2);
-}
-
-static inline void put_unaligned_be64(uint64_t val, void *_p)
-{
- uint8_t *p = _p;
-
- put_unaligned_be32(val >> 32, p);
- put_unaligned_be32(val, p + 4);
-}
-
-#endif /* _TOOLS_BE_BYTESHIFT_H */
deleted file mode 100644
@@ -1,52 +0,0 @@
-#ifndef _TOOLS_LE_BYTESHIFT_H
-#define _TOOLS_LE_BYTESHIFT_H
-
-#include <stdint.h>
-
-static inline uint16_t get_unaligned_le16(const void *_p)
-{
- const uint8_t *p = _p;
-
- return p[0] | p[1] << 8;
-}
-
-static inline uint32_t get_unaligned_le32(const void *_p)
-{
- const uint8_t *p = _p;
-
- return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
-}
-
-static inline uint64_t get_unaligned_le64(const void *_p)
-{
- const uint8_t *p = _p;
-
- return (uint64_t)get_unaligned_le32(p + 4) << 32 |
- get_unaligned_le32(p);
-}
-
-static inline void put_unaligned_le16(uint16_t val, void *_p)
-{
- uint8_t *p = _p;
-
- *p++ = val;
- *p++ = val >> 8;
-}
-
-static inline void put_unaligned_le32(uint32_t val, void *_p)
-{
- uint8_t *p = _p;
-
- put_unaligned_le16(val, p);
- put_unaligned_le16(val >> 16, p + 2);
-}
-
-static inline void put_unaligned_le64(uint64_t val, void *_p)
-{
- uint8_t *p = _p;
-
- put_unaligned_le32(val, p);
- put_unaligned_le32(val >> 32, p + 4);
-}
-
-#endif /* _TOOLS_LE_BYTESHIFT_H */
new file mode 100644
@@ -0,0 +1,2 @@
+#include <tools/unaligned/le_byteshift.h>
+#include <tools/unaligned/be_byteshift.h>
new file mode 100644
@@ -0,0 +1,52 @@
+#ifndef _TOOLS_BE_BYTESHIFT_H
+#define _TOOLS_BE_BYTESHIFT_H
+
+#include <stdint.h>
+
+static inline uint16_t get_unaligned_be16(const void *_p)
+{
+ const uint8_t *p = _p;
+
+ return p[0] << 8 | p[1];
+}
+
+static inline uint32_t get_unaligned_be32(const void *_p)
+{
+ const uint8_t *p = _p;
+
+ return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
+}
+
+static inline uint64_t get_unaligned_be64(const void *_p)
+{
+ const uint8_t *p = _p;
+
+ return (uint64_t)get_unaligned_be32(p) << 32 |
+ get_unaligned_be32(p + 4);
+}
+
+static inline void put_unaligned_be16(uint16_t val, void *_p)
+{
+ uint8_t *p = _p;
+
+ *p++ = val >> 8;
+ *p++ = val;
+}
+
+static inline void put_unaligned_be32(uint32_t val, void *_p)
+{
+ uint8_t *p = _p;
+
+ put_unaligned_be16(val >> 16, p);
+ put_unaligned_be16(val, p + 2);
+}
+
+static inline void put_unaligned_be64(uint64_t val, void *_p)
+{
+ uint8_t *p = _p;
+
+ put_unaligned_be32(val >> 32, p);
+ put_unaligned_be32(val, p + 4);
+}
+
+#endif /* _TOOLS_BE_BYTESHIFT_H */
new file mode 100644
@@ -0,0 +1,52 @@
+#ifndef _TOOLS_LE_BYTESHIFT_H
+#define _TOOLS_LE_BYTESHIFT_H
+
+#include <stdint.h>
+
+static inline uint16_t get_unaligned_le16(const void *_p)
+{
+ const uint8_t *p = _p;
+
+ return p[0] | p[1] << 8;
+}
+
+static inline uint32_t get_unaligned_le32(const void *_p)
+{
+ const uint8_t *p = _p;
+
+ return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
+}
+
+static inline uint64_t get_unaligned_le64(const void *_p)
+{
+ const uint8_t *p = _p;
+
+ return (uint64_t)get_unaligned_le32(p + 4) << 32 |
+ get_unaligned_le32(p);
+}
+
+static inline void put_unaligned_le16(uint16_t val, void *_p)
+{
+ uint8_t *p = _p;
+
+ *p++ = val;
+ *p++ = val >> 8;
+}
+
+static inline void put_unaligned_le32(uint32_t val, void *_p)
+{
+ uint8_t *p = _p;
+
+ put_unaligned_le16(val, p);
+ put_unaligned_le16(val >> 16, p + 2);
+}
+
+static inline void put_unaligned_le64(uint64_t val, void *_p)
+{
+ uint8_t *p = _p;
+
+ put_unaligned_le32(val, p);
+ put_unaligned_le32(val >> 32, p + 4);
+}
+
+#endif /* _TOOLS_LE_BYTESHIFT_H */
@@ -36,7 +36,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <tools/le_byteshift.h>
+#include <tools/unaligned.h>
#include "../../include/uapi/linux/usb/functionfs.h"
Create <tools/unaligned.h> and create an unaligned subdirectory for specific implementations -- currently including the existing be_byteshift.h and le_byteshift.h. Signed-off-by: H. Peter Anvin <hpa@zytor.com> --- arch/x86/boot/compressed/mkpiggy.c | 2 +- arch/x86/boot/tools/build.c | 2 +- arch/x86/tools/relocs.h | 2 +- scripts/sortextable.c | 3 +- tools/include/tools/be_byteshift.h | 52 ---------------------------- tools/include/tools/le_byteshift.h | 52 ---------------------------- tools/include/tools/unaligned.h | 2 ++ tools/include/tools/unaligned/be_byteshift.h | 52 ++++++++++++++++++++++++++++ tools/include/tools/unaligned/le_byteshift.h | 52 ++++++++++++++++++++++++++++ tools/usb/ffs-test.c | 2 +- 10 files changed, 111 insertions(+), 110 deletions(-) delete mode 100644 tools/include/tools/be_byteshift.h delete mode 100644 tools/include/tools/le_byteshift.h create mode 100644 tools/include/tools/unaligned.h create mode 100644 tools/include/tools/unaligned/be_byteshift.h create mode 100644 tools/include/tools/unaligned/le_byteshift.h