Brad Bishop | 8410d61 | 2019-11-25 09:40:59 -0500 | [diff] [blame^] | 1 | From 8f961521add49278b48c9721fc53e05ee3543b74 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 23eaf03 | 2019-11-20 05:15:02 -0500 | [diff] [blame] | 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 | |
Brad Bishop | 8410d61 | 2019-11-25 09:40:59 -0500 | [diff] [blame^] | 9 | Upstream-Status: Submitted [https://github.com/smuellerDD/libkcapi/pull/83] |
Brad Bishop | 23eaf03 | 2019-11-20 05:15:02 -0500 | [diff] [blame] | 10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 11 | --- |
Brad Bishop | 8410d61 | 2019-11-25 09:40:59 -0500 | [diff] [blame^] | 12 | lib/kcapi-kdf.c | 37 +++++++++++++++++-------------------- |
| 13 | 1 file changed, 17 insertions(+), 20 deletions(-) |
Brad Bishop | 23eaf03 | 2019-11-20 05:15:02 -0500 | [diff] [blame] | 14 | |
| 15 | diff --git a/lib/kcapi-kdf.c b/lib/kcapi-kdf.c |
Brad Bishop | 8410d61 | 2019-11-25 09:40:59 -0500 | [diff] [blame^] | 16 | index ea39846..9e53a0b 100644 |
Brad Bishop | 23eaf03 | 2019-11-20 05:15:02 -0500 | [diff] [blame] | 17 | --- a/lib/kcapi-kdf.c |
| 18 | +++ b/lib/kcapi-kdf.c |
| 19 | @@ -54,6 +54,20 @@ |
| 20 | #include "kcapi.h" |
| 21 | #include "internal.h" |
| 22 | |
| 23 | +#define GCC_VERSION (__GNUC__ * 10000 \ |
| 24 | + + __GNUC_MINOR__ * 100 \ |
| 25 | + + __GNUC_PATCHLEVEL__) |
| 26 | +#if GCC_VERSION >= 40400 |
| 27 | +# define __HAVE_BUILTIN_BSWAP32__ |
| 28 | +#endif |
| 29 | + |
Brad Bishop | 23eaf03 | 2019-11-20 05:15:02 -0500 | [diff] [blame] | 30 | +/* Endian dependent byte swap operations. */ |
Brad Bishop | 8410d61 | 2019-11-25 09:40:59 -0500 | [diff] [blame^] | 31 | +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
Brad Bishop | 23eaf03 | 2019-11-20 05:15:02 -0500 | [diff] [blame] | 32 | +# define be_bswap32(x) ((uint32_t)(x)) |
| 33 | +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
Brad Bishop | 8410d61 | 2019-11-25 09:40:59 -0500 | [diff] [blame^] | 34 | +# ifdef __HAVE_BUILTIN_BSWAP32__ |
| 35 | +# define be_bswap32(x) (uint32_t)__builtin_bswap32((uint32_t)(x)) |
| 36 | +# else |
Brad Bishop | 23eaf03 | 2019-11-20 05:15:02 -0500 | [diff] [blame] | 37 | static inline uint32_t rol32(uint32_t x, int n) |
| 38 | { |
| 39 | return ( (x << (n&(32-1))) | (x >> ((32-n)&(32-1))) ); |
Brad Bishop | 8410d61 | 2019-11-25 09:40:59 -0500 | [diff] [blame^] | 40 | @@ -68,27 +82,10 @@ static inline uint32_t _bswap32(uint32_t x) |
Brad Bishop | 23eaf03 | 2019-11-20 05:15:02 -0500 | [diff] [blame] | 41 | { |
| 42 | return ((rol32(x, 8) & 0x00ff00ffL) | (ror32(x, 8) & 0xff00ff00L)); |
| 43 | } |
| 44 | - |
| 45 | -#define GCC_VERSION (__GNUC__ * 10000 \ |
| 46 | - + __GNUC_MINOR__ * 100 \ |
| 47 | - + __GNUC_PATCHLEVEL__) |
| 48 | -#if GCC_VERSION >= 40400 |
| 49 | -# define __HAVE_BUILTIN_BSWAP32__ |
| 50 | -#endif |
| 51 | - |
| 52 | -#ifdef __HAVE_BUILTIN_BSWAP32__ |
| 53 | -# define _swap32(x) (uint32_t)__builtin_bswap32((uint32_t)(x)) |
| 54 | -#else |
| 55 | -# define _swap32(x) _bswap32(x) |
| 56 | -#endif |
| 57 | - |
| 58 | -/* Endian dependent byte swap operations. */ |
| 59 | -#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
| 60 | -# define be_bswap32(x) ((uint32_t)(x)) |
| 61 | -#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
| 62 | -# define be_bswap32(x) _swap32(x) |
Brad Bishop | 8410d61 | 2019-11-25 09:40:59 -0500 | [diff] [blame^] | 63 | +# define be_bswap32(x) _bswap32(x) |
| 64 | +# endif |
Brad Bishop | 23eaf03 | 2019-11-20 05:15:02 -0500 | [diff] [blame] | 65 | #else |
| 66 | -#error "Endianess not defined" |
Brad Bishop | 8410d61 | 2019-11-25 09:40:59 -0500 | [diff] [blame^] | 67 | +# error "endianess not defined" |
Brad Bishop | 23eaf03 | 2019-11-20 05:15:02 -0500 | [diff] [blame] | 68 | #endif |
| 69 | |
| 70 | DSO_PUBLIC |
| 71 | -- |
| 72 | 2.24.0 |
| 73 | |