Skip to content

Commit b35d4b6

Browse files
author
alexrayne
committed
*fpc: package use FPC native builtins
1 parent 9708af5 commit b35d4b6

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

Source/DECUtil.pas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ implementation
266266
$27, $A7, $67, $E7, $17, $97, $57, $D7, $37, $B7, $77, $F7, $0F, $8F,
267267
$4F, $CF, $2F, $AF, $6F, $EF, $1F, $9F, $5F, $DF, $3F, $BF, $7F, $FF);
268268

269+
{$ifdef FPC}
270+
{$include fpc\DECUtil.inc}
271+
{$endif}
269272

270273
{$ifdef X64ASM}
271274
{$include x86_64\DECUtil.inc}

Source/fpc/DECUtil.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
{$define SwapUInt32_asm}
3+
function SwapUInt32(Source: UInt32): UInt32;
4+
begin
5+
result := SwapEndian(Source);
6+
end;
7+
8+
{$define SwapInt64_asm}
9+
function SwapInt64(Source: Int64): Int64;
10+
begin
11+
result := SwapEndian(Source);
12+
end;
13+
14+

Source/fpc/dec.lpk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@
130130
<Filename Value="..\x86_64\DECUtil.inc"/>
131131
<Type Value="Include"/>
132132
</Item>
133+
<Item>
134+
<Filename Value="DECUtil.inc"/>
135+
<Type Value="Include"/>
136+
</Item>
133137
</Files>
134138
<RequiredPkgs>
135139
<Item>

Source/x86/DECUtil.inc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22
{$ASMMODE intel}
33
{$endif}
44

5+
{$ifndef SwapUInt32_asm}
56
{$define SwapUInt32_asm}
67
function SwapUInt32(Source: UInt32): UInt32;
78
asm
89
BSWAP EAX
910
end;
11+
{$endif}
1012

11-
{$define SwapUInt64_asm}
13+
{$ifndef SwapInt64_asm}
14+
{$define SwapInt64_asm}
1215
function SwapInt64(Source: Int64): Int64;
1316
asm
1417
MOV EDX,Source.DWord[0]
1518
MOV EAX,Source.DWord[4]
1619
BSWAP EDX
1720
BSWAP EAX
1821
end;
22+
{$endif}
23+

Source/x86_64/DECUtil.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@
22
{$ASMMODE intel}
33
{$endif}
44

5+
{$ifndef SwapUInt32_asm}
56
{$define SwapUInt32_asm}
67
function SwapUInt32(Source: UInt32): UInt32;
78
asm
89
MOV RAX, Source
910
BSWAP RAX
1011
SHR RAX, 32
1112
end;
13+
{$endif}
1214

15+
{$ifndef SwapInt64_asm}
1316
{$define SwapInt64_asm}
1417
function SwapInt64(Source: Int64): Int64;
1518
asm
1619
MOV RAX, Source
1720
BSWAP RAX
1821
end;
22+
{$endif}
23+
24+

0 commit comments

Comments
 (0)