thumb_atomics.S 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Copyright (C) 2006 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. In addition to the permissions in the GNU Lesser General Public
  8. License, the Free Software Foundation gives you unlimited
  9. permission to link the compiled version of this file with other
  10. programs, and to distribute those programs without any restriction
  11. coming from the use of this file. (The GNU Lesser General Public
  12. License restrictions do apply in other respects; for example, they
  13. cover modification of the file, and distribution when not linked
  14. into another program.)
  15. Note that people who make modified versions of this file are not
  16. obligated to grant this special exception for their modified
  17. versions; it is their choice whether to do so. The GNU Lesser
  18. General Public License gives permission to release a modified
  19. version without this exception; this exception also makes it
  20. possible to release a modified version which carries forward this
  21. exception.
  22. The GNU C Library is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  25. Lesser General Public License for more details.
  26. You should have received a copy of the GNU Lesser General Public
  27. License along with the GNU C Library; if not, see
  28. <http://www.gnu.org/licenses/>. */
  29. #include <features.h>
  30. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  31. #include <sysdep.h>
  32. #if defined __thumb__
  33. /* Out-of-line atomic operations that we can't do in Thumb mode.
  34. This ends up in various libraries where it is needed (and
  35. a few .a archives where it isn't). */
  36. .hidden __thumb_swpb
  37. ENTRY (__thumb_swpb)
  38. swpb r0, r0, [r1]
  39. bx lr
  40. END (__thumb_swpb)
  41. .hidden __thumb_swp
  42. ENTRY (__thumb_swp)
  43. swp r0, r0, [r1]
  44. bx lr
  45. END (__thumb_swp)
  46. .hidden __thumb_cmpxchg
  47. ENTRY (__thumb_cmpxchg)
  48. stmdb sp!, {r4, lr}
  49. mov r4, r0
  50. 0: ldr r3, [r2]
  51. cmp r3, r4
  52. bne 1f
  53. mov r0, r4
  54. mov r3, #0xffff0fff
  55. mov lr, pc
  56. add pc, r3, #(0xffff0fc0 - 0xffff0fff)
  57. bcc 0b
  58. mov r3, r4
  59. 1: mov r0, r3
  60. ldmia sp!, {r4, pc}
  61. END (__thumb_cmpxchg)
  62. #endif /* __thumb__ */
  63. #endif /* __UCLIBC_HAS_THREADS_NATIVE__ */