Enable compilation of little-endian unaligned load/store helper
authorKen Raeburn <raeburn@mit.edu>
Wed, 8 Mar 2006 04:18:31 +0000 (04:18 +0000)
committerKen Raeburn <raeburn@mit.edu>
Wed, 8 Mar 2006 04:18:31 +0000 (04:18 +0000)
functions in k5-platform.h, and use them in kdb encoding/decoding
macros.

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

src/include/ChangeLog
src/include/k5-platform.h
src/include/krb5/ChangeLog
src/include/krb5/kdb.h

index 4065aae96a27dbbaf9014b29ee67a6d9313833f1..584311b05d749728cfd77c8bd72fd203b91ebdc1 100644 (file)
@@ -1,5 +1,8 @@
 2006-03-07  Ken Raeburn  <raeburn@mit.edu>
 
+       * k5-platform.h ({load,store}_{16,32,64}_le): Enable little-endian
+       versions.
+
        * k5-locate.h: Renamed from k5-plugin.h.
        * k5-plugin.h: New file, with plugin support function declarations
        moved from k5-int.h.  Change return types from krb5_error_code to
index 7f7f3087bb931f034334a0c821726cf790d53acd..af949dbd402bb5e29ec788f3ced3a8ff5b50171e 100644 (file)
@@ -577,7 +577,6 @@ load_64_be (const unsigned char *p)
     return ((UINT64_TYPE)load_32_be(p) << 32) | load_32_be(p+4);
 #endif
 }
-#if 0 /* don't need little-endian so far */
 static inline void
 store_16_le (unsigned int val, unsigned char *p)
 {
@@ -655,7 +654,6 @@ load_64_le (const unsigned char *p)
     return ((UINT64_TYPE)load_32_le(p+4) << 32) | load_32_le(p);
 #endif
 }
-#endif
 
 /* Make the interfaces to getpwnam and getpwuid consistent.
    Model the wrappers on the POSIX thread-safe versions, but
index bbc1d8b976c1acb6f10d354027156ec424d303e5..2a7ca9a3210c0644c72959a391f7770d9eb890ba 100644 (file)
@@ -1,3 +1,11 @@
+2006-03-07  Ken Raeburn  <raeburn@mit.edu>
+
+       * kdb.h: Include k5-platform.h.
+       (krb5_kdb_decode_int16, krb5_kdb_decode_int32): Use load_*_le
+       helper functions.
+       (krb5_kdb_encode_int16, krb5_kdb_encode_int32): Use store_*_le
+       helper functions.
+
 2006-03-06  Ken Raeburn  <raeburn@mit.edu>
 
        * Makefile.in (PROCESS_REPLACE): Use MODULE_DIR instead of
index c93ac96c41cf362569768eadd5ec17d9fa998329..c8327657fcd20e4d7328b3f6ca5a787919e6e7df 100644 (file)
@@ -194,26 +194,13 @@ extern char *krb5_mkey_pwd_prompt2;
  *
  * Data encoding is little-endian.
  */
+#include "k5-platform.h"
 #define        krb5_kdb_decode_int16(cp, i16)  \
-       *((krb5_int16 *) &(i16)) = (((krb5_int16) ((unsigned char) (cp)[0]))| \
-                             ((krb5_int16) ((unsigned char) (cp)[1]) << 8))
+       *((krb5_int16 *) &(i16)) = load_16_le(cp)
 #define        krb5_kdb_decode_int32(cp, i32)  \
-       *((krb5_int32 *) &(i32)) = (((krb5_int32) ((unsigned char) (cp)[0]))| \
-                             ((krb5_int32) ((unsigned char) (cp)[1]) << 8) | \
-                             ((krb5_int32) ((unsigned char) (cp)[2]) << 16)| \
-                             ((krb5_int32) ((unsigned char) (cp)[3]) << 24))
-#define        krb5_kdb_encode_int16(i16, cp)  \
-       {                                                       \
-           (cp)[0] = (unsigned char) ((i16) & 0xff);           \
-           (cp)[1] = (unsigned char) (((i16) >> 8) & 0xff);    \
-       }
-#define        krb5_kdb_encode_int32(i32, cp)  \
-       {                                                       \
-           (cp)[0] = (unsigned char) ((i32) & 0xff);           \
-           (cp)[1] = (unsigned char) (((i32) >> 8) & 0xff);    \
-           (cp)[2] = (unsigned char) (((i32) >> 16) & 0xff);   \
-           (cp)[3] = (unsigned char) (((i32) >> 24) & 0xff);   \
-       }
+       *((krb5_int32 *) &(i32)) = load_32_le(cp)
+#define krb5_kdb_encode_int16(i16, cp) store_16_le(i16, cp)
+#define        krb5_kdb_encode_int32(i32, cp)  store_32_le(i32, cp)
 
 #define KRB5_KDB_OPEN_RW                0
 #define KRB5_KDB_OPEN_RO                1