# HG changeset patch # User jcdutton # Date 1053287739 0 # Node ID 719d007d0639ca955ec8e88bcbc83e068ea4064f # Parent a8b35f4c63b95b61e3109ed0a6d34b9119a313e0 Add some more getbit code. diff -r a8b35f4c63b9 -r 719d007d0639 nav_read.c --- a/nav_read.c Sun May 18 18:03:29 2003 +0000 +++ b/nav_read.c Sun May 18 19:55:39 2003 +0000 @@ -96,8 +96,32 @@ return result; } +/* WARNING: This function can only be used on a byte boundary. + No checks are made that we are in fact on a byte boundary. + */ +static uint16_t get16bits(getbits_state_t *state) { + uint16_t result; + state->byte_position++; + result = (state->byte << 8) + state->start[state->byte_position++]; + state->byte = state->start[state->byte_position]; + return result; +} + +/* WARNING: This function can only be used on a byte boundary. + No checks are made that we are in fact on a byte boundary. + */ +static uint32_t get32bits(getbits_state_t *state) { + uint32_t result; + state->byte_position++; + result = (state->byte << 8) + state->start[state->byte_position++]; + result = (result << 8) + state->start[state->byte_position++]; + result = (result << 8) + state->start[state->byte_position++]; + state->byte = state->start[state->byte_position]; + return result; +} + void navRead_PCI(pci_t *pci, unsigned char *buffer) { - int32_t result, i, j; + int32_t i, j; getbits_state_t state; if (getbits_init(&state, buffer)) assert(0); /* Passed NULL pointers */