From 0687f90dba5d628b9465c4c91626aec59638c29e Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 13 Sep 2002 10:33:10 +0000 Subject: Add a couple more of the big/little-endian conversion routines and make them visible from userland, if need be. I wish that the C language contained this as part of struct definintions, but failing that, I would settle for an agreed upon set of functions for packing/unpacking integers in various sizes from byte-streams which may have unfriendly alignment. This really belongs in I guess. --- sys/geom/geom_enc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sys/geom/geom_enc.c') diff --git a/sys/geom/geom_enc.c b/sys/geom/geom_enc.c index 657ac8c..ebb1bd1 100644 --- a/sys/geom/geom_enc.c +++ b/sys/geom/geom_enc.c @@ -101,3 +101,19 @@ g_enc_le4(u_char *p, uint32_t u) p[3] = (u >> 24) & 0xff; } +uint64_t +g_dec_le8(u_char *p) +{ + + return(g_dec_le4(p) | ((uint64_t)(g_dec_le4(p + 4)) << 32)); +} + + +void +g_enc_le8(u_char *p, uint64_t u) +{ + + g_enc_le4(p, u); + g_enc_le4(p + 4, u >> 32); +} + -- cgit v1.1