sysutilp.inc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2001 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. {$ASMMODE ATT}
  15. function InterLockedDecrement (var Target: longint) : longint; assembler;
  16. asm
  17. {$ifdef REGCALL}
  18. movl $-1,%edx
  19. xchgl %edx,%eax
  20. {$else}
  21. movl Target, %edx
  22. movl $-1, %eax
  23. {$endif}
  24. lock
  25. xaddl %eax, (%edx)
  26. decl %eax
  27. end;
  28. function InterLockedIncrement (var Target: longint) : longint; assembler;
  29. asm
  30. {$ifdef REGCALL}
  31. movl $1,%edx
  32. xchgl %edx,%eax
  33. {$else}
  34. movl Target, %edx
  35. movl $1, %eax
  36. {$endif}
  37. lock
  38. xaddl %eax, (%edx)
  39. incl %eax
  40. end;
  41. function InterLockedExchange (var Target: longint;Source : longint) : longint; assembler;
  42. asm
  43. {$ifdef REGCALL}
  44. xchgl (%eax),%edx
  45. movl %edx,%eax
  46. {$else}
  47. movl Target,%ecx
  48. movl Source,%eax
  49. xchgl (%ecx),%eax
  50. {$endif}
  51. end;
  52. function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; assembler;
  53. asm
  54. {$ifdef REGCALL}
  55. xchgl %eax,%edx
  56. {$else}
  57. movl Target,%edx
  58. movl Source,%eax
  59. {$endif}
  60. lock
  61. xaddl %eax, (%edx)
  62. end;