*: use SWAP_BE64 instead of open-coding it

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
diff --git a/include/libbb.h b/include/libbb.h
index dec4e3a..b16157d 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1540,7 +1540,7 @@
 	uint32_t C;
 	uint32_t D;
 	uint64_t total64;
-	char wbuffer[64];
+	char wbuffer[64]; /* NB: always correctly aligned for uint64_t */
 } md5_ctx_t;
 #else
 /* libbb/md5prime.c uses a bit different one: */
diff --git a/libbb/hash_md5.c b/libbb/hash_md5.c
index 051c8ed..9de27f1 100644
--- a/libbb/hash_md5.c
+++ b/libbb/hash_md5.c
@@ -417,11 +417,9 @@
 		if (remaining >= 8) {
 			/* Store the 64-bit counter of bits in the buffer in BE format */
 			uint64_t t = ctx->total64 << 3;
-			unsigned i;
-			for (i = 0; i < 8; i++) {
-				ctx->wbuffer[56 + i] = t;
-				t >>= 8;
-			}
+			t = SWAP_BE64(t);
+			/* wbuffer is suitably aligned for this */
+			*(uint64_t *) (&ctx->wbuffer[64 - 8]) = t;
 		}
 		md5_process_block64(ctx);
 		if (remaining >= 8)
diff --git a/libbb/hash_sha.c b/libbb/hash_sha.c
index d792911..e7199d3 100644
--- a/libbb/hash_sha.c
+++ b/libbb/hash_sha.c
@@ -52,10 +52,10 @@
 	return (x >> n) | (x << (64 - n));
 }
 #if BB_LITTLE_ENDIAN
-/* ALWAYS_INLINE below would hurt code size, using plain inline: */
+/* ALWAYS_INLINE below sometimes hurts code size, using plain inline: */
 static inline uint64_t hton64(uint64_t v)
 {
-	return (((uint64_t)htonl(v)) << 32) | htonl(v >> 32);
+	return SWAP_BE64(v);
 }
 #else
 #define hton64(v) (v)
@@ -76,7 +76,7 @@
 	const uint32_t *words = (uint32_t*) ctx->wbuffer;
 
 	for (t = 0; t < 16; ++t)
-		W[t] = ntohl(words[t]);
+		W[t] = SWAP_BE32(words[t]);
 	for (/*t = 16*/; t < 80; ++t) {
 		uint32_t T = W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16];
 		W[t] = rotl32(T, 1);
@@ -198,7 +198,7 @@
 
 	/* Compute the message schedule according to FIPS 180-2:6.2.2 step 2.  */
 	for (t = 0; t < 16; ++t)
-		W[t] = ntohl(words[t]);
+		W[t] = SWAP_BE32(words[t]);
 	for (/*t = 16*/; t < 64; ++t)
 		W[t] = R1(W[t - 2]) + W[t - 7] + R0(W[t - 15]) + W[t - 16];
 
@@ -490,7 +490,7 @@
 	if (BB_LITTLE_ENDIAN) {
 		unsigned i;
 		for (i = 0; i < bufpos; ++i)
-			ctx->hash[i] = htonl(ctx->hash[i]);
+			ctx->hash[i] = SWAP_BE32(ctx->hash[i]);
 	}
 	memcpy(resbuf, ctx->hash, sizeof(ctx->hash[0]) * bufpos);
 }
diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c
index 2eaadb6..341815a 100644
--- a/networking/udhcp/dumpleases.c
+++ b/networking/udhcp/dumpleases.c
@@ -9,7 +9,7 @@
 #if BB_LITTLE_ENDIAN
 static inline uint64_t hton64(uint64_t v)
 {
-        return (((uint64_t)htonl(v)) << 32) | htonl(v >> 32);
+        return SWAP_BE64(v);
 }
 #else
 #define hton64(v) (v)
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index f5348f6..68b2085 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -14,7 +14,7 @@
 #if BB_LITTLE_ENDIAN
 static inline uint64_t hton64(uint64_t v)
 {
-        return (((uint64_t)htonl(v)) << 32) | htonl(v >> 32);
+        return SWAP_BE64(v);
 }
 #else
 #define hton64(v) (v)