From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ItmUw-0007lj-H2 for qemu-devel@nongnu.org; Sun, 18 Nov 2007 10:55:50 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ItmUv-0007jz-M7 for qemu-devel@nongnu.org; Sun, 18 Nov 2007 10:55:50 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ItmUv-0007jm-Hn for qemu-devel@nongnu.org; Sun, 18 Nov 2007 10:55:49 -0500 Received: from honiara.magic.fr ([195.154.193.36]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1ItmUu-0008Ig-RT for qemu-devel@nongnu.org; Sun, 18 Nov 2007 10:55:49 -0500 Received: from [192.168.0.2] (ppp-36.net-123.static.magiconline.fr [80.118.184.36]) by honiara.magic.fr (8.13.1/8.13.1) with ESMTP id lAIFtgDI002387 for ; Sun, 18 Nov 2007 16:55:42 +0100 From: "J. Mayer" Content-Type: multipart/mixed; boundary="=-59eEc5wpYWpicelsG2BE" Date: Sun, 18 Nov 2007 16:55:46 +0100 Message-Id: <1195401346.5335.86.camel@rapid> Mime-Version: 1.0 Subject: [Qemu-devel] [RFC] thunk.c / thunk.h bugfix Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel --=-59eEc5wpYWpicelsG2BE Content-Type: text/plain Content-Transfer-Encoding: 7bit There's a problem in thunk.h as 2 possibly recursive functions are declared as inline. There could be 2 solutions for this. We can never inline those functions and move them to thunk.c (see the attached patch). The drawback is that all cases that do not recurse would be less efficient. The other solution would be to call another intermediary function that would not be inlined to handle the recursive case. The second solution may be better as it would keep the "fast" cases inlined. -- J. Mayer Never organized --=-59eEc5wpYWpicelsG2BE Content-Disposition: attachment; filename=thunk.diff Content-Type: text/x-patch; name=thunk.diff; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Index: thunk.c =================================================================== RCS file: /sources/qemu/qemu/thunk.c,v retrieving revision 1.10 diff -u -d -d -p -r1.10 thunk.c --- thunk.c 11 Nov 2007 19:31:34 -0000 1.10 +++ thunk.c 18 Nov 2007 15:50:56 -0000 @@ -31,7 +31,7 @@ /* XXX: make it dynamic */ StructEntry struct_entries[MAX_STRUCTS]; -static inline const argtype *thunk_type_next(const argtype *type_ptr) +static const argtype *thunk_type_next(const argtype *type_ptr) { int type; @@ -267,3 +267,78 @@ unsigned int host_to_target_bitmask(unsi } return(x86_mask); } + +#ifndef NO_THUNK_TYPE_SIZE +int thunk_type_size(const argtype *type_ptr, int is_host) +{ + int type, size; + const StructEntry *se; + + type = *type_ptr; + switch(type) { + case TYPE_CHAR: + return 1; + case TYPE_SHORT: + return 2; + case TYPE_INT: + return 4; + case TYPE_LONGLONG: + case TYPE_ULONGLONG: + return 8; + case TYPE_LONG: + case TYPE_ULONG: + case TYPE_PTRVOID: + case TYPE_PTR: + if (is_host) { + return HOST_LONG_SIZE; + } else { + return TARGET_ABI_BITS / 8; + } + break; + case TYPE_ARRAY: + size = type_ptr[1]; + return size * thunk_type_size(type_ptr + 2, is_host); + case TYPE_STRUCT: + se = struct_entries + type_ptr[1]; + return se->size[is_host]; + default: + return -1; + } +} + +int thunk_type_align(const argtype *type_ptr, int is_host) +{ + int type; + const StructEntry *se; + + type = *type_ptr; + switch(type) { + case TYPE_CHAR: + return 1; + case TYPE_SHORT: + return 2; + case TYPE_INT: + return 4; + case TYPE_LONGLONG: + case TYPE_ULONGLONG: + return 8; + case TYPE_LONG: + case TYPE_ULONG: + case TYPE_PTRVOID: + case TYPE_PTR: + if (is_host) { + return HOST_LONG_SIZE; + } else { + return TARGET_ABI_BITS / 8; + } + break; + case TYPE_ARRAY: + return thunk_type_align(type_ptr + 2, is_host); + case TYPE_STRUCT: + se = struct_entries + type_ptr[1]; + return se->align[is_host]; + default: + return -1; + } +} +#endif /* ndef NO_THUNK_TYPE_SIZE */ Index: thunk.h =================================================================== RCS file: /sources/qemu/qemu/thunk.h,v retrieving revision 1.15 diff -u -d -d -p -r1.15 thunk.h --- thunk.h 14 Oct 2007 16:27:28 -0000 1.15 +++ thunk.h 18 Nov 2007 15:50:56 -0000 @@ -75,78 +75,8 @@ const argtype *thunk_convert(void *dst, extern StructEntry struct_entries[]; -static inline int thunk_type_size(const argtype *type_ptr, int is_host) -{ - int type, size; - const StructEntry *se; - - type = *type_ptr; - switch(type) { - case TYPE_CHAR: - return 1; - case TYPE_SHORT: - return 2; - case TYPE_INT: - return 4; - case TYPE_LONGLONG: - case TYPE_ULONGLONG: - return 8; - case TYPE_LONG: - case TYPE_ULONG: - case TYPE_PTRVOID: - case TYPE_PTR: - if (is_host) { - return HOST_LONG_SIZE; - } else { - return TARGET_ABI_BITS / 8; - } - break; - case TYPE_ARRAY: - size = type_ptr[1]; - return size * thunk_type_size(type_ptr + 2, is_host); - case TYPE_STRUCT: - se = struct_entries + type_ptr[1]; - return se->size[is_host]; - default: - return -1; - } -} - -static inline int thunk_type_align(const argtype *type_ptr, int is_host) -{ - int type; - const StructEntry *se; - - type = *type_ptr; - switch(type) { - case TYPE_CHAR: - return 1; - case TYPE_SHORT: - return 2; - case TYPE_INT: - return 4; - case TYPE_LONGLONG: - case TYPE_ULONGLONG: - return 8; - case TYPE_LONG: - case TYPE_ULONG: - case TYPE_PTRVOID: - case TYPE_PTR: - if (is_host) { - return HOST_LONG_SIZE; - } else { - return TARGET_ABI_BITS / 8; - } - break; - case TYPE_ARRAY: - return thunk_type_align(type_ptr + 2, is_host); - case TYPE_STRUCT: - se = struct_entries + type_ptr[1]; - return se->align[is_host]; - default: - return -1; - } -} +int thunk_type_size(const argtype *type_ptr, int is_host); +int thunk_type_align(const argtype *type_ptr, int is_host); #endif /* NO_THUNK_TYPE_SIZE */ --=-59eEc5wpYWpicelsG2BE--