types.c: Fix alignment size of X86_WIN32 case int64 and double.

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.

From-SVN: r79542
This commit is contained in:
Hosaka Yuji 2004-03-16 19:17:33 +00:00 committed by Andreas Tobler
parent cd9b76514e
commit 09cababc5f
4 changed files with 93 additions and 7 deletions

View File

@ -1,3 +1,16 @@
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 ...
@ -12,7 +25,7 @@
* 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>

View File

@ -53,7 +53,7 @@ FFI_INTEGRAL_TYPEDEF(pointer, 4, 4, FFI_TYPE_POINTER);
#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);
@ -73,7 +73,11 @@ FFI_INTEGRAL_TYPEDEF(sint64, 8, 8, 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

View File

@ -47,7 +47,7 @@ void ffi_prep_args(char *stack, extended_cif *ecif)
argp = stack;
if (ecif->cif->rtype->type == FFI_TYPE_STRUCT)
if (ecif->cif->flags == FFI_TYPE_STRUCT)
{
*(void **) argp = ecif->rvalue;
argp += 4;
@ -121,7 +121,9 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
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:
@ -133,6 +135,31 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
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;
@ -177,7 +204,7 @@ void ffi_call(/*@dependent@*/ ffi_cif *cif,
/* 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);
@ -274,6 +301,16 @@ ffi_closure_SYSV (closure)
: : "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@*/
@ -289,7 +326,7 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
argp = stack;
if ( cif->rtype->type == FFI_TYPE_STRUCT ) {
if ( cif->flags == FFI_TYPE_STRUCT ) {
*rvalue = *(void **) argp;
argp += 4;
}

View File

@ -114,12 +114,28 @@ retlongdouble:
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!
@ -209,12 +225,28 @@ sc_retlongdouble:
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!