diff options
| author | Adrian Hunter <adrian.hunter@intel.com> | 2017-05-26 04:17:23 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-06-27 11:08:13 -0400 |
| commit | 07fda552f14830e71f0b5e8e4e31124369903aa3 (patch) | |
| tree | 8edda9dc9f4b36339e4e572b2c4802960883633b /tools/include/linux | |
| parent | 1405720d4f2669e5ebaed192bd727aca74f64732 (diff) | |
tools include: Add byte-swapping macros to kernel.h
Add byte-swapping macros to kernel.h
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/r/1495786658-18063-23-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/include/linux')
| -rw-r--r-- | tools/include/linux/kernel.h | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h index 73ccc48126bb..039bb85e4171 100644 --- a/tools/include/linux/kernel.h +++ b/tools/include/linux/kernel.h | |||
| @@ -5,6 +5,8 @@ | |||
| 5 | #include <stddef.h> | 5 | #include <stddef.h> |
| 6 | #include <assert.h> | 6 | #include <assert.h> |
| 7 | #include <linux/compiler.h> | 7 | #include <linux/compiler.h> |
| 8 | #include <endian.h> | ||
| 9 | #include <byteswap.h> | ||
| 8 | 10 | ||
| 9 | #ifndef UINT_MAX | 11 | #ifndef UINT_MAX |
| 10 | #define UINT_MAX (~0U) | 12 | #define UINT_MAX (~0U) |
| @@ -67,12 +69,33 @@ | |||
| 67 | #endif | 69 | #endif |
| 68 | #endif | 70 | #endif |
| 69 | 71 | ||
| 70 | /* | 72 | #if __BYTE_ORDER == __BIG_ENDIAN |
| 71 | * Both need more care to handle endianness | 73 | #define cpu_to_le16 bswap_16 |
| 72 | * (Don't use bitmap_copy_le() for now) | 74 | #define cpu_to_le32 bswap_32 |
| 73 | */ | 75 | #define cpu_to_le64 bswap_64 |
| 74 | #define cpu_to_le64(x) (x) | 76 | #define le16_to_cpu bswap_16 |
| 75 | #define cpu_to_le32(x) (x) | 77 | #define le32_to_cpu bswap_32 |
| 78 | #define le64_to_cpu bswap_64 | ||
| 79 | #define cpu_to_be16 | ||
| 80 | #define cpu_to_be32 | ||
| 81 | #define cpu_to_be64 | ||
| 82 | #define be16_to_cpu | ||
| 83 | #define be32_to_cpu | ||
| 84 | #define be64_to_cpu | ||
| 85 | #else | ||
| 86 | #define cpu_to_le16 | ||
| 87 | #define cpu_to_le32 | ||
| 88 | #define cpu_to_le64 | ||
| 89 | #define le16_to_cpu | ||
| 90 | #define le32_to_cpu | ||
| 91 | #define le64_to_cpu | ||
| 92 | #define cpu_to_be16 bswap_16 | ||
| 93 | #define cpu_to_be32 bswap_32 | ||
| 94 | #define cpu_to_be64 bswap_64 | ||
| 95 | #define be16_to_cpu bswap_16 | ||
| 96 | #define be32_to_cpu bswap_32 | ||
| 97 | #define be64_to_cpu bswap_64 | ||
| 98 | #endif | ||
| 76 | 99 | ||
| 77 | int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); | 100 | int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); |
| 78 | int scnprintf(char * buf, size_t size, const char * fmt, ...); | 101 | int scnprintf(char * buf, size_t size, const char * fmt, ...); |
