#define CONV_FUNC(name, srctype, dsttype, val) \
static void conv_##name(void *src_ptr, void *dst_ptr, size_t size) \
{ \
- unsigned srctype *srcp = src_ptr; \
- unsigned dsttype *dstp = dst_ptr; \
+ srctype *srcp = src_ptr; \
+ dsttype *dstp = dst_ptr; \
while (size--) { \
- unsigned srctype src = *srcp++; \
+ srctype src = *srcp++; \
*dstp++ = val; \
} \
}
-CONV_FUNC(8_sign, char, char, src ^ 0x80)
-
-CONV_FUNC(8_16, char, short, (unsigned short)src << 8)
-CONV_FUNC(8_16_end, char, short, (unsigned short)src)
-CONV_FUNC(8_16_sign, char, short, (unsigned short)(src ^ 0x80) << 8)
-CONV_FUNC(8_16_sign_end, char, short, (unsigned short)src ^ 0x80)
-
-CONV_FUNC(8_24, char, long, (unsigned long)src << 16)
-CONV_FUNC(8_24_end, char, long, (unsigned long)src << 8)
-CONV_FUNC(8_24_sign, char, long, (unsigned long)(src ^ 0x80) << 16)
-CONV_FUNC(8_24_sign_end, char, long, (unsigned long)(src ^ 0x80) << 8)
-
-CONV_FUNC(8_32, char, long, (unsigned long)src << 24)
-CONV_FUNC(8_32_end, char, long, (unsigned long)src)
-CONV_FUNC(8_32_sign, char, long, (unsigned long)(src ^ 0x80) << 24)
-CONV_FUNC(8_32_sign_end, char, long, (unsigned long)src ^ 0x80)
-
-CONV_FUNC(16_8, short, char, src >> 8)
-CONV_FUNC(16_end_8, short, char, src)
-CONV_FUNC(16_8_sign, short, char, (src >> 8) ^ 0x80)
-CONV_FUNC(16_end_8_sign, short, char, src ^ 0x80)
-
-CONV_FUNC(16_sign, short, short, src ^ 0x8000)
-CONV_FUNC(16_end, short, short, bswap_16(src))
-CONV_FUNC(16_end_sign, short, short, bswap_16(src) ^ 0x8000)
-CONV_FUNC(16_sign_end, short, short, bswap_16(src ^ 0x8000))
-CONV_FUNC(16_end_sign_end, short, short, src ^ 0x80)
-
-CONV_FUNC(16_24, short, long, (unsigned long)src << 8)
-CONV_FUNC(16_24_sign, short, long, (unsigned long)(src ^ 0x8000) << 8)
-CONV_FUNC(16_24_end, short, long, (unsigned long)bswap_16(src) << 8)
-CONV_FUNC(16_24_sign_end, short, long, (unsigned long)bswap_16(src ^ 0x8000) << 8)
-CONV_FUNC(16_end_24, short, long, (unsigned long)bswap_16(src) << 8)
-CONV_FUNC(16_end_24_sign, short, long, (unsigned long)(bswap_16(src) ^ 0x8000) << 8)
-CONV_FUNC(16_end_24_end, short, long, (unsigned long)src << 8)
-CONV_FUNC(16_end_24_sign_end, short, long, ((unsigned long)src ^ 0x80) << 8)
-
-CONV_FUNC(16_32, short, long, (unsigned long)src << 16)
-CONV_FUNC(16_32_sign, short, long, (unsigned long)(src ^ 0x8000) << 16)
-CONV_FUNC(16_32_end, short, long, (unsigned long)bswap_16(src))
-CONV_FUNC(16_32_sign_end, short, long, (unsigned long)bswap_16(src ^ 0x8000))
-CONV_FUNC(16_end_32, short, long, (unsigned long)bswap_16(src) << 16)
-CONV_FUNC(16_end_32_sign, short, long, (unsigned long)(bswap_16(src) ^ 0x8000) << 16)
-CONV_FUNC(16_end_32_end, short, long, (unsigned long)src)
-CONV_FUNC(16_end_32_sign_end, short, long, (unsigned long)src ^ 0x80)
-
-CONV_FUNC(24_8, long, char, src >> 16)
-CONV_FUNC(24_end_8, long, char, src >> 8)
-CONV_FUNC(24_8_sign, long, char, (src >> 16) ^ 0x80)
-CONV_FUNC(24_end_8_sign, long, char, (src >> 8) ^ 0x80)
-
-CONV_FUNC(24_16, long, short, src >> 8)
-CONV_FUNC(24_16_sign, long, short, (src >> 8) ^ 0x8000)
-CONV_FUNC(24_16_end, long, short, bswap_32(src >> 8))
-CONV_FUNC(24_16_sign_end, long, short, bswap_32((src >> 8) ^ 0x8000))
-CONV_FUNC(24_end_16, long, short, bswap_32(src) >> 8)
-CONV_FUNC(24_end_16_sign, long, short, (bswap_32(src) >> 8) ^ 0x8000)
-CONV_FUNC(24_end_16_end, long, short, src >> 8)
-CONV_FUNC(24_end_16_sign_end, long, short, (src >> 8) ^ 0x80)
-
-CONV_FUNC(24_sign, long, long, src ^ 0x800000)
-CONV_FUNC(24_end, long, long, bswap_32(src))
-CONV_FUNC(24_end_sign, long, long, bswap_32(src) ^ 0x800000)
-CONV_FUNC(24_sign_end, long, long, bswap_32(src) ^ 0x80)
-CONV_FUNC(24_end_sign_end, long, long, src ^ 0x80)
-
-CONV_FUNC(24_32, long, long, src << 8)
-CONV_FUNC(24_32_sign, long, long, (src << 8) ^ 0x80000000)
-CONV_FUNC(24_32_end, long, long, bswap_32(src << 8))
-CONV_FUNC(24_32_sign_end, long, long, bswap_32((src << 8) ^ 0x80000000))
-CONV_FUNC(24_end_32, long, long, bswap_32(src) << 8)
-CONV_FUNC(24_end_32_sign, long, long, (bswap_32(src) << 8) ^ 0x80000000)
-CONV_FUNC(24_end_32_end, long, long, src >> 8)
-CONV_FUNC(24_end_32_sign_end, long, long, (src >> 8) ^ 0x80)
-
-CONV_FUNC(32_8, long, char, src >> 24)
-CONV_FUNC(32_end_8, long, char, src)
-CONV_FUNC(32_8_sign, long, char, (src >> 24) ^ 0x80)
-CONV_FUNC(32_end_8_sign, long, char, src ^ 0x80)
-
-CONV_FUNC(32_16, long, short, src >> 16)
-CONV_FUNC(32_16_sign, long, short, (src >> 16) ^ 0x8000)
-CONV_FUNC(32_16_end, long, short, bswap_16(src >> 16))
-CONV_FUNC(32_16_sign_end, long, short, bswap_16((src >> 16) ^ 0x8000))
-CONV_FUNC(32_end_16, long, short, bswap_16(src))
-CONV_FUNC(32_end_16_sign, long, short, bswap_16(src) ^ 0x8000)
-CONV_FUNC(32_end_16_end, long, short, src)
-CONV_FUNC(32_end_16_sign_end, long, short, src ^ 0x80)
-
-CONV_FUNC(32_24, long, long, src >> 8)
-CONV_FUNC(32_24_sign, long, long, (src >> 8) ^ 0x800000)
-CONV_FUNC(32_24_end, long, long, bswap_32(src >> 8))
-CONV_FUNC(32_24_sign_end, long, long, bswap_32((src >> 8) ^ 0x800000))
-CONV_FUNC(32_end_24, long, long, bswap_32(src) >> 8)
-CONV_FUNC(32_end_24_sign, long, long, (bswap_32(src) >> 8) ^ 0x800000)
-CONV_FUNC(32_end_24_end, long, long, src << 8)
-CONV_FUNC(32_end_24_sign_end, long, long, (src << 8) ^ 0x80)
-
-CONV_FUNC(32_sign, long, long, src ^ 0x80000000)
-CONV_FUNC(32_end, long, long, bswap_32(src))
-CONV_FUNC(32_end_sign, long, long, bswap_32(src) ^ 0x80000000)
-CONV_FUNC(32_sign_end, long, long, bswap_32(src) ^ 0x80)
-CONV_FUNC(32_end_sign_end, long, long, src ^ 0x80)
+CONV_FUNC(8_sign, u_int8_t, u_int8_t, src ^ 0x80)
+
+CONV_FUNC(8_16, u_int8_t, u_int16_t, (u_int16_t)src << 8)
+CONV_FUNC(8_16_end, u_int8_t, u_int16_t, (u_int16_t)src)
+CONV_FUNC(8_16_sign, u_int8_t, u_int16_t, (u_int16_t)(src ^ 0x80) << 8)
+CONV_FUNC(8_16_sign_end, u_int8_t, u_int16_t, (u_int16_t)src ^ 0x80)
+
+CONV_FUNC(8_24, u_int8_t, u_int32_t, (u_int32_t)src << 16)
+CONV_FUNC(8_24_end, u_int8_t, u_int32_t, (u_int32_t)src << 8)
+CONV_FUNC(8_24_sign, u_int8_t, u_int32_t, (u_int32_t)(src ^ 0x80) << 16)
+CONV_FUNC(8_24_sign_end, u_int8_t, u_int32_t, (u_int32_t)(src ^ 0x80) << 8)
+
+CONV_FUNC(8_32, u_int8_t, u_int32_t, (u_int32_t)src << 24)
+CONV_FUNC(8_32_end, u_int8_t, u_int32_t, (u_int32_t)src)
+CONV_FUNC(8_32_sign, u_int8_t, u_int32_t, (u_int32_t)(src ^ 0x80) << 24)
+CONV_FUNC(8_32_sign_end, u_int8_t, u_int32_t, (u_int32_t)src ^ 0x80)
+
+CONV_FUNC(16_8, u_int16_t, u_int8_t, src >> 8)
+CONV_FUNC(16_end_8, u_int16_t, u_int8_t, src)
+CONV_FUNC(16_8_sign, u_int16_t, u_int8_t, (src >> 8) ^ 0x80)
+CONV_FUNC(16_end_8_sign, u_int16_t, u_int8_t, src ^ 0x80)
+
+CONV_FUNC(16_sign, u_int16_t, u_int16_t, src ^ 0x8000)
+CONV_FUNC(16_end, u_int16_t, u_int16_t, bswap_16(src))
+CONV_FUNC(16_end_sign, u_int16_t, u_int16_t, bswap_16(src) ^ 0x8000)
+CONV_FUNC(16_sign_end, u_int16_t, u_int16_t, bswap_16(src ^ 0x8000))
+CONV_FUNC(16_end_sign_end, u_int16_t, u_int16_t, src ^ 0x80)
+
+CONV_FUNC(16_24, u_int16_t, u_int32_t, (u_int32_t)src << 8)
+CONV_FUNC(16_24_sign, u_int16_t, u_int32_t, (u_int32_t)(src ^ 0x8000) << 8)
+CONV_FUNC(16_24_end, u_int16_t, u_int32_t, (u_int32_t)bswap_16(src) << 8)
+CONV_FUNC(16_24_sign_end, u_int16_t, u_int32_t, (u_int32_t)bswap_16(src ^ 0x8000) << 8)
+CONV_FUNC(16_end_24, u_int16_t, u_int32_t, (u_int32_t)bswap_16(src) << 8)
+CONV_FUNC(16_end_24_sign, u_int16_t, u_int32_t, (u_int32_t)(bswap_16(src) ^ 0x8000) << 8)
+CONV_FUNC(16_end_24_end, u_int16_t, u_int32_t, (u_int32_t)src << 8)
+CONV_FUNC(16_end_24_sign_end, u_int16_t, u_int32_t, ((u_int32_t)src ^ 0x80) << 8)
+
+CONV_FUNC(16_32, u_int16_t, u_int32_t, (u_int32_t)src << 16)
+CONV_FUNC(16_32_sign, u_int16_t, u_int32_t, (u_int32_t)(src ^ 0x8000) << 16)
+CONV_FUNC(16_32_end, u_int16_t, u_int32_t, (u_int32_t)bswap_16(src))
+CONV_FUNC(16_32_sign_end, u_int16_t, u_int32_t, (u_int32_t)bswap_16(src ^ 0x8000))
+CONV_FUNC(16_end_32, u_int16_t, u_int32_t, (u_int32_t)bswap_16(src) << 16)
+CONV_FUNC(16_end_32_sign, u_int16_t, u_int32_t, (u_int32_t)(bswap_16(src) ^ 0x8000) << 16)
+CONV_FUNC(16_end_32_end, u_int16_t, u_int32_t, (u_int32_t)src)
+CONV_FUNC(16_end_32_sign_end, u_int16_t, u_int32_t, (u_int32_t)src ^ 0x80)
+
+CONV_FUNC(24_8, u_int32_t, u_int8_t, src >> 16)
+CONV_FUNC(24_end_8, u_int32_t, u_int8_t, src >> 8)
+CONV_FUNC(24_8_sign, u_int32_t, u_int8_t, (src >> 16) ^ 0x80)
+CONV_FUNC(24_end_8_sign, u_int32_t, u_int8_t, (src >> 8) ^ 0x80)
+
+CONV_FUNC(24_16, u_int32_t, u_int16_t, src >> 8)
+CONV_FUNC(24_16_sign, u_int32_t, u_int16_t, (src >> 8) ^ 0x8000)
+CONV_FUNC(24_16_end, u_int32_t, u_int16_t, bswap_32(src >> 8))
+CONV_FUNC(24_16_sign_end, u_int32_t, u_int16_t, bswap_32((src >> 8) ^ 0x8000))
+CONV_FUNC(24_end_16, u_int32_t, u_int16_t, bswap_32(src) >> 8)
+CONV_FUNC(24_end_16_sign, u_int32_t, u_int16_t, (bswap_32(src) >> 8) ^ 0x8000)
+CONV_FUNC(24_end_16_end, u_int32_t, u_int16_t, src >> 8)
+CONV_FUNC(24_end_16_sign_end, u_int32_t, u_int16_t, (src >> 8) ^ 0x80)
+
+CONV_FUNC(24_sign, u_int32_t, u_int32_t, src ^ 0x800000)
+CONV_FUNC(24_end, u_int32_t, u_int32_t, bswap_32(src))
+CONV_FUNC(24_end_sign, u_int32_t, u_int32_t, bswap_32(src) ^ 0x800000)
+CONV_FUNC(24_sign_end, u_int32_t, u_int32_t, bswap_32(src) ^ 0x80)
+CONV_FUNC(24_end_sign_end, u_int32_t, u_int32_t, src ^ 0x80)
+
+CONV_FUNC(24_32, u_int32_t, u_int32_t, src << 8)
+CONV_FUNC(24_32_sign, u_int32_t, u_int32_t, (src << 8) ^ 0x80000000)
+CONV_FUNC(24_32_end, u_int32_t, u_int32_t, bswap_32(src << 8))
+CONV_FUNC(24_32_sign_end, u_int32_t, u_int32_t, bswap_32((src << 8) ^ 0x80000000))
+CONV_FUNC(24_end_32, u_int32_t, u_int32_t, bswap_32(src) << 8)
+CONV_FUNC(24_end_32_sign, u_int32_t, u_int32_t, (bswap_32(src) << 8) ^ 0x80000000)
+CONV_FUNC(24_end_32_end, u_int32_t, u_int32_t, src >> 8)
+CONV_FUNC(24_end_32_sign_end, u_int32_t, u_int32_t, (src >> 8) ^ 0x80)
+
+CONV_FUNC(32_8, u_int32_t, u_int8_t, src >> 24)
+CONV_FUNC(32_end_8, u_int32_t, u_int8_t, src)
+CONV_FUNC(32_8_sign, u_int32_t, u_int8_t, (src >> 24) ^ 0x80)
+CONV_FUNC(32_end_8_sign, u_int32_t, u_int8_t, src ^ 0x80)
+
+CONV_FUNC(32_16, u_int32_t, u_int16_t, src >> 16)
+CONV_FUNC(32_16_sign, u_int32_t, u_int16_t, (src >> 16) ^ 0x8000)
+CONV_FUNC(32_16_end, u_int32_t, u_int16_t, bswap_16(src >> 16))
+CONV_FUNC(32_16_sign_end, u_int32_t, u_int16_t, bswap_16((src >> 16) ^ 0x8000))
+CONV_FUNC(32_end_16, u_int32_t, u_int16_t, bswap_16(src))
+CONV_FUNC(32_end_16_sign, u_int32_t, u_int16_t, bswap_16(src) ^ 0x8000)
+CONV_FUNC(32_end_16_end, u_int32_t, u_int16_t, src)
+CONV_FUNC(32_end_16_sign_end, u_int32_t, u_int16_t, src ^ 0x80)
+
+CONV_FUNC(32_24, u_int32_t, u_int32_t, src >> 8)
+CONV_FUNC(32_24_sign, u_int32_t, u_int32_t, (src >> 8) ^ 0x800000)
+CONV_FUNC(32_24_end, u_int32_t, u_int32_t, bswap_32(src >> 8))
+CONV_FUNC(32_24_sign_end, u_int32_t, u_int32_t, bswap_32((src >> 8) ^ 0x800000))
+CONV_FUNC(32_end_24, u_int32_t, u_int32_t, bswap_32(src) >> 8)
+CONV_FUNC(32_end_24_sign, u_int32_t, u_int32_t, (bswap_32(src) >> 8) ^ 0x800000)
+CONV_FUNC(32_end_24_end, u_int32_t, u_int32_t, src << 8)
+CONV_FUNC(32_end_24_sign_end, u_int32_t, u_int32_t, (src << 8) ^ 0x80)
+
+CONV_FUNC(32_sign, u_int32_t, u_int32_t, src ^ 0x80000000)
+CONV_FUNC(32_end, u_int32_t, u_int32_t, bswap_32(src))
+CONV_FUNC(32_end_sign, u_int32_t, u_int32_t, bswap_32(src) ^ 0x80000000)
+CONV_FUNC(32_sign_end, u_int32_t, u_int32_t, bswap_32(src) ^ 0x80)
+CONV_FUNC(32_end_sign_end, u_int32_t, u_int32_t, src ^ 0x80)
/* src_wid dst_wid src_endswap, dst_endswap, sign_swap */
conv_f convert_functions[4 * 4 * 2 * 2 * 2] = {