summaryrefslogtreecommitdiffstats
path: root/sys/geom/geom_enc.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-09-13 10:33:10 +0000
committerphk <phk@FreeBSD.org>2002-09-13 10:33:10 +0000
commit0687f90dba5d628b9465c4c91626aec59638c29e (patch)
treea6c2aa2b6519a7f9c2a51850c254ca89d2a99ffb /sys/geom/geom_enc.c
parente48c2b856016caaa98feb0c86f13098e44f4a725 (diff)
downloadFreeBSD-src-0687f90dba5d628b9465c4c91626aec59638c29e.zip
FreeBSD-src-0687f90dba5d628b9465c4c91626aec59638c29e.tar.gz
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 <sys/endian.h> I guess.
Diffstat (limited to 'sys/geom/geom_enc.c')
-rw-r--r--sys/geom/geom_enc.c16
1 files changed, 16 insertions, 0 deletions
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);
+}
+
OpenPOWER on IntegriCloud