2017-03-29 06:22:10 +02:00
|
|
|
From 0d14edc19f2112a2d61f835c9664c388cbf14246 Mon Sep 17 00:00:00 2001
|
2011-12-11 03:42:09 +01:00
|
|
|
From: Alexander Graf <agraf@suse.de>
|
2009-08-11 17:37:13 +02:00
|
|
|
Date: Tue, 14 Apr 2009 16:20:50 +0200
|
2012-02-01 00:10:40 +01:00
|
|
|
Subject: [PATCH] qemu-cvs-alsa_bitfield
|
2009-08-11 17:37:13 +02:00
|
|
|
|
|
|
|
Implements TYPE_INTBITFIELD partially. (required for ALSA support)
|
|
|
|
|
2011-12-11 03:42:09 +01:00
|
|
|
Signed-off-by: Alexander Graf <agraf@suse.de>
|
2009-08-11 17:37:13 +02:00
|
|
|
Signed-off-by: Ulrich Hecht <uli@suse.de>
|
|
|
|
---
|
2014-01-17 23:04:30 +01:00
|
|
|
include/exec/user/thunk.h | 3 +++
|
|
|
|
thunk.c | 21 +++++++++++++++++++++
|
|
|
|
2 files changed, 24 insertions(+)
|
2009-08-11 17:37:13 +02:00
|
|
|
|
2013-02-10 19:32:29 +01:00
|
|
|
diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h
|
2017-03-29 06:22:10 +02:00
|
|
|
index f19ef4b..b2659e0 100644
|
2013-02-10 19:32:29 +01:00
|
|
|
--- a/include/exec/user/thunk.h
|
|
|
|
+++ b/include/exec/user/thunk.h
|
2016-04-05 15:18:15 +02:00
|
|
|
@@ -37,6 +37,7 @@ typedef enum argtype {
|
2013-02-10 19:32:29 +01:00
|
|
|
TYPE_ARRAY,
|
|
|
|
TYPE_STRUCT,
|
|
|
|
TYPE_OLDDEVT,
|
|
|
|
+ TYPE_INTBITFIELD,
|
|
|
|
} argtype;
|
|
|
|
|
|
|
|
#define MK_PTR(type) TYPE_PTR, type
|
2016-09-19 19:06:58 +02:00
|
|
|
@@ -89,6 +90,7 @@ static inline int thunk_type_size(const argtype *type_ptr, int is_host)
|
2013-02-10 19:32:29 +01:00
|
|
|
case TYPE_SHORT:
|
|
|
|
return 2;
|
|
|
|
case TYPE_INT:
|
|
|
|
+ case TYPE_INTBITFIELD:
|
|
|
|
return 4;
|
|
|
|
case TYPE_LONGLONG:
|
|
|
|
case TYPE_ULONGLONG:
|
2016-09-19 19:06:58 +02:00
|
|
|
@@ -151,6 +153,7 @@ static inline int thunk_type_align(const argtype *type_ptr, int is_host)
|
2013-02-10 19:32:29 +01:00
|
|
|
case TYPE_SHORT:
|
|
|
|
return 2;
|
|
|
|
case TYPE_INT:
|
|
|
|
+ case TYPE_INTBITFIELD:
|
|
|
|
return 4;
|
|
|
|
case TYPE_LONGLONG:
|
|
|
|
case TYPE_ULONGLONG:
|
2009-08-11 17:37:13 +02:00
|
|
|
diff --git a/thunk.c b/thunk.c
|
2017-03-29 06:22:10 +02:00
|
|
|
index 2dac366..0eb7286 100644
|
2009-08-11 17:37:13 +02:00
|
|
|
--- a/thunk.c
|
|
|
|
+++ b/thunk.c
|
2016-04-05 15:18:15 +02:00
|
|
|
@@ -37,6 +37,7 @@ static inline const argtype *thunk_type_next(const argtype *type_ptr)
|
2007-07-10 18:55:54 +02:00
|
|
|
case TYPE_CHAR:
|
|
|
|
case TYPE_SHORT:
|
|
|
|
case TYPE_INT:
|
|
|
|
+ case TYPE_INTBITFIELD:
|
|
|
|
case TYPE_LONGLONG:
|
|
|
|
case TYPE_ULONGLONG:
|
|
|
|
case TYPE_LONG:
|
2016-04-05 15:18:15 +02:00
|
|
|
@@ -139,6 +140,26 @@ const argtype *thunk_convert(void *dst, const void *src,
|
2007-07-10 18:55:54 +02:00
|
|
|
case TYPE_INT:
|
|
|
|
*(uint32_t *)dst = tswap32(*(uint32_t *)src);
|
|
|
|
break;
|
|
|
|
+ case TYPE_INTBITFIELD:
|
|
|
|
+#if defined(TARGET_I386) && defined(__powerpc__)
|
2011-12-11 03:42:09 +01:00
|
|
|
+ /* powerpc uses the MSB, whereas i386 uses the LSB
|
2007-07-10 18:55:54 +02:00
|
|
|
+ * 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);
|