sysutilp.inc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2004 by Florian Klaempfl
  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. asm
  17. movq %rdi,%rax
  18. movl $-1,%edx
  19. xchgq %rdx,%rax
  20. lock
  21. xaddl %eax, (%rdx)
  22. decl %eax
  23. end;
  24. function InterLockedIncrement (var Target: longint) : longint; assembler;
  25. asm
  26. movq %rdi,%rax
  27. movl $1,%edx
  28. xchgq %rdx,%rax
  29. lock
  30. xaddl %eax, (%rdx)
  31. incl %eax
  32. end;
  33. function InterLockedExchange (var Target: longint;Source : longint) : longint; assembler;
  34. asm
  35. xchgl (%rdi),%esi
  36. movl %esi,%eax
  37. end;
  38. function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; assembler;
  39. asm
  40. xchgq %rdi,%rsi
  41. lock
  42. xaddl %edi, (%rsi)
  43. movl %edi,%eax
  44. end;
  45. {
  46. $Log$
  47. Revision 1.5 2004-11-01 20:37:49 florian
  48. * fixed some x86-64 multithreading stuff
  49. Revision 1.4 2004/11/01 20:31:35 florian
  50. * another fix for locked reference counting
  51. Revision 1.2 2004/03/05 12:17:50 marco
  52. * interlocked* changed to longints, including winapi. (which was a bug)
  53. Revision 1.1 2004/02/20 22:15:16 florian
  54. + x86_64 dependend sysutils part added
  55. * some 64 bit adaptions
  56. }