lowlevel-atomic.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #ifdef __ASSEMBLER__
  16. #define _IMP1 #1
  17. #define _IMM1 #-1
  18. #define _IMM4 #-4
  19. #define _IMM6 #-6
  20. #define _IMM8 #-8
  21. #define INC(mem, reg) \
  22. .align 2; \
  23. mova 99f, r0; \
  24. mov r15, r1; \
  25. mov _IMM6, r15; \
  26. 98: mov.l mem, reg; \
  27. add _IMP1, reg; \
  28. mov.l reg, mem; \
  29. 99: mov r1, r15
  30. #define DEC(mem, reg) \
  31. .align 2; \
  32. mova 99f, r0; \
  33. mov r15, r1; \
  34. mov _IMM6, r15; \
  35. 98: mov.l mem, reg; \
  36. add _IMM1, reg; \
  37. mov.l reg, mem; \
  38. 99: mov r1, r15
  39. #define XADD(reg, mem, old, tmp) \
  40. .align 2; \
  41. mova 99f, r0; \
  42. nop; \
  43. mov r15, r1; \
  44. mov _IMM8, r15; \
  45. 98: mov.l mem, old; \
  46. mov reg, tmp; \
  47. add old, tmp; \
  48. mov.l tmp, mem; \
  49. 99: mov r1, r15
  50. #define XCHG(reg, mem, old) \
  51. .align 2; \
  52. mova 99f, r0; \
  53. nop; \
  54. mov r15, r1; \
  55. mov _IMM4, r15; \
  56. 98: mov.l mem, old; \
  57. mov.l reg, mem; \
  58. 99: mov r1, r15
  59. #define CMPXCHG(reg, mem, new, old) \
  60. .align 2; \
  61. mova 99f, r0; \
  62. nop; \
  63. mov r15, r1; \
  64. mov _IMM8, r15; \
  65. 98: mov.l mem, old; \
  66. cmp/eq old, reg; \
  67. bf 99f; \
  68. mov.l new, mem; \
  69. 99: mov r1, r15
  70. #endif /* __ASSEMBLER__ */