sysutilp.inc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2003 by Peter Vreman,
  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. var
  16. fpc_system_lock : byte;external name 'fpc_system_lock';
  17. function InterLockedDecrement (var Target: longint) : longint; assembler;
  18. asm
  19. { usually, we shouldn't lock here so saving the stack frame for these extra intructions is
  20. worse the effort, especially while waiting :)
  21. }
  22. .LInterLockedDecrement1:
  23. sethi %hi(fpc_system_lock), %g1
  24. or %g1,%lo(fpc_system_lock), %g1
  25. ldstub [%g1],%g1
  26. cmp %g1,0
  27. bne .LInterLockedDecrement1
  28. nop
  29. ld [%o0],%g1
  30. sub %g1,1,%g1
  31. st %g1,[%o0]
  32. mov %g1,%o0
  33. { unlock }
  34. sethi %hi(fpc_system_lock), %g1
  35. or %g1,%lo(fpc_system_lock), %g1
  36. stb %g0,[%g1]
  37. end;
  38. function InterLockedIncrement (var Target: longint) : longint; assembler; nostackframe;
  39. asm
  40. { usually, we shouldn't lock here so saving the stack frame for these extra intructions is
  41. worse the effort, especially while waiting :)
  42. }
  43. .LInterLockedIncrement1:
  44. sethi %hi(fpc_system_lock), %g1
  45. or %g1,%lo(fpc_system_lock), %g1
  46. ldstub [%g1],%g1
  47. cmp %g1,0
  48. bne .LInterLockedIncrement1
  49. nop
  50. ld [%o0],%g1
  51. add %g1,1,%g1
  52. st %g1,[%o0]
  53. mov %g1,%o0
  54. { unlock }
  55. sethi %hi(fpc_system_lock), %g1
  56. or %g1,%lo(fpc_system_lock), %g1
  57. stb %g0,[%g1]
  58. end;
  59. function InterLockedExchange (var Target: longint;Source : longint) : longint; assembler; nostackframe;
  60. asm
  61. { usually, we shouldn't lock here so saving the stack frame for these extra intructions is
  62. worse the effort, especially while waiting :)
  63. }
  64. .LInterLockedExchange1:
  65. sethi %hi(fpc_system_lock), %g1
  66. or %g1,%lo(fpc_system_lock), %g1
  67. ldstub [%g1],%g1
  68. cmp %g1,0
  69. bne .LInterLockedExchange1
  70. nop
  71. ld [%o0],%g1
  72. st %o1,[%o0]
  73. mov %g1,%o0
  74. { unlock }
  75. sethi %hi(fpc_system_lock), %g1
  76. or %g1,%lo(fpc_system_lock), %g1
  77. stb %g0,[%g1]
  78. end;
  79. function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; assembler; nostackframe;
  80. asm
  81. { usually, we shouldn't lock here so saving the stack frame for these extra intructions is
  82. worse the effort, especially while waiting :)
  83. }
  84. .LInterLockedExchangeAdd1:
  85. sethi %hi(fpc_system_lock), %g1
  86. or %g1,%lo(fpc_system_lock), %g1
  87. ldstub [%g1],%g1
  88. cmp %g1,0
  89. bne .LInterLockedExchangeAdd1
  90. nop
  91. ld [%o0],%g1
  92. add %g1,%o1,%o1
  93. st %o1,[%o0]
  94. mov %g1,%o0
  95. { unlock }
  96. sethi %hi(fpc_system_lock), %g1
  97. or %g1,%lo(fpc_system_lock), %g1
  98. stb %g0,[%g1]
  99. end;
  100. {
  101. $Log$
  102. Revision 1.3 2004-10-14 19:45:39 florian
  103. + added and implemented functions for locked operations
  104. Revision 1.2 2004/03/05 12:17:50 marco
  105. * interlocked* changed to longints, including winapi. (which was a bug)
  106. Revision 1.1 2003/09/01 20:46:32 peter
  107. * new dummies
  108. }