sysutilp.inc 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2001 by Jonas Maebe,
  4. member of the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. { ---------------------------------------------------------------------
  12. This include contains cpu-specific routines
  13. ---------------------------------------------------------------------}
  14. function InterLockedDecrement (var Target: longint) : longint; assembler;
  15. { input: address of target in r3 }
  16. { output: target-1 in r3 }
  17. { side-effect: target := target-1 }
  18. asm
  19. .LInterLockedDecLoop:
  20. lwarx r10,0,r3
  21. subi r10,r10,1
  22. stwcx. r10,0,r3
  23. bne .LInterLockedDecLoop
  24. mr r3,r10
  25. end;
  26. function InterLockedIncrement (var Target: longint) : longint; assembler;
  27. { input: address of target in r3 }
  28. { output: target+1 in r3 }
  29. { side-effect: target := target+1 }
  30. asm
  31. .LInterLockedIncLoop:
  32. lwarx r10,0,r3
  33. addi r10,r10,1
  34. stwcx. r10,0,r3
  35. bne .LInterLockedIncLoop
  36. mr r3,r10
  37. end;
  38. function InterLockedExchange (var Target: longint;Source : longint) : longint; assembler;
  39. { input: address of target in r3, source in r4 }
  40. { output: target in r3 }
  41. { side-effect: target := source }
  42. asm
  43. .LInterLockedXchgLoop:
  44. lwarx r10,0,r3
  45. stwcx. r4,0,r3
  46. bne .LInterLockedXchgLoop
  47. mr r3,r10
  48. end;
  49. function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; assembler;
  50. { input: address of target in r3, source in r4 }
  51. { output: target in r3 }
  52. { side-effect: target := target+source }
  53. asm
  54. .LInterLockedXchgAddLoop:
  55. lwarx r10,0,r3
  56. add r10,r10,r4
  57. stwcx. r10,0,r3
  58. bne .LInterLockedXchgAddLoop
  59. sub r3,r10,r4
  60. end;