* interlocked methods with smallint parameters, resolves #31158

git-svn-id: trunk@35221 -
This commit is contained in:
florian 2016-12-31 19:42:47 +00:00
parent be9f055c33
commit a2838775cc

View File

@ -211,3 +211,114 @@ function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint
end;
end;
function InterLockedDecrement (var Target: smallint) : smallint;
var
temp_sreg : byte;
begin
{ block interrupts }
asm
in r0,0x3f
std temp_sreg,r0
cli
end;
dec(Target);
Result:=Target;
{ release interrupts }
asm
ldd r0,temp_sreg
out 0x3f,r0
end;
end;
function InterLockedIncrement (var Target: smallint) : smallint;
var
temp_sreg : byte;
begin
{ block interrupts }
asm
in r0,0x3f
std temp_sreg,r0
cli
end;
inc(Target);
Result:=Target;
{ release interrupts }
asm
ldd r0,temp_sreg
out 0x3f,r0
end;
end;
function InterLockedExchange (var Target: smallint;Source : smallint) : smallint;
var
temp_sreg : byte;
begin
{ block interrupts }
asm
in r0,0x3f
std temp_sreg,r0
cli
end;
Result:=Target;
Target:=Source;
{ release interrupts }
asm
ldd r0,temp_sreg
out 0x3f,r0
end;
end;
function InterlockedCompareExchange(var Target: smallint; NewValue: smallint; Comperand: smallint): smallint;
var
temp_sreg : byte;
begin
{ block interrupts }
asm
in r0,0x3f
std temp_sreg,r0
cli
end;
Result:=Target;
if Target=Comperand then
Target:=NewValue;
{ release interrupts }
asm
ldd r0,temp_sreg
out 0x3f,r0
end;
end;
function InterLockedExchangeAdd (var Target: smallint;Source : smallint) : smallint;
var
temp_sreg : byte;
begin
{ block interrupts }
asm
in r0,0x3f
std temp_sreg,r0
cli
end;
Result:=Target;
inc(Target,Source);
{ release interrupts }
asm
ldd r0,temp_sreg
out 0x3f,r0
end;
end;