2
0

sysutilp.inc 2.2 KB

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