sysutilp.inc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2004 by Florian Klaempfl
  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. asm
  16. movq %rdi,%rax
  17. movl $-1,%edx
  18. xchgq %rdx,%rax
  19. lock
  20. xaddl %eax, (%rdx)
  21. decl %eax
  22. end;
  23. function InterLockedIncrement (var Target: longint) : longint; assembler;
  24. asm
  25. movq %rdi,%rax
  26. movl $1,%edx
  27. xchgq %rdx,%rax
  28. lock
  29. xaddl %eax, (%rdx)
  30. incl %eax
  31. end;
  32. function InterLockedExchange (var Target: longint;Source : longint) : longint; assembler;
  33. asm
  34. xchgl (%rdi),%esi
  35. movl %esi,%eax
  36. end;
  37. function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; assembler;
  38. asm
  39. xchgq %rdi,%rsi
  40. lock
  41. xaddl %edi, (%rsi)
  42. movl %edi,%eax
  43. end;