diff options
author | Denis Kenzior <denkenz@gmail.com> | 2023-10-08 12:50:13 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2023-10-11 09:55:25 -0500 |
commit | ef0ee3e87f263fc40379100ceba330ecb4be3dad (patch) | |
tree | 5e1f553de7541a76e29e724d2b4fa374728c0442 | |
parent | 0e8f533ed045af0008c36ee3fa1cf6376497234c (diff) |
useful: Move SWAP macro to useful.h
And also make it work for multiple types
-rw-r--r-- | ell/cipher.c | 2 | ||||
-rw-r--r-- | ell/useful.h | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/ell/cipher.c b/ell/cipher.c index 57e4b195..a1c0e255 100644 --- a/ell/cipher.c +++ b/ell/cipher.c @@ -731,8 +731,6 @@ LIB_EXPORT bool l_aead_cipher_is_supported(enum l_aead_cipher_type type) /* ARC4 implementation copyright (c) 2001 Niels Möller */ -#define SWAP(a, b) do { uint8_t _t = a; a = b; b = _t; } while (0) - static void arc4_set_key(uint8_t *S, const uint8_t *key, size_t key_length) { unsigned int i; diff --git a/ell/useful.h b/ell/useful.h index dbe7df95..991edc3b 100644 --- a/ell/useful.h +++ b/ell/useful.h @@ -15,6 +15,9 @@ #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) +#define SWAP(l, r) \ + do { typeof(l) __tmp = (l); (l) = (r); (r) = __tmp; } while (0) + static inline size_t minsize(size_t a, size_t b) { if (a <= b) |