diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-15 20:22:25 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-15 20:22:25 +0200 |
| commit | 2c1258c620c5847649367394439cc10d0331d211 (patch) | |
| tree | a0464536ff4534783af8cc68249e80b358101d31 | |
| parent | 08dfafc43757c42971b4bc3709ae7a5cda7c21fb (diff) | |
| download | busybox-w32-2c1258c620c5847649367394439cc10d0331d211.tar.gz busybox-w32-2c1258c620c5847649367394439cc10d0331d211.tar.bz2 busybox-w32-2c1258c620c5847649367394439cc10d0331d211.zip | |
Move get_unaligned_le32() macros to platform.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | archival/libarchive/decompress_unxz.c | 16 | ||||
| -rw-r--r-- | include/platform.h | 6 | ||||
| -rw-r--r-- | networking/tls_aes.c | 4 |
3 files changed, 17 insertions, 9 deletions
diff --git a/archival/libarchive/decompress_unxz.c b/archival/libarchive/decompress_unxz.c index cd32cc745..350e5358a 100644 --- a/archival/libarchive/decompress_unxz.c +++ b/archival/libarchive/decompress_unxz.c | |||
| @@ -27,11 +27,17 @@ static uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc) | |||
| 27 | return ~crc32_block_endian0(~crc, buf, size, global_crc32_table); | 27 | return ~crc32_block_endian0(~crc, buf, size, global_crc32_table); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | /* We use arch-optimized unaligned accessors */ | 30 | /* We use arch-optimized unaligned fixed-endian accessors. |
| 31 | #define get_unaligned_le32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_LE32(v); }) | 31 | * They have been moved to libbb (proved to be useful elsewhere as well), |
| 32 | #define get_unaligned_be32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_BE32(v); }) | 32 | * just check that we have them defined: |
| 33 | #define put_unaligned_le32(val, buf) move_to_unaligned32(buf, SWAP_LE32(val)) | 33 | */ |
| 34 | #define put_unaligned_be32(val, buf) move_to_unaligned32(buf, SWAP_BE32(val)) | 34 | #if !defined(get_unaligned_le32) \ |
| 35 | || !defined(get_unaligned_be32) \ | ||
| 36 | || !defined(put_unaligned_le32) \ | ||
| 37 | || !defined(put_unaligned_be32) | ||
| 38 | # error get_unaligned_le32 accessors are not defined | ||
| 39 | #endif | ||
| 40 | #define get_le32(p) (*(uint32_t*)(p)) | ||
| 35 | 41 | ||
| 36 | #include "unxz/xz_dec_bcj.c" | 42 | #include "unxz/xz_dec_bcj.c" |
| 37 | #include "unxz/xz_dec_lzma2.c" | 43 | #include "unxz/xz_dec_lzma2.c" |
diff --git a/include/platform.h b/include/platform.h index 6c7d03dc7..8210e5c49 100644 --- a/include/platform.h +++ b/include/platform.h | |||
| @@ -247,6 +247,12 @@ typedef uint64_t bb__aliased_uint64_t FIX_ALIASING; | |||
| 247 | } while (0) | 247 | } while (0) |
| 248 | #endif | 248 | #endif |
| 249 | 249 | ||
| 250 | /* Unaligned, fixed-endian accessors */ | ||
| 251 | #define get_unaligned_le32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_LE32(v); }) | ||
| 252 | #define get_unaligned_be32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_BE32(v); }) | ||
| 253 | #define put_unaligned_le32(val, buf) move_to_unaligned32(buf, SWAP_LE32(val)) | ||
| 254 | #define put_unaligned_be32(val, buf) move_to_unaligned32(buf, SWAP_BE32(val)) | ||
| 255 | |||
| 250 | 256 | ||
| 251 | /* ---- Size-saving "small" ints (arch-dependent) ----------- */ | 257 | /* ---- Size-saving "small" ints (arch-dependent) ----------- */ |
| 252 | 258 | ||
diff --git a/networking/tls_aes.c b/networking/tls_aes.c index 6992f1c90..c137442e9 100644 --- a/networking/tls_aes.c +++ b/networking/tls_aes.c | |||
| @@ -40,10 +40,6 @@ | |||
| 40 | */ | 40 | */ |
| 41 | #include "tls.h" | 41 | #include "tls.h" |
| 42 | 42 | ||
| 43 | /* TODO: grep for this and move to libbb */ | ||
| 44 | #define get_unaligned_be32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_BE32(v); }) | ||
| 45 | |||
| 46 | |||
| 47 | // The lookup-tables are marked const so they can be placed in read-only storage instead of RAM | 43 | // The lookup-tables are marked const so they can be placed in read-only storage instead of RAM |
| 48 | // The numbers below can be computed dynamically trading ROM for RAM - | 44 | // The numbers below can be computed dynamically trading ROM for RAM - |
| 49 | // This can be useful in (embedded) bootloader applications, where ROM is often limited. | 45 | // This can be useful in (embedded) bootloader applications, where ROM is often limited. |
