mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 07:26:24 +02:00
* interlocked methods with smallint parameters, resolves #31158
git-svn-id: trunk@35221 -
This commit is contained in:
parent
be9f055c33
commit
a2838775cc
111
rtl/avr/avr.inc
111
rtl/avr/avr.inc
@ -211,3 +211,114 @@ function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint
|
|||||||
end;
|
end;
|
||||||
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;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user