PageRenderTime 30ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/js/lock_SunOS.s

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
Assembly | 119 lines | 108 code | 11 blank | 0 comment | 8 complexity | 26af6a398d7424e7db62fb71d0be0cc4 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. !
  2. ! ***** BEGIN LICENSE BLOCK *****
  3. ! Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. !
  5. ! The contents of this file are subject to the Mozilla Public License Version
  6. ! 1.1 (the "License"); you may not use this file except in compliance with
  7. ! the License. You may obtain a copy of the License at
  8. ! http://www.mozilla.org/MPL/
  9. !
  10. ! Software distributed under the License is distributed on an "AS IS" basis,
  11. ! WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. ! for the specific language governing rights and limitations under the
  13. ! License.
  14. !
  15. ! The Original Code is Mozilla Communicator client code, released
  16. ! March 31, 1998.
  17. !
  18. ! The Initial Developer of the Original Code is
  19. ! Netscape Communications Corporation.
  20. ! Portions created by the Initial Developer are Copyright (C) 1998-1999
  21. ! the Initial Developer. All Rights Reserved.
  22. !
  23. ! Contributor(s):
  24. !
  25. ! Alternatively, the contents of this file may be used under the terms of
  26. ! either the GNU General Public License Version 2 or later (the "GPL"), or
  27. ! the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. ! in which case the provisions of the GPL or the LGPL are applicable instead
  29. ! of those above. If you wish to allow use of your version of this file only
  30. ! under the terms of either the GPL or the LGPL, and not to allow others to
  31. ! use your version of this file under the terms of the MPL, indicate your
  32. ! decision by deleting the provisions above and replace them with the notice
  33. ! and other provisions required by the GPL or the LGPL. If you do not delete
  34. ! the provisions above, a recipient may use your version of this file under
  35. ! the terms of any one of the MPL, the GPL or the LGPL.
  36. !
  37. ! ***** END LICENSE BLOCK *****
  38. !
  39. ! atomic compare-and-swap routines for V8 sparc
  40. ! and for V8+ (ultrasparc)
  41. !
  42. !
  43. ! standard asm linkage macros; this module must be compiled
  44. ! with the -P option (use C preprocessor)
  45. #include <sys/asm_linkage.h>
  46. ! ======================================================================
  47. !
  48. ! Perform the sequence *a = b atomically with respect to previous value
  49. ! of a (a0). If *a==a0 then assign *a to b, all in one atomic operation.
  50. ! Returns 1 if assignment happened, and 0 otherwise.
  51. !
  52. ! usage : old_val = compare_and_swap(address, oldval, newval)
  53. !
  54. ! -----------------------
  55. ! Note on REGISTER USAGE:
  56. ! as this is a LEAF procedure, a new stack frame is not created;
  57. ! we use the caller stack frame so what would normally be %i (input)
  58. ! registers are actually %o (output registers). Also, we must not
  59. ! overwrite the contents of %l (local) registers as they are not
  60. ! assumed to be volatile during calls.
  61. !
  62. ! So, the registers used are:
  63. ! %o0 [input] - the address of the value to increment
  64. ! %o1 [input] - the old value to compare with
  65. ! %o2 [input] - the new value to set for [%o0]
  66. ! %o3 [local] - work register
  67. ! -----------------------
  68. #ifndef ULTRA_SPARC
  69. ! v8
  70. ENTRY(compare_and_swap) ! standard assembler/ELF prologue
  71. stbar
  72. mov -1,%o3 ! busy flag
  73. swap [%o0],%o3 ! get current value
  74. l1: cmp %o3,-1 ! busy?
  75. be,a l1 ! if so, spin
  76. swap [%o0],%o3 ! using branch-delay to swap back value
  77. cmp %o1,%o3 ! compare old with current
  78. be,a l2 ! if equal then swap in new value
  79. swap [%o0],%o2 ! done.
  80. swap [%o0],%o3 ! otherwise, swap back current value
  81. retl
  82. mov 0,%o0 ! return false
  83. l2: retl
  84. mov 1,%o0 ! return true
  85. SET_SIZE(compare_and_swap) ! standard assembler/ELF epilogue
  86. !
  87. ! end
  88. !
  89. #else /* ULTRA_SPARC */
  90. ! ======================================================================
  91. !
  92. ! v9
  93. ENTRY(compare_and_swap) ! standard assembler/ELF prologue
  94. stbar
  95. cas [%o0],%o1,%o2 ! compare *w with old value and set to new if equal
  96. cmp %o1,%o2 ! did we succeed?
  97. be,a m1 ! yes
  98. mov 1,%o0 ! return true (annulled when no jump)
  99. mov 0,%o0 ! return false
  100. m1: retl
  101. nop
  102. SET_SIZE(compare_and_swap) ! standard assembler/ELF epilogue
  103. !
  104. ! end
  105. !
  106. ! ======================================================================
  107. !
  108. #endif