Show quoted text 8 lines
I'm working (or trying to) with FPC 1.0.4 + FreeBSD and seeing some
"faults" (?)
with "clone" function. The example in the reference guide don't work and
I didn't
found anything on the web that can help. Does anybody haves another
sample code
or more information about this function ?
The clone function in there is untested and taken from the Linux Threads port. It is provided for experimentation only atm.
If it looks like below, try adding a "pushl %eax" at the given place:
function Clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint; assembler;
asm
pushl %esi
movl 12(%ebp), %esi
subl $4, %esi
movl 20(%ebp), %eax
movl %eax, (%esi)
subl $4, %esi
movl 8(%ebp), %eax
movl %eax, (%esi)
pushl 16(%ebp)
pushl %esi
pushl %eax // <- this one is EXTRA!!!!!!
mov syscall_nr_rfork, %eax
int $0x80
jb .L2
test %edx, %edx
jz .L1
movl %esi,%esp
popl %eax
call %eax
addl $8, %esp
call halt // Does not return
.L2:
mov %eax,ErrNo
mov $-1,%eax
jmp .L1
// jmp PIC_PLT(HIDENAME(cerror))
.L1:
addl $8, %esp
popl %esi
end;