X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Flibsigrok-internal.h;h=3413f9208fae0377e3633ef2c329bc9239394cdf;hb=e6b15cb5e609c9263f501d3b12965206feddb42b;hp=41754b288ac9a7126953f323c18922c9209d981f;hpb=17b93fd7c0c7af90042eac513d837cf1ec2b5f9c;p=libsigrok.git diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index 41754b28..3413f920 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -76,6 +76,15 @@ struct zip_stat; #define RL16(x) (((unsigned)((const uint8_t*)(x))[1] << 8) | \ (unsigned)((const uint8_t*)(x))[0]) +/** + * Read a 16 bits big endian signed integer out of memory. + * @param x a pointer to the input memory + * @return the corresponding signed integer + */ +#define RB16S(x) ((int16_t) \ + (((unsigned)((const uint8_t*)(x))[0] << 8) | \ + (unsigned)((const uint8_t*)(x))[1])) + /** * Read a 16 bits little endian signed integer out of memory. * @param x a pointer to the input memory @@ -105,6 +114,17 @@ struct zip_stat; ((unsigned)((const uint8_t*)(x))[1] << 8) | \ (unsigned)((const uint8_t*)(x))[0]) +/** + * Read a 32 bits big endian signed integer out of memory. + * @param x a pointer to the input memory + * @return the corresponding signed integer + */ +#define RB32S(x) ((int32_t) \ + (((unsigned)((const uint8_t*)(x))[0] << 24) | \ + ((unsigned)((const uint8_t*)(x))[1] << 16) | \ + ((unsigned)((const uint8_t*)(x))[2] << 8) | \ + (unsigned)((const uint8_t*)(x))[3])) + /** * Read a 32 bits little endian signed integer out of memory. * @param x a pointer to the input memory