sysutilp.inc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2003 by Peter Vreman,
  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. var
  15. fpc_system_lock : byte;external name 'fpc_system_lock';
  16. function InterLockedDecrement (var Target: longint) : longint; assembler; nostackframe;
  17. asm
  18. { usually, we shouldn't lock here so saving the stack frame for these extra intructions is
  19. worse the effort, especially while waiting :)
  20. }
  21. .LInterLockedDecrement1:
  22. sethi %hi(fpc_system_lock), %g1
  23. or %g1,%lo(fpc_system_lock), %g1
  24. ldstub [%g1],%g1
  25. cmp %g1,0
  26. bne .LInterLockedDecrement1
  27. nop
  28. ld [%o0],%g1
  29. sub %g1,1,%g1
  30. st %g1,[%o0]
  31. mov %g1,%o0
  32. { unlock }
  33. sethi %hi(fpc_system_lock), %g1
  34. or %g1,%lo(fpc_system_lock), %g1
  35. stb %g0,[%g1]
  36. end;
  37. function InterLockedIncrement (var Target: longint) : longint; assembler; nostackframe;
  38. asm
  39. { usually, we shouldn't lock here so saving the stack frame for these extra intructions is
  40. worse the effort, especially while waiting :)
  41. }
  42. .LInterLockedIncrement1:
  43. sethi %hi(fpc_system_lock), %g1
  44. or %g1,%lo(fpc_system_lock), %g1
  45. ldstub [%g1],%g1
  46. cmp %g1,0
  47. bne .LInterLockedIncrement1
  48. nop
  49. ld [%o0],%g1
  50. add %g1,1,%g1
  51. st %g1,[%o0]
  52. mov %g1,%o0
  53. { unlock }
  54. sethi %hi(fpc_system_lock), %g1
  55. or %g1,%lo(fpc_system_lock), %g1
  56. stb %g0,[%g1]
  57. end;
  58. function InterLockedExchange (var Target: longint;Source : longint) : longint; assembler; nostackframe;
  59. asm
  60. { usually, we shouldn't lock here so saving the stack frame for these extra intructions is
  61. worse the effort, especially while waiting :)
  62. }
  63. .LInterLockedExchange1:
  64. sethi %hi(fpc_system_lock), %g1
  65. or %g1,%lo(fpc_system_lock), %g1
  66. ldstub [%g1],%g1
  67. cmp %g1,0
  68. bne .LInterLockedExchange1
  69. nop
  70. ld [%o0],%g1
  71. st %o1,[%o0]
  72. mov %g1,%o0
  73. { unlock }
  74. sethi %hi(fpc_system_lock), %g1
  75. or %g1,%lo(fpc_system_lock), %g1
  76. stb %g0,[%g1]
  77. end;
  78. function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; assembler; nostackframe;
  79. asm
  80. { usually, we shouldn't lock here so saving the stack frame for these extra intructions is
  81. worse the effort, especially while waiting :)
  82. }
  83. .LInterLockedExchangeAdd1:
  84. sethi %hi(fpc_system_lock), %g1
  85. or %g1,%lo(fpc_system_lock), %g1
  86. ldstub [%g1],%g1
  87. cmp %g1,0
  88. bne .LInterLockedExchangeAdd1
  89. nop
  90. ld [%o0],%g1
  91. add %g1,%o1,%o1
  92. st %o1,[%o0]
  93. mov %g1,%o0
  94. { unlock }
  95. sethi %hi(fpc_system_lock), %g1
  96. or %g1,%lo(fpc_system_lock), %g1
  97. stb %g0,[%g1]
  98. end;