* patch from Christopher Key (via Alonso Cardenas Marquez) to fix mmap

syscall.  Recent versions of FreeBSD check the seventh parameter, and
    that code wasn't correct in FPC.

git-svn-id: trunk@15785 -
This commit is contained in:
marco 2010-08-12 10:56:31 +00:00
parent 8e8a573707
commit c59973d149
3 changed files with 6 additions and 49 deletions

View File

@ -94,7 +94,7 @@ Function Fpmmap(start:pointer;len:size_t;prot:cint;flags:cint;fd:cint;offst:off_
begin
{$ifdef CPU64}
Fpmmap:=pointer(ptruint(do__syscall(TSysParam(syscall_nr_mmap),TSysParam(Start),TSysParam(Len),TSysParam(Prot),TSysParam(Flags),TSysParam(fd),TSysParam(offst),0,0)));
Fpmmap:=pointer(ptruint(do_syscall(TSysParam(syscall_nr_mmap),TSysParam(Start),TSysParam(Len),TSysParam(Prot),TSysParam(Flags),TSysParam(fd),0,TSysParam(offst))));
{$else}
Fpmmap:=pointer(ptruint(do_syscall(syscall_nr_mmap,TSysParam(Start),Len,Prot,Flags,fd,
{$ifdef FPC_BIG_ENDIAN} hi(offst),lo(offst){$endif}

View File

@ -219,7 +219,6 @@ asm
.LSyscOK:
end;
function fpsysCall(sysnr,param1,param2,param3,param4,param5,param6 : TSysParam):TSysResult; assembler;[public,alias:'FPC_DOSYS6'];
asm
@ -232,7 +231,6 @@ asm
movq param6,%r9
syscall { Do the system call. }
jnb .LSyscOK { branch to exit if ok, errorhandler otherwise}
movq %rax,%rdx
{$ifdef FPC_PIC}
movq fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
@ -257,50 +255,11 @@ asm
.LSyscOK:
end;
// edi esi edx ecx r8 r9 stack
function fp_sysCall(sysnr,param1,param2,param3,param4,param5,param6 : TSysParam):TSysResult; assembler;[public,alias:'FPC__DOSYS'];
function fp_sysCall(sysnr,param1,param2,param3,param4,param5,param6,param7 : TSysParam):TSysResult; assembler;[public,alias:'FPC_DOSYS7'];
asm
movq sysnr,%rax { Syscall number -> rax. }
movq param1,%rdi { shift arg1 - arg6. }
movq param2,%rsi
movq param3,%rdx
movq param4,%r10
movq param5,%r8
movq param6,%r9
syscall { Do the system call. }
jnb .LSyscOK { branch to exit if ok, errorhandler otherwise}
movq %rax,%rdx
{$ifdef FPC_PIC}
movq fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
movq (%rax),%rax
movq Errno@GOTPCREL(%rip),%r11
{$else FPC_PIC}
movq fpc_threadvar_relocate_proc,%rax
leaq Errno,%r11
{$endif FPC_PIC}
testq %rax,%rax
jne .LThread
movl %edx,8(%r11)
jmp .LNoThread
.LThread:
pushq %rdx
movq (%r11),%rdi
call *%rax
popq %rdx
movl %edx,(%rax)
.LNoThread:
movq $-1,%rax
.LSyscOK:
add $0x18,%rsp
end;
// edi esi edx ecx r8 r9 stack stack
function fp_sysCall(sysnr,param1,param2,param3,param4,param5,param6,param7 : TSysParam):TSysResult; assembler;[public,alias:'FPC__DOSYS7'];
asm
sub $0x10,%rsp
subq $0x10,%rsp
movq sysnr,%rax { Syscall number -> rax. }
movq param1,%rdi { shift arg1 - arg6. }
movq param2,%rsi
@ -309,7 +268,7 @@ asm
movq param5,%r8
movq param6,%r9
movq param7,%r11
movq %r11,(%rsp)
movq %r11,8(%rsp)
syscall { Do the system call. }
jnb .LSyscOK { branch to exit if ok, errorhandler otherwise}
movq %rax,%rdx
@ -334,6 +293,6 @@ asm
.LNoThread:
movq $-1,%rax
.LSyscOK:
add $0x10,%rsp
addq $0x10,%rsp
end;

View File

@ -41,7 +41,5 @@ function do_sysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResu
function do_sysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):int64; external name 'FPC_DOSYS6';
function do_sysCall(sysnr,param1,param2,param3,param4,param5,param6,param7:TSysParam):int64; external name 'FPC_DOSYS7';
// special
function do__sysCall(sysnr,param1,param2,param3,param4,param5,param6,param7,Param8:TSysParam):TSysResult; external name 'FPC__DOSYS';
{$endif}