Brad Bishop | 23eaf03 | 2019-11-20 05:15:02 -0500 | [diff] [blame^] | 1 | From 00c1654e368f728b213c4e3782045d54098edb25 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Sat, 16 Nov 2019 23:03:51 -0800 |
| 4 | Subject: [PATCH] kcapi-kdf: Move code to fix |
| 5 | |
| 6 | Fixes clang build |
| 7 | unused function '_bswap32' [-Werror,-Wunused-function] |
| 8 | |
| 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 10 | --- |
| 11 | lib/kcapi-kdf.c | 36 ++++++++++++++++-------------------- |
| 12 | 1 file changed, 16 insertions(+), 20 deletions(-) |
| 13 | |
| 14 | diff --git a/lib/kcapi-kdf.c b/lib/kcapi-kdf.c |
| 15 | index ea39846..8e4a636 100644 |
| 16 | --- a/lib/kcapi-kdf.c |
| 17 | +++ b/lib/kcapi-kdf.c |
| 18 | @@ -54,6 +54,20 @@ |
| 19 | #include "kcapi.h" |
| 20 | #include "internal.h" |
| 21 | |
| 22 | +#define GCC_VERSION (__GNUC__ * 10000 \ |
| 23 | + + __GNUC_MINOR__ * 100 \ |
| 24 | + + __GNUC_PATCHLEVEL__) |
| 25 | +#if GCC_VERSION >= 40400 |
| 26 | +# define __HAVE_BUILTIN_BSWAP32__ |
| 27 | +#endif |
| 28 | + |
| 29 | +#ifdef __HAVE_BUILTIN_BSWAP32__ |
| 30 | +# define be_bswap32(x) (uint32_t)__builtin_bswap32((uint32_t)(x)) |
| 31 | +/* Endian dependent byte swap operations. */ |
| 32 | +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
| 33 | +# define be_bswap32(x) ((uint32_t)(x)) |
| 34 | +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
| 35 | + |
| 36 | static inline uint32_t rol32(uint32_t x, int n) |
| 37 | { |
| 38 | return ( (x << (n&(32-1))) | (x >> ((32-n)&(32-1))) ); |
| 39 | @@ -68,27 +82,9 @@ static inline uint32_t _bswap32(uint32_t x) |
| 40 | { |
| 41 | return ((rol32(x, 8) & 0x00ff00ffL) | (ror32(x, 8) & 0xff00ff00L)); |
| 42 | } |
| 43 | - |
| 44 | -#define GCC_VERSION (__GNUC__ * 10000 \ |
| 45 | - + __GNUC_MINOR__ * 100 \ |
| 46 | - + __GNUC_PATCHLEVEL__) |
| 47 | -#if GCC_VERSION >= 40400 |
| 48 | -# define __HAVE_BUILTIN_BSWAP32__ |
| 49 | -#endif |
| 50 | - |
| 51 | -#ifdef __HAVE_BUILTIN_BSWAP32__ |
| 52 | -# define _swap32(x) (uint32_t)__builtin_bswap32((uint32_t)(x)) |
| 53 | -#else |
| 54 | -# define _swap32(x) _bswap32(x) |
| 55 | -#endif |
| 56 | - |
| 57 | -/* Endian dependent byte swap operations. */ |
| 58 | -#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
| 59 | -# define be_bswap32(x) ((uint32_t)(x)) |
| 60 | -#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
| 61 | -# define be_bswap32(x) _swap32(x) |
| 62 | +# define be_bswap32(x) _bswap32(x) |
| 63 | #else |
| 64 | -#error "Endianess not defined" |
| 65 | +# error "Neither builtin_bswap32 nor endianess defined" |
| 66 | #endif |
| 67 | |
| 68 | DSO_PUBLIC |
| 69 | -- |
| 70 | 2.24.0 |
| 71 | |