mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 09:34:12 +02:00
+ added and implemented functions for locked operations
This commit is contained in:
parent
6cba461f4f
commit
a641af80de
@ -293,11 +293,69 @@ asm
|
|||||||
xor %o0,%g1,%o0
|
xor %o0,%g1,%o0
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
fpc_system_lock : byte;export name 'fpc_system_lock';
|
||||||
|
|
||||||
|
|
||||||
|
{$define FPC_SYSTEM_HAS_DECLOCKED_LONGINT}
|
||||||
|
function declocked(var l : longint) : boolean;assembler;nostackframe;
|
||||||
|
asm
|
||||||
|
{ usually, we shouldn't lock here so saving the stack frame for these extra intructions is
|
||||||
|
worse the effort, especially while waiting :)
|
||||||
|
}
|
||||||
|
.Ldeclocked1:
|
||||||
|
sethi %hi(fpc_system_lock), %g1
|
||||||
|
or %g1,%lo(fpc_system_lock), %g1
|
||||||
|
ldstub [%g1],%g1
|
||||||
|
cmp %g1,0
|
||||||
|
bne .Ldeclocked1
|
||||||
|
nop
|
||||||
|
|
||||||
|
ld [%o0],%g1
|
||||||
|
sub %g1,1,%g1
|
||||||
|
st %g1,[%o0]
|
||||||
|
|
||||||
|
subcc %g1,1,%g0
|
||||||
|
addx %g0,%g0,%o0
|
||||||
|
|
||||||
|
{ unlock }
|
||||||
|
sethi %hi(fpc_system_lock), %g1
|
||||||
|
or %g1,%lo(fpc_system_lock), %g1
|
||||||
|
stb %g0,[%g1]
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{$define FPC_SYSTEM_HAS_INCLOCKED_LONGINT}
|
||||||
|
procedure inclocked(var l : longint);assembler;nostackframe;
|
||||||
|
asm
|
||||||
|
{ usually, we shouldn't lock here so saving the stack frame for these extra intructions is
|
||||||
|
worse the effort, especially while waiting :)
|
||||||
|
}
|
||||||
|
.Linclocked1:
|
||||||
|
sethi %hi(fpc_system_lock), %g1
|
||||||
|
or %g1,%lo(fpc_system_lock), %g1
|
||||||
|
ldstub [%g1],%g1
|
||||||
|
cmp %g1,0
|
||||||
|
bne .Linclocked1
|
||||||
|
nop
|
||||||
|
|
||||||
|
ld [%o0],%g1
|
||||||
|
add %g1,1,%g1
|
||||||
|
st %g1,[%o0]
|
||||||
|
|
||||||
|
{ unlock }
|
||||||
|
sethi %hi(fpc_system_lock), %g1
|
||||||
|
or %g1,%lo(fpc_system_lock), %g1
|
||||||
|
stb %g0,[%g1]
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.12 2004-10-03 12:41:30 florian
|
Revision 1.13 2004-10-14 19:45:39 florian
|
||||||
|
+ added and implemented functions for locked operations
|
||||||
|
|
||||||
|
Revision 1.12 2004/10/03 12:41:30 florian
|
||||||
* made sqrt, sqr and abs internal for the sparc
|
* made sqrt, sqr and abs internal for the sparc
|
||||||
|
|
||||||
Revision 1.11 2004/10/02 20:46:20 florian
|
Revision 1.11 2004/10/02 20:46:20 florian
|
||||||
|
@ -18,85 +18,119 @@
|
|||||||
This include contains cpu-specific routines
|
This include contains cpu-specific routines
|
||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
|
||||||
|
var
|
||||||
|
fpc_system_lock : byte;external name 'fpc_system_lock';
|
||||||
|
|
||||||
function InterLockedDecrement (var Target: longint) : longint; assembler;
|
function InterLockedDecrement (var Target: longint) : longint; assembler;
|
||||||
asm
|
asm
|
||||||
{$warning FIXME}
|
{ usually, we shouldn't lock here so saving the stack frame for these extra intructions is
|
||||||
|
worse the effort, especially while waiting :)
|
||||||
|
}
|
||||||
|
.LInterLockedDecrement1:
|
||||||
|
sethi %hi(fpc_system_lock), %g1
|
||||||
|
or %g1,%lo(fpc_system_lock), %g1
|
||||||
|
ldstub [%g1],%g1
|
||||||
|
cmp %g1,0
|
||||||
|
bne .LInterLockedDecrement1
|
||||||
|
nop
|
||||||
|
|
||||||
|
ld [%o0],%g1
|
||||||
|
sub %g1,1,%g1
|
||||||
|
st %g1,[%o0]
|
||||||
|
|
||||||
|
mov %g1,%o0
|
||||||
|
|
||||||
|
{ unlock }
|
||||||
|
sethi %hi(fpc_system_lock), %g1
|
||||||
|
or %g1,%lo(fpc_system_lock), %g1
|
||||||
|
stb %g0,[%g1]
|
||||||
end;
|
end;
|
||||||
(*
|
|
||||||
{ input: address of target in r3 }
|
function InterLockedIncrement (var Target: longint) : longint; assembler; nostackframe;
|
||||||
{ output: target-1 in r3 }
|
|
||||||
{ side-effect: target := target-1 }
|
|
||||||
asm
|
asm
|
||||||
InterLockedDecLoop:
|
{ usually, we shouldn't lock here so saving the stack frame for these extra intructions is
|
||||||
lwarx r0,r0,r3
|
worse the effort, especially while waiting :)
|
||||||
subi r0,r0,1
|
}
|
||||||
stwcx. r0,r0,r3
|
.LInterLockedIncrement1:
|
||||||
bne InterLockedDecLoop
|
sethi %hi(fpc_system_lock), %g1
|
||||||
mr r3,r0
|
or %g1,%lo(fpc_system_lock), %g1
|
||||||
|
ldstub [%g1],%g1
|
||||||
|
cmp %g1,0
|
||||||
|
bne .LInterLockedIncrement1
|
||||||
|
nop
|
||||||
|
|
||||||
|
ld [%o0],%g1
|
||||||
|
add %g1,1,%g1
|
||||||
|
st %g1,[%o0]
|
||||||
|
|
||||||
|
mov %g1,%o0
|
||||||
|
|
||||||
|
{ unlock }
|
||||||
|
sethi %hi(fpc_system_lock), %g1
|
||||||
|
or %g1,%lo(fpc_system_lock), %g1
|
||||||
|
stb %g0,[%g1]
|
||||||
end;
|
end;
|
||||||
*)
|
|
||||||
|
|
||||||
|
|
||||||
function InterLockedIncrement (var Target: longint) : longint; assembler;
|
function InterLockedExchange (var Target: longint;Source : longint) : longint; assembler; nostackframe;
|
||||||
asm
|
asm
|
||||||
{$warning FIXME}
|
{ usually, we shouldn't lock here so saving the stack frame for these extra intructions is
|
||||||
end;
|
worse the effort, especially while waiting :)
|
||||||
(*
|
}
|
||||||
{ input: address of target in r3 }
|
.LInterLockedExchange1:
|
||||||
{ output: target+1 in r3 }
|
sethi %hi(fpc_system_lock), %g1
|
||||||
{ side-effect: target := target+1 }
|
or %g1,%lo(fpc_system_lock), %g1
|
||||||
asm
|
ldstub [%g1],%g1
|
||||||
InterLockedIncLoop:
|
cmp %g1,0
|
||||||
lwarx r0,r0,r3
|
bne .LInterLockedExchange1
|
||||||
addi r0,r0,1
|
nop
|
||||||
stwcx. r0,r0,r3
|
|
||||||
bne InterLockedIncLoop
|
|
||||||
mr r3,r0
|
|
||||||
end;
|
|
||||||
*)
|
|
||||||
|
|
||||||
function InterLockedExchange (var Target: longint;Source : longint) : longint; assembler;
|
ld [%o0],%g1
|
||||||
asm
|
st %o1,[%o0]
|
||||||
{$warning FIXME}
|
|
||||||
|
mov %g1,%o0
|
||||||
|
|
||||||
|
{ unlock }
|
||||||
|
sethi %hi(fpc_system_lock), %g1
|
||||||
|
or %g1,%lo(fpc_system_lock), %g1
|
||||||
|
stb %g0,[%g1]
|
||||||
end;
|
end;
|
||||||
(*
|
|
||||||
{ input: address of target in r3, source in r4 }
|
|
||||||
{ output: target in r3 }
|
|
||||||
{ side-effect: target := source }
|
|
||||||
asm
|
|
||||||
InterLockedXchgLoop:
|
|
||||||
lwarx r0,r0,r3
|
|
||||||
stwcx. r4,r0,r3
|
|
||||||
bne InterLockedXchgLoop
|
|
||||||
mr r3,r0
|
|
||||||
end;
|
|
||||||
*)
|
|
||||||
|
|
||||||
|
|
||||||
function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; assembler;
|
function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; assembler; nostackframe;
|
||||||
asm
|
asm
|
||||||
{$warning FIXME}
|
{ usually, we shouldn't lock here so saving the stack frame for these extra intructions is
|
||||||
|
worse the effort, especially while waiting :)
|
||||||
|
}
|
||||||
|
.LInterLockedExchangeAdd1:
|
||||||
|
sethi %hi(fpc_system_lock), %g1
|
||||||
|
or %g1,%lo(fpc_system_lock), %g1
|
||||||
|
ldstub [%g1],%g1
|
||||||
|
cmp %g1,0
|
||||||
|
bne .LInterLockedExchangeAdd1
|
||||||
|
nop
|
||||||
|
|
||||||
|
ld [%o0],%g1
|
||||||
|
add %g1,%o1,%o1
|
||||||
|
st %o1,[%o0]
|
||||||
|
|
||||||
|
mov %g1,%o0
|
||||||
|
|
||||||
|
{ unlock }
|
||||||
|
sethi %hi(fpc_system_lock), %g1
|
||||||
|
or %g1,%lo(fpc_system_lock), %g1
|
||||||
|
stb %g0,[%g1]
|
||||||
end;
|
end;
|
||||||
(*
|
|
||||||
{ input: address of target in r3, source in r4 }
|
|
||||||
{ output: target in r3 }
|
|
||||||
{ side-effect: target := target+source }
|
|
||||||
asm
|
|
||||||
InterLockedXchgAddLoop:
|
|
||||||
lwarx r0,r0,r3
|
|
||||||
add r0,r0,r4
|
|
||||||
stwcx. r0,r0,r3
|
|
||||||
bne InterLockedXchgAddLoop
|
|
||||||
sub r3,r0,r4
|
|
||||||
end;
|
|
||||||
*)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.2 2004-03-05 12:17:50 marco
|
Revision 1.3 2004-10-14 19:45:39 florian
|
||||||
|
+ added and implemented functions for locked operations
|
||||||
|
|
||||||
|
Revision 1.2 2004/03/05 12:17:50 marco
|
||||||
* interlocked* changed to longints, including winapi. (which was a bug)
|
* interlocked* changed to longints, including winapi. (which was a bug)
|
||||||
|
|
||||||
Revision 1.1 2003/09/01 20:46:32 peter
|
Revision 1.1 2003/09/01 20:46:32 peter
|
||||||
* new dummies
|
* new dummies
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user