From: Ken Raeburn Date: Wed, 8 Mar 2006 04:18:31 +0000 (+0000) Subject: Enable compilation of little-endian unaligned load/store helper X-Git-Tag: krb5-1.5-alpha1~186 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=59a772e257ac9012eaecd8c35f27c1e4630c80b0;p=krb5.git Enable compilation of little-endian unaligned load/store helper 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 --- diff --git a/src/include/ChangeLog b/src/include/ChangeLog index 4065aae96..584311b05 100644 --- a/src/include/ChangeLog +++ b/src/include/ChangeLog @@ -1,5 +1,8 @@ 2006-03-07 Ken Raeburn + * 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 diff --git a/src/include/k5-platform.h b/src/include/k5-platform.h index 7f7f3087b..af949dbd4 100644 --- a/src/include/k5-platform.h +++ b/src/include/k5-platform.h @@ -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 diff --git a/src/include/krb5/ChangeLog b/src/include/krb5/ChangeLog index bbc1d8b97..2a7ca9a32 100644 --- a/src/include/krb5/ChangeLog +++ b/src/include/krb5/ChangeLog @@ -1,3 +1,11 @@ +2006-03-07 Ken Raeburn + + * 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 * Makefile.in (PROCESS_REPLACE): Use MODULE_DIR instead of diff --git a/src/include/krb5/kdb.h b/src/include/krb5/kdb.h index c93ac96c4..c8327657f 100644 --- a/src/include/krb5/kdb.h +++ b/src/include/krb5/kdb.h @@ -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