updates.
[silc.git] / includes / bitmove.h
index aca83a4abdaf5cf650b2f660e0414ed504387d44..8c765cceeda4007e567f24098b575df613eb59c0 100644 (file)
 #define BITMOVE_H
 
 /* Returns four 8-bit bytes, most significant bytes first. */
-#define SILC_GET32_MSB(l, cp) \
-       (l) = ((unsigned long)(unsigned char)(cp)[0]) << 24 \
-           | ((unsigned long)(unsigned char)(cp)[1] << 16) \
-           | ((unsigned long)(unsigned char)(cp)[2] << 8) \
-           | ((unsigned long)(unsigned char)(cp)[3])
-#define SILC_PUT32_MSB(l, cp) \
-       (cp)[0] = l >> 24; \
-       (cp)[1] = l >> 16; \
-       (cp)[2] = l >> 8; \
+#define SILC_GET32_MSB(l, cp)                  \
+       (l) = ((uint32)(uint8)(cp)[0]) << 24    \
+           | ((uint32)(uint8)(cp)[1] << 16)    \
+           | ((uint32)(uint8)(cp)[2] << 8)     \
+           | ((uint32)(uint8)(cp)[3])
+#define SILC_PUT32_MSB(l, cp)                  \
+       (cp)[0] = l >> 24;                      \
+       (cp)[1] = l >> 16;                      \
+       (cp)[2] = l >> 8;                       \
        (cp)[3] = l;
 
 
 /* Returns four 8-bit bytes, less significant bytes first. */
-#define SILC_GET32_LSB(l, cp) \
-       (l) = ((unsigned long)(unsigned char)(cp)[0]) \
-           | ((unsigned long)(unsigned char)(cp)[1] << 8) \
-           | ((unsigned long)(unsigned char)(cp)[2] << 16) \
-           | ((unsigned long)(unsigned char)(cp)[3] << 24)
+#define SILC_GET32_LSB(l, cp)                  \
+       (l) = ((uint32)(uint8)(cp)[0])          \
+           | ((uint32)(uint8)(cp)[1] << 8)     \
+           | ((uint32)(uint8)(cp)[2] << 16)    \
+           | ((uint32)(uint8)(cp)[3] << 24)
 /* same as upper but XOR the result always */
-#define SILC_GET32_X_LSB(l, cp) \
-       (l) ^= ((unsigned long)(unsigned char)(cp)[0]) \
-           | ((unsigned long)(unsigned char)(cp)[1] << 8) \
-           | ((unsigned long)(unsigned char)(cp)[2] << 16) \
-           | ((unsigned long)(unsigned char)(cp)[3] << 24)
-#define SILC_PUT32_LSB(l, cp) \
-       (cp)[0] = l; \
-       (cp)[1] = l >> 8; \
-       (cp)[2] = l >> 16; \
+#define SILC_GET32_X_LSB(l, cp)                        \
+       (l) ^= ((uint32)(uint8)(cp)[0])         \
+           | ((uint32)(uint8)(cp)[1] << 8)     \
+           | ((uint32)(uint8)(cp)[2] << 16)    \
+           | ((uint32)(uint8)(cp)[3] << 24)
+#define SILC_PUT32_LSB(l, cp)                  \
+       (cp)[0] = l;                            \
+       (cp)[1] = l >> 8;                       \
+       (cp)[2] = l >> 16;                      \
        (cp)[3] = l >> 24;
 
 
 /* Returns two 8-bit bytes, most significant bytes first. */
-#define SILC_GET16_MSB(l, cp) \
-       (l) = ((unsigned long)(unsigned char)(cp)[0] << 8) \
-           | ((unsigned long)(unsigned char)(cp)[1])
-#define SILC_PUT16_MSB(l, cp) \
-       (cp)[0] = l >> 8; \
+#define SILC_GET16_MSB(l, cp)                  \
+       (l) = ((uint32)(uint8)(cp)[0] << 8)     \
+           | ((uint32)(uint8)(cp)[1])
+#define SILC_PUT16_MSB(l, cp)                  \
+       (cp)[0] = l >> 8;                       \
        (cp)[1] = l;
 
 /* Returns two 8-bit bytes, less significant bytes first. */
-#define SILC_GET16_LSB(l, cp) \
-       (l) = ((unsigned long)(unsigned char)(cp)[0]) \
-           | ((unsigned long)(unsigned char)(cp)[1] << 8)
-#define SILC_PUT16_LSB(l, cp) \
-       (cp)[0] = l; \
+#define SILC_GET16_LSB(l, cp)                  \
+       (l) = ((uint32)(uint8)(cp)[0])          \
+           | ((uint32)(uint8)(cp)[1] << 8)
+#define SILC_PUT16_LSB(l, cp)                  \
+       (cp)[0] = l;                            \
        (cp)[1] = l >> 8;
 
 #endif