From f42f2e90162893dd4eb9c9d6ccd25e7bd758aabe Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Wed, 2 Dec 2009 23:09:29 +0000 Subject: [PATCH] Add store_{16,32,64}_n functions, for potentially-unaligned, native-order values git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23431 dc483132-0cff-0310-8789-dd5450dbe970 --- src/include/k5-platform.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/include/k5-platform.h b/src/include/k5-platform.h index ee3730ad0..9b02462b6 100644 --- a/src/include/k5-platform.h +++ b/src/include/k5-platform.h @@ -713,6 +713,35 @@ load_64_le (const void *cvp) #endif } +static inline void +store_16_n (unsigned int val, void *vp) +{ +#ifdef _WIN32 + unsigned __int16 n; +#else + uint16_t n; +#endif + n = val; + memcpy(vp, &n, 2); +} +static inline void +store_32_n (unsigned int val, void *vp) +{ +#ifdef _WIN32 + unsigned __int32 n; +#else + uint32_t n; +#endif + n = val; + memcpy(vp, &n, 4); +} +static inline void +store_64_n (UINT64_TYPE val, void *vp) +{ + UINT64_TYPE n; + n = val; + memcpy(vp, &n, 8); +} static inline unsigned short load_16_n (const void *p) { -- 2.26.2