cmpxchg8b_emu.S 957 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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/dwarf2.h>
  10. .text
  11. /*
  12. * Inputs:
  13. * %esi : memory location to compare
  14. * %eax : low 32 bits of old value
  15. * %edx : high 32 bits of old value
  16. * %ebx : low 32 bits of new value
  17. * %ecx : high 32 bits of new value
  18. */
  19. ENTRY(cmpxchg8b_emu)
  20. CFI_STARTPROC
  21. #
  22. # Emulate 'cmpxchg8b (%esi)' on UP except we don't
  23. # set the whole ZF thing (caller will just compare
  24. # eax:edx with the expected value)
  25. #
  26. pushfl_cfi
  27. cli
  28. cmpl (%esi), %eax
  29. jne .Lnot_same
  30. cmpl 4(%esi), %edx
  31. jne .Lhalf_same
  32. movl %ebx, (%esi)
  33. movl %ecx, 4(%esi)
  34. CFI_REMEMBER_STATE
  35. popfl_cfi
  36. ret
  37. CFI_RESTORE_STATE
  38. .Lnot_same:
  39. movl (%esi), %eax
  40. .Lhalf_same:
  41. movl 4(%esi), %edx
  42. popfl_cfi
  43. ret
  44. CFI_ENDPROC
  45. ENDPROC(cmpxchg8b_emu)