Fix problem with callbacks
parent
deb51fbd00
commit
c00f89c38b
|
@ -3,7 +3,7 @@ USING: alien alien.c-types alien.syntax compiler kernel
|
||||||
namespaces namespaces tools.test sequences inference words
|
namespaces namespaces tools.test sequences inference words
|
||||||
arrays parser quotations continuations inference.backend effects
|
arrays parser quotations continuations inference.backend effects
|
||||||
namespaces.private io io.streams.string memory system threads
|
namespaces.private io io.streams.string memory system threads
|
||||||
tools.test ;
|
tools.test math ;
|
||||||
|
|
||||||
FUNCTION: void ffi_test_0 ;
|
FUNCTION: void ffi_test_0 ;
|
||||||
[ ] [ ffi_test_0 ] unit-test
|
[ ] [ ffi_test_0 ] unit-test
|
||||||
|
@ -354,3 +354,14 @@ FUNCTION: double ffi_test_36 ( test-struct-12 x ) ;
|
||||||
] alien-callback ;
|
] alien-callback ;
|
||||||
|
|
||||||
[ ] [ callback-8 callback_test_1 ] unit-test
|
[ ] [ callback-8 callback_test_1 ] unit-test
|
||||||
|
|
||||||
|
: callback-9
|
||||||
|
"int" { "int" "int" "int" } "cdecl" [
|
||||||
|
+ + 1+
|
||||||
|
] alien-callback ;
|
||||||
|
|
||||||
|
FUNCTION: int ffi_test_37 ( void* func ) ;
|
||||||
|
|
||||||
|
[ 1 ] [ callback-9 ffi_test_37 ] unit-test
|
||||||
|
|
||||||
|
[ 7 ] [ callback-9 ffi_test_37 ] unit-test
|
||||||
|
|
|
@ -403,7 +403,6 @@ TUPLE: callback-context ;
|
||||||
: generate-callback ( node -- )
|
: generate-callback ( node -- )
|
||||||
dup xt>> dup [
|
dup xt>> dup [
|
||||||
init-templates
|
init-templates
|
||||||
%save-word-xt
|
|
||||||
%prologue-later
|
%prologue-later
|
||||||
dup alien-stack-frame [
|
dup alien-stack-frame [
|
||||||
dup registers>objects
|
dup registers>objects
|
||||||
|
|
|
@ -16,7 +16,6 @@ IN: cpu.x86.32
|
||||||
M: x86.32 ds-reg ESI ;
|
M: x86.32 ds-reg ESI ;
|
||||||
M: x86.32 rs-reg EDI ;
|
M: x86.32 rs-reg EDI ;
|
||||||
M: x86.32 stack-reg ESP ;
|
M: x86.32 stack-reg ESP ;
|
||||||
M: x86.32 xt-reg ECX ;
|
|
||||||
M: x86.32 stack-save-reg EDX ;
|
M: x86.32 stack-save-reg EDX ;
|
||||||
|
|
||||||
M: temp-reg v>operand drop EBX ;
|
M: temp-reg v>operand drop EBX ;
|
||||||
|
|
|
@ -11,7 +11,6 @@ IN: cpu.x86.64
|
||||||
M: x86.64 ds-reg R14 ;
|
M: x86.64 ds-reg R14 ;
|
||||||
M: x86.64 rs-reg R15 ;
|
M: x86.64 rs-reg R15 ;
|
||||||
M: x86.64 stack-reg RSP ;
|
M: x86.64 stack-reg RSP ;
|
||||||
M: x86.64 xt-reg RCX ;
|
|
||||||
M: x86.64 stack-save-reg RSI ;
|
M: x86.64 stack-save-reg RSI ;
|
||||||
|
|
||||||
M: temp-reg v>operand drop RBX ;
|
M: temp-reg v>operand drop RBX ;
|
||||||
|
|
|
@ -9,7 +9,6 @@ IN: cpu.x86.architecture
|
||||||
HOOK: ds-reg cpu
|
HOOK: ds-reg cpu
|
||||||
HOOK: rs-reg cpu
|
HOOK: rs-reg cpu
|
||||||
HOOK: stack-reg cpu
|
HOOK: stack-reg cpu
|
||||||
HOOK: xt-reg cpu
|
|
||||||
HOOK: stack-save-reg cpu
|
HOOK: stack-save-reg cpu
|
||||||
|
|
||||||
: stack@ stack-reg swap [+] ;
|
: stack@ stack-reg swap [+] ;
|
||||||
|
|
|
@ -65,9 +65,7 @@ M: float-regs move-spec drop float ;
|
||||||
M: float-regs operand-class* drop float ;
|
M: float-regs operand-class* drop float ;
|
||||||
|
|
||||||
! Temporary register for stack shuffling
|
! Temporary register for stack shuffling
|
||||||
TUPLE: temp-reg reg-class>> ;
|
SINGLETON: temp-reg
|
||||||
|
|
||||||
: temp-reg T{ temp-reg f int-regs } ;
|
|
||||||
|
|
||||||
M: temp-reg move-spec drop f ;
|
M: temp-reg move-spec drop f ;
|
||||||
|
|
||||||
|
|
|
@ -250,3 +250,13 @@ double ffi_test_36(struct test_struct_12 x)
|
||||||
{
|
{
|
||||||
return x.x;
|
return x.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ffi_test_37(int (*f)(int, int, int))
|
||||||
|
{
|
||||||
|
static int global_var = 0;
|
||||||
|
printf("ffi_test_37\n");
|
||||||
|
global_var = f(global_var,global_var * 2,global_var * 3);
|
||||||
|
printf("global_var is %d\n",global_var);
|
||||||
|
fflush(stdout);
|
||||||
|
return global_var;
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue