diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2012-04-18 09:31:31 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2012-04-19 06:37:55 -0400 |
commit | 95af9817588787371e8c440aeeec53519737efb6 (patch) | |
tree | 610201b269ccae0454dc753cfaead4fcfe6dd6dd | |
parent | c0a165cc8d45633c5ac036d7176e2afed8c892da (diff) | |
download | gpsd-95af9817588787371e8c440aeeec53519737efb6.tar.gz |
Rename some bit extractors.
-rw-r--r-- | bits.c | 12 | ||||
-rw-r--r-- | bits.h | 4 | ||||
-rw-r--r-- | driver_aivdm.c | 6 | ||||
-rw-r--r-- | driver_evermore.c | 4 | ||||
-rw-r--r-- | driver_rtcm3.c | 4 | ||||
-rw-r--r-- | test_bits.c | 4 |
6 files changed, 17 insertions, 17 deletions
@@ -20,7 +20,7 @@ #define BITS_PER_BYTE 8 -uint64_t ubits(char buf[], unsigned int start, unsigned int width) +uint64_t ubebits(char buf[], unsigned int start, unsigned int width) /* extract a (zero-origin) bitfield from the buffer as an unsigned big-endian uint64_t */ { uint64_t fld = 0; @@ -34,7 +34,7 @@ uint64_t ubits(char buf[], unsigned int start, unsigned int width) fld |= (unsigned char)buf[i]; } #ifdef DEBUG - (void)printf("%d:%d from %s:\n", start, width, gpsd_hexdump(buf, 32)); + (void)printf("ubebits: %d:%d from %s:\n", start, width, gpsd_hexdump(buf, 32)); #endif #ifdef DEBUG @@ -64,13 +64,13 @@ uint64_t ubits(char buf[], unsigned int start, unsigned int width) return fld; } -int64_t sbits(char buf[], unsigned int start, unsigned int width) +int64_t sbebits(char buf[], unsigned int start, unsigned int width) /* extract a bitfield from the buffer as a signed big-endian long */ { - uint64_t fld = ubits(buf, start, width); + uint64_t fld = ubebits(buf, start, width); #ifdef __UNUSED_DEBUG__ - (void)fprintf(stderr, "sbits(%d, %d) extracts %llx\n", start, width, fld); + (void)fprintf(stderr, "sbebits(%d, %d) extracts %llx\n", start, width, fld); #endif /* __UNUSED_DEBUG__ */ /*@ +relaxtypes */ if (fld & (1LL << (width - 1))) { @@ -82,7 +82,7 @@ int64_t sbits(char buf[], unsigned int start, unsigned int width) /*@ +shiftimplementation @*/ } #ifdef __UNUSED_DEBUG__ - (void)fprintf(stderr, "sbits(%d, %d) returns %lld\n", start, width, + (void)fprintf(stderr, "sbebits(%d, %d) returns %lld\n", start, width, (int64_t)fld); #endif /* __UNUSED_DEBUG__ */ return (int64_t)fld; @@ -81,7 +81,7 @@ union long_double { (void)memcpy(to, from+2*(s)-2, 2*((e)-(s)+1)) /* bitfield extraction */ -extern uint64_t ubits(char buf[], unsigned int, unsigned int); -extern int64_t sbits(char buf[], unsigned int, unsigned int); +extern uint64_t ubebits(char buf[], unsigned int, unsigned int); +extern int64_t sbebits(char buf[], unsigned int, unsigned int); #endif /* _GPSD_BITS_H_ */ diff --git a/driver_aivdm.c b/driver_aivdm.c index 00aace0b..e5d80b22 100644 --- a/driver_aivdm.c +++ b/driver_aivdm.c @@ -44,7 +44,7 @@ static void from_sixbit(char *bitvec, uint start, int count, char *to) /* six-bit to ASCII */ for (i = 0; i < count - 1; i++) { - newchar = sixchr[ubits(bitvec, start + 6 * i, 6U)]; + newchar = sixchr[ubebits(bitvec, start + 6 * i, 6U)]; if (newchar == '@') break; else @@ -215,8 +215,8 @@ bool aivdm_decode(const char *buf, size_t buflen, ais_context->decoded_frags = 0; #define BITS_PER_BYTE 8 -#define UBITS(s, l) ubits((char *)ais_context->bits, s, l) -#define SBITS(s, l) sbits((char *)ais_context->bits, s, l) +#define UBITS(s, l) ubebits((char *)ais_context->bits, s, l) +#define SBITS(s, l) sbebits((char *)ais_context->bits, s, l) #define UCHARS(s, to) from_sixbit((char *)ais_context->bits, s, sizeof(to), to) ais->type = UBITS(0, 6); ais->repeat = UBITS(6, 2); diff --git a/driver_evermore.c b/driver_evermore.c index d1118c47..10d58cc7 100644 --- a/driver_evermore.c +++ b/driver_evermore.c @@ -333,8 +333,8 @@ gps_mask_t evermore_parse(struct gps_device_t * session, unsigned char *buf, * and status for each channel from the chip. We cannot get * codephase or carrierphase. */ -#define SBITS(sat, s, l) sbits((char *)buf, 10 + (sat*14) + s, l) -#define UBITS(sat, s, l) ubits((char *)buf, 10 + (sat*14) + s, l) +#define SBITS(sat, s, l) sbebits((char *)buf, 10 + (sat*14) + s, l) +#define UBITS(sat, s, l) ubebits((char *)buf, 10 + (sat*14) + s, l) for (k = 0; k < visible; k++) { int prn = (int)UBITS(k, 4, 5); /* this is so we can tell which never got set */ diff --git a/driver_rtcm3.c b/driver_rtcm3.c index c39d3450..d1ce850d 100644 --- a/driver_rtcm3.c +++ b/driver_rtcm3.c @@ -74,8 +74,8 @@ void rtcm3_unpack( /*@out@*/ struct rtcm3_t *rtcm, char *buf) signed long temp; /*@ -evalorder -sefparams -mayaliasunique @*/ -#define ugrab(width) (bitcount += width, ubits(buf, bitcount-width, width)) -#define sgrab(width) (bitcount += width, sbits(buf, bitcount-width, width)) +#define ugrab(width) (bitcount += width, ubebits(buf, bitcount-width, width)) +#define sgrab(width) (bitcount += width, sbebits(buf, bitcount-width, width)) #define GPS_PSEUDORANGE(fld, len) \ {temp = (unsigned long)ugrab(len); \ if (temp == GPS_INVALID_PSEUDORANGE) \ diff --git a/test_bits.c b/test_bits.c index e30b95aa..3be27cc8 100644 --- a/test_bits.c +++ b/test_bits.c @@ -195,8 +195,8 @@ int main(void) up < unsigned_tests + sizeof(unsigned_tests) / sizeof(unsigned_tests[0]); up++) { - uint64_t res = ubits((char *)buf, up->start, up->width); - (void)printf("ubits(%s, %d, %d) %s should be %" PRIx64 ", is %" PRIx64 ": %s\n", + uint64_t res = ubebits((char *)buf, up->start, up->width); + (void)printf("ubebits(%s, %d, %d) %s should be %" PRIx64 ", is %" PRIx64 ": %s\n", hexdump(buf, strlen((char *)buf)), up->start, up->width, up->description, up->expected, res, res == up->expected ? "succeeded" : "FAILED"); |