diff --git a/macros.h b/macros.h index 89400c547b6c5e5605df988f50b4bdbfa8e94e53..52876976ebf52fc27add29081e8b1bb04786d3fc 100644 --- a/macros.h +++ b/macros.h @@ -78,6 +78,17 @@ do { \ (p)[0] = (i) & 0xff; \ } while(0) +/* Analogous macros, for 16 bit numbers */ +#define LE_READ_UINT16(p) \ + ( (((uint32_t) (p)[1]) << 8) \ + | ((uint32_t) (p)[0])) + +#define LE_WRITE_UINT16(p, i) \ + do { \ + (p)[1] = ((i) >> 8) & 0xff; \ + (p)[0] = (i) & 0xff; \ + } while(0) + /* Macro to make it easier to loop over several blocks. */ #define FOR_BLOCKS(length, dst, src, blocksize) \ assert( !((length) % (blocksize))); \