Skip to content
Snippets Groups Projects
Commit 20b8bd9b authored by Niels Möller's avatar Niels Möller
Browse files

(READ_UINT24, WRITE_UINT24, READ_UINT16, WRITE_UINT16):

New macros.

Rev: src/nettle/macros.h:1.6
parent 5b64829d
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,29 @@ do { \ ...@@ -40,6 +40,29 @@ do { \
(p)[3] = (i) & 0xff; \ (p)[3] = (i) & 0xff; \
} while(0) } while(0)
/* Analogous macros, for 24 and 16 bit numbers */
#define READ_UINT24(p) \
( (((uint32_t) (p)[0]) << 16) \
| (((uint32_t) (p)[1]) << 8) \
| ((uint32_t) (p)[2]))
#define WRITE_UINT24(p, i) \
do { \
(p)[0] = ((i) >> 16) & 0xff; \
(p)[1] = ((i) >> 8) & 0xff; \
(p)[2] = (i) & 0xff; \
} while(0)
#define READ_UINT16(p) \
( (((uint32_t) (p)[0]) << 8) \
| ((uint32_t) (p)[1]))
#define WRITE_UINT16(p, i) \
do { \
(p)[0] = ((i) >> 8) & 0xff; \
(p)[1] = (i) & 0xff; \
} while(0)
/* And the other, little-endian, byteorder */ /* And the other, little-endian, byteorder */
#define LE_READ_UINT32(p) \ #define LE_READ_UINT32(p) \
( (((uint32_t) (p)[3]) << 24) \ ( (((uint32_t) (p)[3]) << 24) \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment