From: Tilman Sauerbeck Date: Mon, 16 Nov 2015 18:47:04 +0000 (+0100) Subject: Add the RB64 macro. X-Git-Tag: libsigrok-0.4.0~82 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=17b93fd7c0c7af90042eac513d837cf1ec2b5f9c;p=libsigrok.git Add the RB64 macro. Reads an unsigned 64 bit integer from memory. --- diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index f3ee2e3b..41754b28 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -116,6 +116,20 @@ struct zip_stat; ((unsigned)((const uint8_t*)(x))[1] << 8) | \ (unsigned)((const uint8_t*)(x))[0])) +/** + * Read a 64 bits big endian unsigned integer out of memory. + * @param x a pointer to the input memory + * @return the corresponding unsigned integer + */ +#define RB64(x) (((uint64_t)((const uint8_t*)(x))[0] << 56) | \ + ((uint64_t)((const uint8_t*)(x))[1] << 48) | \ + ((uint64_t)((const uint8_t*)(x))[2] << 40) | \ + ((uint64_t)((const uint8_t*)(x))[3] << 32) | \ + ((uint64_t)((const uint8_t*)(x))[4] << 24) | \ + ((uint64_t)((const uint8_t*)(x))[5] << 16) | \ + ((uint64_t)((const uint8_t*)(x))[6] << 8) | \ + (uint64_t)((const uint8_t*)(x))[7]) + /** * Read a 32 bits big endian float out of memory. * @param x a pointer to the input memory