]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
(LE_READ_UINT16, LE_WRITE_UINT16): New macros.
authorSimon Josefsson <simon@josefsson.org>
Tue, 24 Aug 2004 14:29:00 +0000 (16:29 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Tue, 24 Aug 2004 14:29:00 +0000 (16:29 +0200)
Rev: src/nettle/macros.h:1.7

macros.h

index 89400c547b6c5e5605df988f50b4bdbfa8e94e53..52876976ebf52fc27add29081e8b1bb04786d3fc 100644 (file)
--- 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)));           \