summaryrefslogtreecommitdiff
path: root/bits.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-03-15 06:38:17 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-03-15 06:38:17 +0000
commit4f627e90862866164d1e0e1c0ac3ca85e8373f56 (patch)
treeb9cf75dba85794f10c627025ed1cbcfa12d6bd2a /bits.c
parentb3f49700b7f032a4cd0fe5d15ef4b747ad580f9f (diff)
downloadgpsd-4f627e90862866164d1e0e1c0ac3ca85e8373f56.tar.gz
Check in AIVDM regression tests for sentence types 1-4.
Diffstat (limited to 'bits.c')
-rw-r--r--bits.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/bits.c b/bits.c
index 41599634..bd807348 100644
--- a/bits.c
+++ b/bits.c
@@ -30,25 +30,30 @@ unsigned long long ubits(char buf[], unsigned int start, unsigned int width)
fld <<= BITS_PER_BYTE;
fld |= (unsigned char)buf[i];
}
-#ifdef UDEBUG
- printf("Extracting %d:%d from %s: segment 0x%llx = %lld\n", start, width,
- gpsd_hexdump(buf, 12), fld, fld);
-#endif /* UDEBUG */
+#ifdef DEBUG
+ (void)printf("%d:%d from %s:\n", start, width, gpsd_hexdump(buf, 32));
+#endif
+#ifdef DEBUG
+ (void)printf(" segment=0x%llx,", fld);
+#endif /* DEBUG */
end = (start + width) % BITS_PER_BYTE;
if (end != 0) {
fld >>= (BITS_PER_BYTE - end);
-#ifdef UDEBUG
- printf("After downshifting by %d bits: 0x%llx = %lld\n",
- BITS_PER_BYTE - end, fld, fld);
+#ifdef DEBUG
+ (void)printf(" after downshifting by %d bits: 0x%llx",
+ BITS_PER_BYTE - end, fld);
#endif /* UDEBUG */
}
+#ifdef DEBUG
+ (void)printf(" = %lld\n", fld);
+#endif /* UDEBUG */
fld &= ~(-1LL << width);
-#ifdef UDEBUG
- printf("After selecting out the bottom %u bits: 0x%llx = %lld\n",
- width, fld, fld);
-#endif /* UDEBUG */
+#ifdef DEBUG
+ (void)printf(" after selecting out the bottom %u bits: 0x%llx = %lld\n",
+ width, fld, fld);
+#endif /* DEBUG */
return fld;
}
@@ -58,19 +63,19 @@ signed long long sbits(char buf[], unsigned int start, unsigned int width)
{
unsigned long long fld = ubits(buf, start, width);
-#ifdef DEBUG
+#ifdef SDEBUG
(void)fprintf(stderr, "sbits(%d, %d) extracts %llx\n", start, width, fld);
-#endif /* DEBUG */
+#endif /* SDEBUG */
/*@ +relaxtypes */
if (fld & (1 << (width-1))) {
-#ifdef DEBUG
+#ifdef SDEBUG
(void)fprintf(stderr, "%llx is signed\n", fld);
-#endif /* DEBUG */
+#endif /* SDEBUG */
fld |= (-1LL << (width-1));
}
-#ifdef DEBUG
+#ifdef SDEBUG
(void)fprintf(stderr, "sbits(%d, %d) returns %lld\n", start, width, (signed long long)fld);
-#endif /* DEBUG */
+#endif /* SDEBUG */
return (signed long long)fld;
/*@ -relaxtypes */
}