From: Simon Josefsson Date: Tue, 24 Aug 2004 14:29:00 +0000 (+0200) Subject: (LE_READ_UINT16, LE_WRITE_UINT16): New macros. X-Git-Tag: nettle_1.11_release_20041026~68 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=ffcdc8c6d2ea0730de2291f352571418a537a155;p=thirdparty%2Fnettle.git (LE_READ_UINT16, LE_WRITE_UINT16): New macros. Rev: src/nettle/macros.h:1.7 --- diff --git a/macros.h b/macros.h index 89400c54..52876976 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))); \