cmpxchg8b_emu.S 972 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License
  4. * as published by the Free Software Foundation; version 2
  5. * of the License.
  6. *
  7. */
  8. #include <linux/linkage.h>
  9. #include <asm/alternative-asm.h>
  10. #include <asm/frame.h>
  11. #include <asm/dwarf2.h>
  12. .text
  13. /*
  14. * Inputs:
  15. * %esi : memory location to compare
  16. * %eax : low 32 bits of old value
  17. * %edx : high 32 bits of old value
  18. * %ebx : low 32 bits of new value
  19. * %ecx : high 32 bits of new value
  20. */
  21. ENTRY(cmpxchg8b_emu)
  22. CFI_STARTPROC
  23. #
  24. # Emulate 'cmpxchg8b (%esi)' on UP except we don't
  25. # set the whole ZF thing (caller will just compare
  26. # eax:edx with the expected value)
  27. #
  28. cmpxchg8b_emu:
  29. pushfl
  30. cli
  31. cmpl (%esi), %eax
  32. jne not_same
  33. cmpl 4(%esi), %edx
  34. jne half_same
  35. movl %ebx, (%esi)
  36. movl %ecx, 4(%esi)
  37. popfl
  38. ret
  39. not_same:
  40. movl (%esi), %eax
  41. half_same:
  42. movl 4(%esi), %edx
  43. popfl
  44. ret
  45. CFI_ENDPROC
  46. ENDPROC(cmpxchg8b_emu)