sysutilp.inc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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.8 2004-03-05 12:17:50 marco
  65. * interlocked* changed to longints, including winapi. (which was a bug)
  66. Revision 1.7 2004/01/04 20:09:36 jonas
  67. * renamed "r0" usages as base register to 0
  68. Revision 1.6 2003/12/28 20:55:57 jonas
  69. * fixed *locked* routines
  70. Revision 1.5 2003/11/29 16:27:19 jonas
  71. * fixed several ppc assembler reader related problems
  72. * local vars in assembler procedures now start at offset 4
  73. * fixed second_int_to_bool (apparently an longint can be in LOC_JUMP??)
  74. Revision 1.4 2003/08/24 20:50:11 olle
  75. * changed used scratchreg from r0 to r10
  76. Revision 1.3 2003/04/24 12:13:23 florian
  77. * fixed assembler errors
  78. Revision 1.2 2002/09/07 16:01:26 peter
  79. * old logs removed and tabs fixed
  80. }