* prot.h: Include k5-platform.h.
authorKen Raeburn <raeburn@mit.edu>
Wed, 8 Mar 2006 19:57:21 +0000 (19:57 +0000)
committerKen Raeburn <raeburn@mit.edu>
Wed, 8 Mar 2006 19:57:21 +0000 (19:57 +0000)
(krb4_swab16, krb4_swap32): Define in terms of SWAP16 and SWAP32, if
they're defined.
(KRB4_PUT32BE, KRB4_PUT32LE, KRB4_PUT16BE, KRB4_PUT16LE): Define to
use store_{16,32}_{be,le}.
(KRB4_GET32BE, KRB4_GET32LE, KRB4_GET16BE, KRB4_GET16LE): Define to
use load_{16,32}_{be,le}.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17715 dc483132-0cff-0310-8789-dd5450dbe970

src/include/kerberosIV/ChangeLog
src/include/kerberosIV/prot.h

index 9a0cd7764b8f5bf4cced4f38e29526b3273829dc..d9313e91df109e72a8fbc991728cac56bc1a3ffe 100644 (file)
@@ -1,3 +1,13 @@
+2006-03-08  Ken Raeburn  <raeburn@mit.edu>
+
+       * prot.h: Include k5-platform.h.
+       (krb4_swab16, krb4_swap32): Define in terms of SWAP16 and SWAP32,
+       if they're defined.
+       (KRB4_PUT32BE, KRB4_PUT32LE, KRB4_PUT16BE, KRB4_PUT16LE): Define
+       to use store_{16,32}_{be,le}.
+       (KRB4_GET32BE, KRB4_GET32LE, KRB4_GET16BE, KRB4_GET16LE): Define
+       to use load_{16,32}_{be,le}.
+
 2005-05-13  Ken Raeburn  <raeburn@mit.edu>
 
        * Makefile.in (thisconfigdir, mydir): Updated for configure
index c927ac042c03be8276e6bffa698e750a12009ee7..ccb028bd726864e27828c528fb4160a9dca2ce0d 100644 (file)
  *
  * Should also go away soon though.
  */
+#include "k5-platform.h"
+
+#ifdef SWAP16
+#define krb4_swab16(val)       SWAP16(val)
+#else
 #define krb4_swab16(val)       ((((val) >> 8)&0xFF) | ((val) << 8))
+#endif
+#ifdef SWAP32
+#define krb4_swap32(val)       SWAP32(val)
+#else
 #define krb4_swab32(val)       ((((val)>>24)&0xFF) | (((val)>>8)&0xFF00) | \
                                  (((val)<<8)&0xFF0000) | ((val)<<24))
+#endif
 
 /*
  * Macros to encode integers into buffers.  These take a parameter
  * that is a moving pointer of type (unsigned char *) into the buffer,
  * and assume that the caller has already bounds-checked.
  */
-#define KRB4_PUT32BE(p, val)                   \
-do {                                           \
-    (p)[0] = ((KRB_UINT32)(val) >> 24) & 0xff; \
-    (p)[1] = ((KRB_UINT32)(val) >> 16) & 0xff; \
-    (p)[2] = ((KRB_UINT32)(val) >> 8)  & 0xff; \
-    (p)[3] =  (KRB_UINT32)(val)        & 0xff; \
-    (p) += 4;                                  \
-} while (0)
-
-#define KRB4_PUT32LE(p, val)                   \
-do {                                           \
-    (p)[0] =  (KRB_UINT32)(val)        & 0xff; \
-    (p)[1] = ((KRB_UINT32)(val) >> 8)  & 0xff; \
-    (p)[2] = ((KRB_UINT32)(val) >> 16) & 0xff; \
-    (p)[3] = ((KRB_UINT32)(val) >> 24) & 0xff; \
-    (p) += 4;                                  \
-} while (0)
-
+#define KRB4_PUT32BE(p, val)   (store_32_be(val, p), (p) += 4)
+#define KRB4_PUT32LE(p, val)   (store_32_le(val, p), (p) += 4)
 #define KRB4_PUT32(p, val, le)                 \
 do {                                           \
     if (le)                                    \
@@ -123,20 +117,8 @@ do {                                               \
        KRB4_PUT32BE((p), (val));               \
 } while (0)
 
-#define KRB4_PUT16BE(p, val)                   \
-do {                                           \
-    (p)[0] = ((KRB_UINT32)(val) >> 8) & 0xff;  \
-    (p)[1] =  (KRB_UINT32)(val)       & 0xff;  \
-    (p) += 2;                                  \
-} while (0)
-
-#define KRB4_PUT16LE(p, val)                   \
-do {                                           \
-    (p)[0] =  (KRB_UINT32)(val)       & 0xff;  \
-    (p)[1] = ((KRB_UINT32)(val) >> 8) & 0xff;  \
-    (p) += 2;                                  \
-} while (0)
-
+#define KRB4_PUT16BE(p, val)   (store_16_be(val, p), (p) += 2)
+#define KRB4_PUT16LE(p, val)   (store_16_le(val, p), (p) += 2)
 #define KRB4_PUT16(p, val, le)                 \
 do {                                           \
     if (le)                                    \
@@ -153,24 +135,8 @@ do {                                               \
  * of unsigned -> signed conversion as implementation-defined, so it's
  * unwise to depend on such.
  */
-#define KRB4_GET32BE(val, p)                   \
-do {                                           \
-    (val)  = (KRB_UINT32)(p)[0] << 24;         \
-    (val) |= (KRB_UINT32)(p)[1] << 16;         \
-    (val) |= (KRB_UINT32)(p)[2] << 8;          \
-    (val) |= (KRB_UINT32)(p)[3];               \
-    (p) += 4;                                  \
-} while (0)
-
-#define KRB4_GET32LE(val, p)                   \
-do {                                           \
-    (val)  = (KRB_UINT32)(p)[0];               \
-    (val) |= (KRB_UINT32)(p)[1] << 8;          \
-    (val) |= (KRB_UINT32)(p)[2] << 16;         \
-    (val) |= (KRB_UINT32)(p)[3] << 24;         \
-    (p) += 4;                                  \
-} while(0)
-
+#define KRB4_GET32BE(val, p)   ((val) = load_32_be(p), (p) += 4)
+#define KRB4_GET32LE(val, p)   ((val) = load_32_le(p), (p) += 4)
 #define KRB4_GET32(val, p, le)                 \
 do {                                           \
     if (le)                                    \
@@ -179,20 +145,8 @@ do {                                               \
        KRB4_GET32BE((val), (p));               \
 } while (0)
 
-#define KRB4_GET16BE(val, p)                   \
-do {                                           \
-    (val)  = (KRB_UINT32)(p)[0] << 8;          \
-    (val) |= (KRB_UINT32)(p)[1];               \
-    (p) += 2;                                  \
-} while (0)
-
-#define KRB4_GET16LE(val, p)                   \
-do {                                           \
-    (val)  = (KRB_UINT32)(p)[0];               \
-    (val) |= (KRB_UINT32)(p)[1] << 8;          \
-    (p) += 2;                                  \
-} while (0)
-
+#define KRB4_GET16BE(val, p)   ((val) = load_16_be(p), (p) += 2)
+#define KRB4_GET16LE(val, p)   ((val) = load_16_le(p), (p) += 2)
 #define KRB4_GET16(val, p, le)                 \
 do {                                           \
     if (le)                                    \