| @@ -1,25 +1,58 @@ | | | @@ -1,25 +1,58 @@ |
1 | $NetBSD: patch-cipher_bithelp.h,v 1.3 2014/01/08 09:39:45 obache Exp $ | | 1 | $NetBSD: patch-cipher_bithelp.h,v 1.4 2014/01/13 11:44:27 obache Exp $ |
2 | | | 2 | |
3 | * NetBSD has bswap32 and bswap64 as macros. | | 3 | * NetBSD has bswap32 and bswap64 as macros. |
4 | https://bugs.g10code.com/gnupg/issue1600 | | 4 | https://bugs.g10code.com/gnupg/issue1600 |
5 | | | 5 | |
6 | --- cipher/bithelp.h.orig 2013-12-09 07:48:50.000000000 +0000 | | 6 | --- cipher/bithelp.h.orig 2013-12-09 07:48:50.000000000 +0000 |
7 | +++ cipher/bithelp.h | | 7 | +++ cipher/bithelp.h |
8 | @@ -40,7 +40,7 @@ static inline u32 ror(u32 x, int n) | | 8 | @@ -39,9 +39,10 @@ static inline u32 ror(u32 x, int n) |
| | | 9 | /* Byte swap for 32-bit and 64-bit integers. If available, use compiler |
9 | provided helpers. */ | | 10 | provided helpers. */ |
10 | #ifdef HAVE_BUILTIN_BSWAP32 | | 11 | #ifdef HAVE_BUILTIN_BSWAP32 |
11 | # define bswap32 __builtin_bswap32 | | 12 | -# define bswap32 __builtin_bswap32 |
12 | -#else | | 13 | +# define _gcry_bswap32 __builtin_bswap32 |
13 | +#elif !defined(__NetBSD__) && !defined(bswap32) | | 14 | #else |
14 | static inline u32 bswap32(u32 x) | | 15 | -static inline u32 bswap32(u32 x) |
| | | 16 | +static inline u32 |
| | | 17 | +_gcry_bswap32(u32 x) |
15 | { | | 18 | { |
16 | return ((rol(x, 8) & 0x00ff00ffL) | (ror(x, 8) & 0xff00ff00L)); | | 19 | return ((rol(x, 8) & 0x00ff00ffL) | (ror(x, 8) & 0xff00ff00L)); |
17 | @@ -50,7 +50,7 @@ static inline u32 bswap32(u32 x) | | 20 | } |
| | | 21 | @@ -49,29 +50,30 @@ static inline u32 bswap32(u32 x) |
| | | 22 | |
18 | #ifdef HAVE_U64_TYPEDEF | | 23 | #ifdef HAVE_U64_TYPEDEF |
19 | # ifdef HAVE_BUILTIN_BSWAP64 | | 24 | # ifdef HAVE_BUILTIN_BSWAP64 |
20 | # define bswap64 __builtin_bswap64 | | 25 | -# define bswap64 __builtin_bswap64 |
21 | -# else | | 26 | +# define _gcry_bswap64 __builtin_bswap64 |
22 | +# elif !defined(__NetBSD__) && !defined(bswap64) | | 27 | # else |
23 | static inline u64 bswap64(u64 x) | | 28 | -static inline u64 bswap64(u64 x) |
| | | 29 | +static inline u64 |
| | | 30 | +_gcry_bswap64(u64 x) |
24 | { | | 31 | { |
25 | return ((u64)bswap32(x) << 32) | (bswap32(x >> 32)); | | 32 | - return ((u64)bswap32(x) << 32) | (bswap32(x >> 32)); |
| | | 33 | + return ((u64)_gcry_bswap32(x) << 32) | (_gcry_bswap32(x >> 32)); |
| | | 34 | } |
| | | 35 | # endif |
| | | 36 | #endif |
| | | 37 | |
| | | 38 | /* Endian dependent byte swap operations. */ |
| | | 39 | #ifdef WORDS_BIGENDIAN |
| | | 40 | -# define le_bswap32(x) bswap32(x) |
| | | 41 | +# define le_bswap32(x) _gcry_bswap32(x) |
| | | 42 | # define be_bswap32(x) ((u32)(x)) |
| | | 43 | # ifdef HAVE_U64_TYPEDEF |
| | | 44 | -# define le_bswap64(x) bswap64(x) |
| | | 45 | +# define le_bswap64(x) _gcry_bswap64(x) |
| | | 46 | # define be_bswap64(x) ((u64)(x)) |
| | | 47 | # endif |
| | | 48 | #else |
| | | 49 | # define le_bswap32(x) ((u32)(x)) |
| | | 50 | -# define be_bswap32(x) bswap32(x) |
| | | 51 | +# define be_bswap32(x) _gcry_bswap32(x) |
| | | 52 | # ifdef HAVE_U64_TYPEDEF |
| | | 53 | # define le_bswap64(x) ((u64)(x)) |
| | | 54 | -# define be_bswap64(x) bswap64(x) |
| | | 55 | +# define be_bswap64(x) _gcry_bswap64(x) |
| | | 56 | # endif |
| | | 57 | #endif |
| | | 58 | |