[Ecls-list] FFI changes
Goffioul Michael
goffioul at imec.be
Mon Oct 10 07:07:13 UTC 2005
> All code is rather untested and only works on Intel-32 with the GCC
> compiler.
Here's a first trial for MSVC implementation (I'm not a ASM expert at
all, it took me almost 2 hours to produce those few asm statements, please
be comprehensive...):
Index: ../src/c/arch/ffi_x86.d
===================================================================
RCS file: /cvsroot/ecls/ecls/src/c/arch/ffi_x86.d,v
retrieving revision 1.1
diff -u -3 -p -r1.1 ffi_x86.d
--- ../src/c/arch/ffi_x86.d 10 Oct 2005 11:11:48 -0000 1.1
+++ ../src/c/arch/ffi_x86.d 10 Oct 2005 14:01:54 -0000
@@ -54,6 +54,19 @@ ecl_fficall_push_arg(union ecl_ffi_value
void
ecl_fficall_execute(void *f_ptr, struct ecl_fficall *fficall, enum ecl_ffi_tag return_type)
{
+#ifdef _MSC_VER
+ int bufsize = fficall->buffer_size;
+ char* buf = fficall->buffer;
+
+ __asm
+ {
+ sub esp,bufsize
+ mov esi,buf
+ mov edi,esp
+ mov ecx,bufsize
+ rep movsb
+ }
+#else
register char *sp asm("esp");
char *p1, *p2;
int i;
@@ -61,6 +74,7 @@ ecl_fficall_execute(void *f_ptr, struct
for (p1 = sp, p2 = fficall->buffer, i = fficall->buffer_size; i; i--) {
*(p1++) = *(p2++);
}
+#endif
if (return_type <= ECL_FFI_UNSIGNED_LONG) {
fficall->output.i = ((int (*)())f_ptr)();
} else if (return_type == ECL_FFI_POINTER_VOID) {
@@ -76,5 +90,9 @@ ecl_fficall_execute(void *f_ptr, struct
} else {
((void (*)())f_ptr)();
}
+#ifdef _MSC_VER
+ __asm add esp,bufsize
+#else
sp += fficall->buffer_size;
+#endif
}
What do you think?
Michael.
More information about the ecl-devel
mailing list