summaryrefslogtreecommitdiff
path: root/src/uint128p.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/uint128p.c')
-rw-r--r--src/uint128p.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/uint128p.c b/src/uint128p.c
index 57c713e..a06da72 100644
--- a/src/uint128p.c
+++ b/src/uint128p.c
@@ -6,9 +6,10 @@
@source djbdns6
@brief packing/unpacking 128 bit integer to/from char string
*/
-
-void uint128_pack(char s[16],uint128 u)
+
+void uint128_pack(char s[16], uint128 u)
{
+ // clang-format off
s[0] = u.lo & 255; u.lo >>= 8;
s[1] = u.lo & 255; u.lo >>= 8;
s[2] = u.lo & 255; u.lo >>= 8;
@@ -25,10 +26,12 @@ void uint128_pack(char s[16],uint128 u)
s[12] = u.hi & 255; u.hi >>= 8;
s[13] = u.hi & 255; u.hi >>= 8;
s[14] = u.hi & 255; u.hi >>= 8;
- s[15] = u.hi & 255;
+ s[15] = u.hi & 255;
+ // clang-format on
}
-void uint128_pack_big(char s[16],uint128 u)
+void uint128_pack_big(char s[16], uint128 u)
{
+ // clang-format off
s[15] = u.lo & 255; u.lo >>= 8;
s[14] = u.lo & 255; u.lo >>= 8;
s[13] = u.lo & 255; u.lo >>= 8;
@@ -45,14 +48,16 @@ void uint128_pack_big(char s[16],uint128 u)
s[3] = u.hi & 255; u.hi >>= 8;
s[2] = u.hi & 255; u.hi >>= 8;
s[1] = u.hi & 255; u.hi >>= 8;
- s[0] = u.hi & 255;
+ s[0] = u.hi & 255;
+ // clang-format on
}
-void uint128_unpack(char s[16],uint128 *u)
+void uint128_unpack(char s[16], uint128 *u)
{
uint128 result;
result.hi = result.lo = 0ULL;
+ // clang-format off
result.hi = (unsigned char) s[15]; result.hi <<= 8;
result.hi += (unsigned char) s[14]; result.hi <<= 8;
result.hi += (unsigned char) s[13]; result.hi <<= 8;
@@ -69,15 +74,17 @@ void uint128_unpack(char s[16],uint128 *u)
result.lo += (unsigned char) s[3]; result.lo <<= 8;
result.lo += (unsigned char) s[2]; result.lo <<= 8;
result.lo += (unsigned char) s[1]; result.lo <<= 8;
- result.lo += (unsigned char) s[0];
+ result.lo += (unsigned char) s[0];
+ // clang-format on
*u = result;
}
-void uint128_unpack_big(char s[16],uint128 *u)
+void uint128_unpack_big(char s[16], uint128 *u)
{
uint128 result;
result.hi = result.lo = 0ULL;
+ // clang-format off
result.hi = (unsigned char) s[0]; result.hi <<= 8;
result.hi += (unsigned char) s[1]; result.hi <<= 8;
result.hi += (unsigned char) s[2]; result.hi <<= 8;
@@ -95,6 +102,7 @@ void uint128_unpack_big(char s[16],uint128 *u)
result.lo += (unsigned char) s[13]; result.lo <<= 8;
result.lo += (unsigned char) s[14]; result.lo <<= 8;
result.lo += (unsigned char) s[15];
+ // clang-format on
*u = result;
}