* patches from wiktor

This commit is contained in:
peter 2003-12-15 15:57:48 +00:00
parent 2d7ecc1273
commit d715c6195f
2 changed files with 107 additions and 35 deletions

View File

@ -527,29 +527,78 @@ begin
end; end;
function strcopy(dest,source : pchar) : pchar;assembler; function strcopy(dest,source : pchar) : pchar;assembler;
var
saveeax,saveesi,saveedi : longint;
asm asm
pushl %esi movl %edi,saveedi
pushl %edi movl %esi,saveesi
cld {$ifdef REGCALL}
movl 12(%ebp),%edi movl %eax,saveeax
movl $0xffffffff,%ecx movl %edx,%edi
xorb %al,%al {$else}
repne movl source,%edi
scasb {$endif}
not %ecx testl %edi,%edi
movl 8(%ebp),%edi jz .LStrCopyDone
movl 12(%ebp),%esi leal 3(%edi),%ecx
movl %ecx,%eax andl $-4,%ecx
shrl $2,%ecx movl %edi,%esi
rep subl %edi,%ecx
movsl {$ifdef REGCALL}
movl %eax,%ecx movl %eax,%edi
andl $3,%ecx {$else}
rep movl dest,%edi
movsb {$endif}
movl 8(%ebp),%eax jz .LStrCopyAligned
popl %edi .LStrCopyAlignLoop:
popl %esi movb (%esi),%al
incl %edi
incl %esi
testb %al,%al
movb %al,-1(%edi)
jz .LStrCopyDone
decl %ecx
jnz .LStrCopyAlignLoop
.balign 16
.LStrCopyAligned:
movl (%esi),%eax
movl %eax,%edx
leal 0x0fefefeff(%eax),%ecx
notl %edx
addl $4,%esi
andl %edx,%ecx
andl $0x080808080,%ecx
jnz .LStrCopyEndFound
movl %eax,(%edi)
addl $4,%edi
jmp .LStrCopyAligned
.LStrCopyEndFound:
testl $0x0ff,%eax
jz .LStrCopyByte
testl $0x0ff00,%eax
jz .LStrCopyWord
testl $0x0ff0000,%eax
jz .LStrCopy3Bytes
movl %eax,(%edi)
jmp .LStrCopyDone
.LStrCopy3Bytes:
xorb %dl,%dl
movw %ax,(%edi)
movb %dl,2(%edi)
jmp .LStrCopyDone
.LStrCopyWord:
movw %ax,(%edi)
jmp .LStrCopyDone
.LStrCopyByte:
movb %al,(%edi)
.LStrCopyDone:
{$ifdef REGCALL}
movl saveeax,%eax
{$else}
movl dest,%eax
{$endif}
movl saveedi,%edi
movl saveesi,%esi
end; end;
@ -1442,7 +1491,10 @@ END.
{ {
$Log$ $Log$
Revision 1.8 2003-11-17 19:55:13 hajny Revision 1.9 2003-12-15 15:57:48 peter
* patches from wiktor
Revision 1.8 2003/11/17 19:55:13 hajny
* Wiktor Sywula: LFN detection uncommented in system, new units added * Wiktor Sywula: LFN detection uncommented in system, new units added
Revision 1.7 2003/10/18 09:31:59 hajny Revision 1.7 2003/10/18 09:31:59 hajny

View File

@ -68,9 +68,9 @@ begin
StrDispose(P); StrDispose(P);
end ; end ;
{ Native OpenFile function. { Native OpenFile function.
if return value <> 0 call failed. } if return value <> 0 call failed. }
function OpenFile(const FileName: string; var Handle: longint; Mode, Action: word): longint; function OpenFile(const FileName: string; var Handle: longint; Mode, Action: word): longint;
var var
Regs: registers; Regs: registers;
@ -78,17 +78,34 @@ begin
result := 0; result := 0;
Handle := 0; Handle := 0;
StringToTB(FileName); StringToTB(FileName);
if LFNSupport then Regs.Eax:=$716c if LFNSupport then
else Regs.Eax:=$6c00; Regs.Eax := $716c { Use LFN Open/Create API }
Regs.Edx := Action; { Action if file exists/not exists } else { Check if Extended Open/Create API is safe to use }
Regs.Ds := tb_segment; if lo(dosversion) < 7 then
Regs.Esi := tb_offset; Regs.Eax := $3d00 + (Mode and $ff) { For now, map to Open API }
Regs.Ebx := $2000 + (Mode and $ff); { file open mode } else
Regs.Ecx := $20; { Attributes } Regs.Eax := $6c00; { Use Extended Open/Create API }
if Regs.Ah = $3d then
begin
if (Action and $00f0) <> 0 then
Regs.Eax := $3c00; { Map to Create/Replace API }
Regs.Ds := tb_segment;
Regs.Edx := tb_offset;
end
else { LFN or Extended Open/Create API }
begin
Regs.Edx := Action; { Action if file exists/not exists }
Regs.Ds := tb_segment;
Regs.Esi := tb_offset;
Regs.Ebx := $2000 + (Mode and $ff); { file open mode }
end;
Regs.Ecx := $20; { Attributes }
RealIntr($21, Regs); RealIntr($21, Regs);
if Regs.Flags and CarryFlag <> 0 then result := Regs.Ax if (Regs.Flags and CarryFlag) <> 0 then
else Handle := Regs.Ax; result := Regs.Ax
end ; else
Handle := Regs.Ax;
end;
Function FileOpen (Const FileName : string; Mode : Integer) : Longint; Function FileOpen (Const FileName : string; Mode : Integer) : Longint;
@ -755,7 +772,10 @@ end.
{ {
$Log$ $Log$
Revision 1.2 2003-11-26 20:00:19 florian Revision 1.3 2003-12-15 15:57:49 peter
* patches from wiktor
Revision 1.2 2003/11/26 20:00:19 florian
* error handling for Variants improved * error handling for Variants improved
Revision 1.1 2003/11/17 19:55:13 hajny Revision 1.1 2003/11/17 19:55:13 hajny