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 <[EMAIL PROTECTED]>
Never organized
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 */
 

Reply via email to