openbsd-ports/security/hs-cryptohash/patches/patch-cbits_bitfn_h
jasper d061c5f51c import hs-cryptohash 0.6.1
Collection of crypto hashes, with a practical incremental and one-pass,
pure APIs, with performance close to the fastest implementations
available in others languages.

feedback and ok kili@
2010-12-08 23:29:04 +00:00

63 lines
1.6 KiB
Plaintext

$OpenBSD: patch-cbits_bitfn_h,v 1.1.1.1 2010/12/08 23:29:04 jasper Exp $
- Don't redefine swap32/swap64.
--- cbits/bitfn.h.orig Mon Nov 1 23:27:34 2010
+++ cbits/bitfn.h Wed Dec 8 18:20:40 2010
@@ -30,14 +30,17 @@
/**********************************************************/
# if (defined(__i386__))
# define ARCH_HAS_SWAP32
+# ifndef swap32
static inline uint32_t swap32(uint32_t a)
{
asm ("bswap %0" : "=r" (a) : "0" (a));
return a;
}
+# endif
/**********************************************************/
# elif (defined(__arm__))
# define ARCH_HAS_SWAP32
+# ifndef swap32
static inline uint32_t swap32(uint32_t a)
{
uint32_t tmp = a;
@@ -48,22 +51,25 @@ static inline uint32_t swap32(uint32_t a)
: "=r" (a), "=r" (tmp) : "0" (a), "1" (tmp));
return a;
}
+# endif
/**********************************************************/
# elif defined(__x86_64__)
# define ARCH_HAS_SWAP32
# define ARCH_HAS_SWAP64
+# ifndef swap32
static inline uint32_t swap32(uint32_t a)
{
asm ("bswap %0" : "=r" (a) : "0" (a));
return a;
}
-
+# endif
+# ifndef swap64
static inline uint64_t swap64(uint64_t a)
{
asm ("bswap %0" : "=r" (a) : "0" (a));
return a;
}
-
+# endif
# endif
#endif /* NO_INLINE_ASM */
/**********************************************************/
@@ -161,7 +167,8 @@ static inline void array_copy64(uint64_t *d, uint64_t
#ifdef __MINGW32__
# define LITTLE_ENDIAN 1234
# define BYTE_ORDER LITTLE_ENDIAN
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__OpenBSD__)
+ # include <sys/types.h>
# include <sys/endian.h>
#elif defined(__APPLE__)
# include <machine/endian.h>