summaryrefslogtreecommitdiff
path: root/bits.h
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-12-26 18:00:58 -0500
committerEric S. Raymond <esr@thyrsus.com>2010-12-26 18:00:58 -0500
commitcafb272f98f0b66481675743dfd42d6ac30baa47 (patch)
tree4d50a2f8dbae7f62c96320259e791f73a422e78d /bits.h
parent5062f7c420c55c8f2c3d51a75539b050536fc103 (diff)
downloadgpsd-cafb272f98f0b66481675743dfd42d6ac30baa47.tar.gz
Rename the bits.h macros to be explicit about operand length.
With most machines being 64-bit now, the assumption that "word" = 16 bits and "long" = 32 bits is increasingly archaic. This commit removes it from our naming conventions.
Diffstat (limited to 'bits.h')
-rw-r--r--bits.h44
1 files changed, 22 insertions, 22 deletions
diff --git a/bits.h b/bits.h
index 908cca02..6a41fd79 100644
--- a/bits.h
+++ b/bits.h
@@ -46,38 +46,38 @@ union long_double {
#define putbyte(buf,off,b) do {buf[(off)-(PUT_ORIGIN)] = (unsigned char)(b);} while (0)
/* little-endian access */
-#define getlesw(buf, off) ((int16_t)(((uint16_t)getub((buf), (off)+1) << 8) | (uint16_t)getub((buf), (off))))
-#define getleuw(buf, off) ((uint16_t)(((uint16_t)getub((buf), (off)+1) << 8) | (uint16_t)getub((buf), (off))))
-#define getlesl(buf, off) ((int32_t)(((uint16_t)getleuw((buf), (off)+2) << 16) | (uint16_t)getleuw((buf), (off))))
-#define getleul(buf, off) ((uint32_t)(((uint16_t)getleuw((buf),(off)+2) << 16) | (uint16_t)getleuw((buf), (off))))
+#define getles16(buf, off) ((int16_t)(((uint16_t)getub((buf), (off)+1) << 8) | (uint16_t)getub((buf), (off))))
+#define getleu16(buf, off) ((uint16_t)(((uint16_t)getub((buf), (off)+1) << 8) | (uint16_t)getub((buf), (off))))
+#define getles32(buf, off) ((int32_t)(((uint16_t)getleu16((buf), (off)+2) << 16) | (uint16_t)getleu16((buf), (off))))
+#define getleu32(buf, off) ((uint32_t)(((uint16_t)getleu16((buf),(off)+2) << 16) | (uint16_t)getleu16((buf), (off))))
-#define putleword(buf, off, w) do {putbyte(buf, (off)+1, (uint)(w) >> 8); putbyte(buf, (off), (w));} while (0)
-#define putlelong(buf, off, l) do {putleword(buf, (off)+2, (uint)(l) >> 16); putleword(buf, (off), (l));} while (0)
-#define getlesL(buf, off) ((int64_t)(((uint64_t)getleul(buf, (off)+4) << 32) | getleul(buf, (off))))
-#define getleuL(buf, off) ((uint64_t)(((uint64_t)getleul(buf, (off)+4) << 32) | getleul(buf, (off))))
+#define putle16(buf, off, w) do {putbyte(buf, (off)+1, (uint)(w) >> 8); putbyte(buf, (off), (w));} while (0)
+#define putle32(buf, off, l) do {putle16(buf, (off)+2, (uint)(l) >> 16); putle16(buf, (off), (l));} while (0)
+#define getles64(buf, off) ((int64_t)(((uint64_t)getleu32(buf, (off)+4) << 32) | getleu32(buf, (off))))
+#define getleu64(buf, off) ((uint64_t)(((uint64_t)getleu32(buf, (off)+4) << 32) | getleu32(buf, (off))))
-#define getlef(buf, off) (i_f.i = getlesl(buf, off), i_f.f)
-#define getled(buf, off) (l_d.l = getlesL(buf, off), l_d.d)
+#define getlef(buf, off) (i_f.i = getles32(buf, off), i_f.f)
+#define getled(buf, off) (l_d.l = getles64(buf, off), l_d.d)
/* SiRF and most other GPS protocols use big-endian (network byte order) */
-#define getbesw(buf, off) ((int16_t)(((uint16_t)getub(buf, (off)) << 8) | (uint16_t)getub(buf, (off)+1)))
-#define getbeuw(buf, off) ((uint16_t)(((uint16_t)getub(buf, (off)) << 8) | (uint16_t)getub(buf, (off)+1)))
-#define getbesl(buf, off) ((int32_t)(((uint16_t)getbeuw(buf, (off)) << 16) | getbeuw(buf, (off)+2)))
-#define getbeul(buf, off) ((uint32_t)(((uint16_t)getbeuw(buf, (off)) << 16) | getbeuw(buf, (off)+2)))
-#define getbesL(buf, off) ((int64_t)(((uint64_t)getbeul(buf, (off)) << 32) | getbeul(buf, (off)+4)))
-#define getbeuL(buf, off) ((uint64_t)(((uint64_t)getbeul(buf, (off)) << 32) | getbeul(buf, (off)+4)))
+#define getbes16(buf, off) ((int16_t)(((uint16_t)getub(buf, (off)) << 8) | (uint16_t)getub(buf, (off)+1)))
+#define getbeu16(buf, off) ((uint16_t)(((uint16_t)getub(buf, (off)) << 8) | (uint16_t)getub(buf, (off)+1)))
+#define getbes32(buf, off) ((int32_t)(((uint16_t)getbeu16(buf, (off)) << 16) | getbeu16(buf, (off)+2)))
+#define getbeu32(buf, off) ((uint32_t)(((uint16_t)getbeu16(buf, (off)) << 16) | getbeu16(buf, (off)+2)))
+#define getbes64(buf, off) ((int64_t)(((uint64_t)getbeu32(buf, (off)) << 32) | getbeu32(buf, (off)+4)))
+#define getbeu64(buf, off) ((uint64_t)(((uint64_t)getbeu32(buf, (off)) << 32) | getbeu32(buf, (off)+4)))
-#define putbeword(buf,off,w) do {putbyte(buf, (off) ,(w) >> 8); putbyte(buf, (off)+1, (w));} while (0)
-#define putbelong(buf,off,l) do {putbeword(buf, (off) ,(l) >> 16); putbeword(buf, (off)+2, (l));} while (0)
+#define putbe16(buf,off,w) do {putbyte(buf, (off) ,(w) >> 8); putbyte(buf, (off)+1, (w));} while (0)
+#define putbe32(buf,off,l) do {putbe16(buf, (off) ,(l) >> 16); putbe16(buf, (off)+2, (l));} while (0)
-#define getbef(buf, off) (i_f.i = getbesl(buf, off), i_f.f)
-#define getbed(buf, off) (l_d.l = getbesL(buf, off), l_d.d)
+#define getbef(buf, off) (i_f.i = getbes32(buf, off), i_f.f)
+#define getbed(buf, off) (l_d.l = getbes64(buf, off), l_d.d)
/* Zodiac protocol description uses 1-origin indexing by little-endian word */
-#define getwordz(buf, n) ( (buf[2*(n)-2]) \
+#define get16z(buf, n) ( (buf[2*(n)-2]) \
| (buf[2*(n)-1] << 8))
-#define getlongz(buf, n) ( (buf[2*(n)-2]) \
+#define get32z(buf, n) ( (buf[2*(n)-2]) \
| (buf[2*(n)-1] << 8) \
| (buf[2*(n)+0] << 16) \
| (buf[2*(n)+1] << 24))