+2004-03-16 Hosaka Yuji <hos@tamanegi.org>
+
+ * src/types.c: Fix alignment size of X86_WIN32 case int64 and
+ double.
+ * src/x86/ffi.c (ffi_prep_args): Replace ecif->cif->rtype->type
+ with ecif->cif->flags.
+ (ffi_call, ffi_prep_incoming_args_SYSV): Replace cif->rtype->type
+ with cif->flags.
+ (ffi_prep_cif_machdep): Add X86_WIN32 struct case.
+ (ffi_closure_SYSV): Add 1 or 2-bytes struct case for X86_WIN32.
+ * src/x86/win32.S (retstruct1b, retstruct2b, sc_retstruct1b,
+ sc_retstruct2b): Add for 1 or 2-bytes struct case.
+
2004-03-15 Kelley Cook <kcook@gcc.gnu.org>
* configure.in: Rename file to ...
* src/powerpc/darwin.S: Fix EH information so it corresponds to
changes in EH format resulting from addition of linkonce support.
* src/powerpc/darwin_closure.S: Likewise.
-
+
2004-03-11 Andreas Tobler <a.tobler@schweiz.ch>
Paolo Bonzini <bonzini@gnu.org>
#endif
-#if defined X86 || defined X86_WIN32 || defined ARM || defined M68K
+#if defined X86 || defined ARM || defined M68K
FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
#if defined X86 || defined X86_WIN32 || defined M68K
+#ifdef X86_WIN32
+FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
+#else
FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
+#endif
FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
#elif defined ARM || defined SH || defined POWERPC_AIX || defined POWERPC_DARWIN
argp = stack;
- if (ecif->cif->rtype->type == FFI_TYPE_STRUCT)
+ if (ecif->cif->flags == FFI_TYPE_STRUCT)
{
*(void **) argp = ecif->rvalue;
argp += 4;
switch (cif->rtype->type)
{
case FFI_TYPE_VOID:
+#ifndef X86_WIN32
case FFI_TYPE_STRUCT:
+#endif
case FFI_TYPE_SINT64:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
cif->flags = FFI_TYPE_SINT64;
break;
+#ifdef X86_WIN32
+ case FFI_TYPE_STRUCT:
+ if (cif->rtype->size == 1)
+ {
+ cif->flags = FFI_TYPE_SINT8; /* same as char size */
+ }
+ else if (cif->rtype->size == 2)
+ {
+ cif->flags = FFI_TYPE_SINT16; /* same as short size */
+ }
+ else if (cif->rtype->size == 4)
+ {
+ cif->flags = FFI_TYPE_INT; /* same as int type */
+ }
+ else if (cif->rtype->size == 8)
+ {
+ cif->flags = FFI_TYPE_SINT64; /* same as int64 type */
+ }
+ else
+ {
+ cif->flags = FFI_TYPE_STRUCT;
+ }
+ break;
+#endif
+
default:
cif->flags = FFI_TYPE_INT;
break;
/* value address then we need to make one */
if ((rvalue == NULL) &&
- (cif->rtype->type == FFI_TYPE_STRUCT))
+ (cif->flags == FFI_TYPE_STRUCT))
{
/*@-sysunrecog@*/
ecif.rvalue = alloca(cif->rtype->size);
: : "r"(resp)
: "eax", "edx");
}
+#ifdef X86_WIN32
+ else if (rtype == FFI_TYPE_SINT8) /* 1-byte struct */
+ {
+ asm ("movsbl (%0),%%eax" : : "r" (resp) : "eax");
+ }
+ else if (rtype == FFI_TYPE_SINT16) /* 2-bytes struct */
+ {
+ asm ("movswl (%0),%%eax" : : "r" (resp) : "eax");
+ }
+#endif
}
/*@-exportheader@*/
argp = stack;
- if ( cif->rtype->type == FFI_TYPE_STRUCT ) {
+ if ( cif->flags == FFI_TYPE_STRUCT ) {
*rvalue = *(void **) argp;
argp += 4;
}
retint64:
cmpl $FFI_TYPE_SINT64,%ecx
- jne retstruct
+ jne retstruct1b
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movl %eax,0(%ecx)
movl %edx,4(%ecx)
+retstruct1b:
+ cmpl $FFI_TYPE_SINT8,%ecx
+ jne retstruct2b
+ # Load %ecx with the pointer to storage for the return value
+ movl 24(%ebp),%ecx
+ movb %al,0(%ecx)
+ jmp epilogue
+
+retstruct2b:
+ cmpl $FFI_TYPE_SINT16,%ecx
+ jne retstruct
+ # Load %ecx with the pointer to storage for the return value
+ movl 24(%ebp),%ecx
+ movw %ax,0(%ecx)
+ jmp epilogue
+
retstruct:
# Nothing to do!
sc_retint64:
cmpl $FFI_TYPE_SINT64,%ecx
- jne sc_retstruct
+ jne sc_retstruct1b
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movl %eax,0(%ecx)
movl %edx,4(%ecx)
+sc_retstruct1b:
+ cmpl $FFI_TYPE_SINT8,%ecx
+ jne sc_retstruct2b
+ # Load %ecx with the pointer to storage for the return value
+ movl 24(%ebp),%ecx
+ movb %al,0(%ecx)
+ jmp sc_epilogue
+
+sc_retstruct2b:
+ cmpl $FFI_TYPE_SINT16,%ecx
+ jne sc_retstruct
+ # Load %ecx with the pointer to storage for the return value
+ movl 24(%ebp),%ecx
+ movw %ax,0(%ecx)
+ jmp sc_epilogue
+
sc_retstruct:
# Nothing to do!