lowlevel-atomic.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* Copyright (C) 2003, 2004, 2008 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library 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. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #ifdef __ASSEMBLER__
  15. #define _IMP1 #1
  16. #define _IMM1 #-1
  17. #define _IMM4 #-4
  18. #define _IMM6 #-6
  19. #define _IMM8 #-8
  20. #define INC(mem, reg) \
  21. .align 2; \
  22. mova 99f, r0; \
  23. mov r15, r1; \
  24. mov _IMM6, r15; \
  25. 98: mov.l mem, reg; \
  26. add _IMP1, reg; \
  27. mov.l reg, mem; \
  28. 99: mov r1, r15
  29. #define DEC(mem, reg) \
  30. .align 2; \
  31. mova 99f, r0; \
  32. mov r15, r1; \
  33. mov _IMM6, r15; \
  34. 98: mov.l mem, reg; \
  35. add _IMM1, reg; \
  36. mov.l reg, mem; \
  37. 99: mov r1, r15
  38. #define XADD(reg, mem, old, tmp) \
  39. .align 2; \
  40. mova 99f, r0; \
  41. nop; \
  42. mov r15, r1; \
  43. mov _IMM8, r15; \
  44. 98: mov.l mem, old; \
  45. mov reg, tmp; \
  46. add old, tmp; \
  47. mov.l tmp, mem; \
  48. 99: mov r1, r15
  49. #define XCHG(reg, mem, old) \
  50. .align 2; \
  51. mova 99f, r0; \
  52. nop; \
  53. mov r15, r1; \
  54. mov _IMM4, r15; \
  55. 98: mov.l mem, old; \
  56. mov.l reg, mem; \
  57. 99: mov r1, r15
  58. #define CMPXCHG(reg, mem, new, old) \
  59. .align 2; \
  60. mova 99f, r0; \
  61. nop; \
  62. mov r15, r1; \
  63. mov _IMM8, r15; \
  64. 98: mov.l mem, old; \
  65. cmp/eq old, reg; \
  66. bf 99f; \
  67. mov.l new, mem; \
  68. 99: mov r1, r15
  69. #endif /* __ASSEMBLER__ */