Add store_{16,32,64}_n functions, for potentially-unaligned, native-order values
authorKen Raeburn <raeburn@mit.edu>
Wed, 2 Dec 2009 23:09:29 +0000 (23:09 +0000)
committerKen Raeburn <raeburn@mit.edu>
Wed, 2 Dec 2009 23:09:29 +0000 (23:09 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23431 dc483132-0cff-0310-8789-dd5450dbe970

src/include/k5-platform.h

index ee3730ad095bbbf92dac02c3c6fa903fb4e786cc..9b02462b6445fd534c628d7b4d7b0dbf41408e13 100644 (file)
@@ -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)
 {