summaryrefslogtreecommitdiff
path: root/thunk.c
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2009-04-14 16:20:50 +0200
committerYury Usishchev <y.usishchev@samsung.com>2014-12-10 13:47:56 +0300
commit8da61f99e2f32d0cdd079bad8a144883269ba0f9 (patch)
tree35f4aaa2ea01135954c025011595f1506b535c4a /thunk.c
parent2148b5f3ec29899660651c7d028fe6da5ce28130 (diff)
downloadqemu-8da61f99e2f32d0cdd079bad8a144883269ba0f9.tar.gz
qemu-8da61f99e2f32d0cdd079bad8a144883269ba0f9.tar.bz2
qemu-8da61f99e2f32d0cdd079bad8a144883269ba0f9.zip
qemu-cvs-alsa_bitfield
Implements TYPE_INTBITFIELD partially. (required for ALSA support) Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Ulrich Hecht <uli@suse.de>
Diffstat (limited to 'thunk.c')
-rw-r--r--thunk.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/thunk.c b/thunk.c
index 3cca04750..c6a78ca96 100644
--- a/thunk.c
+++ b/thunk.c
@@ -41,6 +41,7 @@ static inline const argtype *thunk_type_next(const argtype *type_ptr)
case TYPE_CHAR:
case TYPE_SHORT:
case TYPE_INT:
+ case TYPE_INTBITFIELD:
case TYPE_LONGLONG:
case TYPE_ULONGLONG:
case TYPE_LONG:
@@ -140,6 +141,26 @@ const argtype *thunk_convert(void *dst, const void *src,
case TYPE_INT:
*(uint32_t *)dst = tswap32(*(uint32_t *)src);
break;
+ case TYPE_INTBITFIELD:
+#if defined(TARGET_I386) && defined(__powerpc__)
+ /* powerpc uses the MSB, whereas i386 uses the LSB
+ * to store the first bit in a field */
+ {
+ unsigned char byte = *(uint8_t *)src;
+ *(uint8_t *)dst = ((byte >> 7) & 1)
+ | ((byte >> 5) & 2)
+ | ((byte >> 3) & 4)
+ | ((byte >> 1) & 8)
+ | ((byte << 1) & 16)
+ | ((byte << 3) & 32)
+ | ((byte << 5) & 64)
+ | ((byte << 7) & 128);
+ /* FIXME: implement for bitfields > 1 byte and other archs */
+ }
+#else
+ *(uint32_t *)dst = tswap32(*(uint32_t *)src);
+#endif
+ break;
case TYPE_LONGLONG:
case TYPE_ULONGLONG:
*(uint64_t *)dst = tswap64(*(uint64_t *)src);