diff --git a/cbits/bitfn.h b/cbits/bitfn.h
--- a/cbits/bitfn.h
+++ b/cbits/bitfn.h
@@ -30,7 +30,7 @@
 /**********************************************************/
 # if (defined(__i386__))
 #  define ARCH_HAS_SWAP32
-static inline uint32_t swap32(uint32_t a)
+static inline uint32_t bitfn_swap32(uint32_t a)
 {
 	asm ("bswap %0" : "=r" (a) : "0" (a));
 	return a;
@@ -38,7 +38,7 @@
 /**********************************************************/
 # elif (defined(__arm__))
 #  define ARCH_HAS_SWAP32
-static inline uint32_t swap32(uint32_t a)
+static inline uint32_t bitfn_swap32(uint32_t a)
 {
 	uint32_t tmp = a;
 	asm volatile ("eor %1, %0, %0, ror #16\n"
@@ -52,13 +52,13 @@
 # elif defined(__x86_64__)
 #  define ARCH_HAS_SWAP32
 #  define ARCH_HAS_SWAP64
-static inline uint32_t swap32(uint32_t a)
+static inline uint32_t bitfn_swap32(uint32_t a)
 {
 	asm ("bswap %0" : "=r" (a) : "0" (a));
 	return a;
 }
 
-static inline uint64_t swap64(uint64_t a)
+static inline uint64_t bitfn_swap64(uint64_t a)
 {
 	asm ("bswap %0" : "=r" (a) : "0" (a));
 	return a;
@@ -97,7 +97,7 @@
 #endif
 
 #ifndef ARCH_HAS_SWAP32
-static inline uint32_t swap32(uint32_t a)
+static inline uint32_t bitfn_swap32(uint32_t a)
 {
 	return (a << 24) | ((a & 0xff00) << 8) | ((a >> 8) & 0xff00) | (a >> 24);
 }
@@ -107,15 +107,15 @@
 static inline void array_swap32(uint32_t *d, uint32_t *s, uint32_t nb)
 {
 	while (nb--)
-		*d++ = swap32(*s++);
+		*d++ = bitfn_swap32(*s++);
 }
 #endif
 
 #ifndef ARCH_HAS_SWAP64
-static inline uint64_t swap64(uint64_t a)
+static inline uint64_t bitfn_swap64(uint64_t a)
 {
-	return ((uint64_t) swap32((uint32_t) (a >> 32))) |
-	       (((uint64_t) swap32((uint32_t) a)) << 32);
+	return ((uint64_t) bitfn_swap32((uint32_t) (a >> 32))) |
+	       (((uint64_t) bitfn_swap32((uint32_t) a)) << 32);
 }
 #endif
 
@@ -123,7 +123,7 @@
 static inline void array_swap64(uint64_t *d, uint64_t *s, uint32_t nb)
 {
 	while (nb--)
-		*d++ = swap64(*s++);
+		*d++ = bitfn_swap64(*s++);
 }
 #endif
 
@@ -163,20 +163,24 @@
   # define BYTE_ORDER    LITTLE_ENDIAN
 #elif defined(__FreeBSD__)
   # include <sys/endian.h>
+#elif defined(__OpenBSD__)
+  # include <sys/types.h>
 #elif defined(__APPLE__)
   # include <machine/endian.h>
+#elif defined( BSD ) && ( BSD >= 199103 )
+  # include <machine/endian.h>
 #else
   # include <endian.h>
 #endif
 /* big endian to cpu */
 #if LITTLE_ENDIAN == BYTE_ORDER
 
-# define be32_to_cpu(a) swap32(a)
-# define cpu_to_be32(a) swap32(a)
+# define be32_to_cpu(a) bitfn_swap32(a)
+# define cpu_to_be32(a) bitfn_swap32(a)
 # define le32_to_cpu(a) (a)
 # define cpu_to_le32(a) (a)
-# define be64_to_cpu(a) swap64(a)
-# define cpu_to_be64(a) swap64(a)
+# define be64_to_cpu(a) bitfn_swap64(a)
+# define cpu_to_be64(a) bitfn_swap64(a)
 # define le64_to_cpu(a) (a)
 # define cpu_to_le64(a) (a)
 
@@ -201,10 +205,10 @@
 # define cpu_to_be32(a) (a)
 # define be64_to_cpu(a) (a)
 # define cpu_to_be64(a) (a)
-# define le64_to_cpu(a) swap64(a)
-# define cpu_to_le64(a) swap64(a)
-# define le32_to_cpu(a) swap32(a)
-# define cpu_to_le32(a) swap32(a)
+# define le64_to_cpu(a) bitfn_swap64(a)
+# define cpu_to_le64(a) bitfn_swap64(a)
+# define le32_to_cpu(a) bitfn_swap32(a)
+# define cpu_to_le32(a) bitfn_swap32(a)
 
 # define cpu_to_le32_array(d, s, l) array_swap32(d, s, l)
 # define le32_to_cpu_array(d, s, l) array_swap32(d, s, l)
diff --git a/cbits/sha1.c b/cbits/sha1.c
--- a/cbits/sha1.c
+++ b/cbits/sha1.c
@@ -50,31 +50,17 @@
 #define R(a, b, c, d, e, f, k, w)  \
 	e += rol32(a, 5) + f(b, c, d) + k + w; b = rol32(b, 30)
 
-#if (defined(__arm__))
-#define M(i)  (w[i])
-#else
 #define M(i)  (w[i & 0x0f] = rol32(w[i & 0x0f] ^ w[(i - 14) & 0x0f] \
               ^ w[(i - 8) & 0x0f] ^ w[(i - 3) & 0x0f], 1))
-#endif
 
 static inline void sha1_do_chunk(struct sha1_ctx *ctx, uint32_t *buf)
 {
 	uint32_t a, b, c, d, e;
-#if (defined(__arm__))
-	uint32_t i;
-	uint32_t w[80];
-	for (i = 0; i < 16; i++)
-		w[i] = be32_to_cpu(buf[i]);
-	for (; i < 80; i++)
-		w[i] = rol32(w[i & 0x0f] ^ w[(i - 14) & 0x0f] ^
-		             w[(i - 8) % 0x0f] ^ w[(i - 3) & 0x0f], 1);
-#else
 	uint32_t w[16];
 #define CPY(i)	w[i] = be32_to_cpu(buf[i])
 	CPY(0); CPY(1); CPY(2); CPY(3); CPY(4); CPY(5); CPY(6); CPY(7);
 	CPY(8); CPY(9); CPY(10); CPY(11); CPY(12); CPY(13); CPY(14); CPY(15);
 #undef CPY
-#endif
 
 	a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3]; e = ctx->h[4];
 
diff --git a/cryptohash.cabal b/cryptohash.cabal
--- a/cryptohash.cabal
+++ b/cryptohash.cabal
@@ -1,5 +1,5 @@
 Name:                cryptohash
-Version:             0.6.1
+Version:             0.6.2
 Description:
     A collection of crypto hashes, with a practical incremental and one-pass, pure APIs,
     with performance close to the fastest implementations available in others languages.
