ia64.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. /*
  23. * This file specifies Itanimum primitives for use with the HP compiler
  24. * under HP/UX. We use intrinsics instead of the inline assembly code in the
  25. * gcc file.
  26. */
  27. #include "../all_atomic_load_store.h"
  28. #include "../all_acquire_release_volatile.h"
  29. #include "../test_and_set_t_is_char.h"
  30. #include <machine/sys/inline.h>
  31. #ifdef __LP64__
  32. # define AO_T_FASIZE _FASZ_D
  33. # define AO_T_SIZE _SZ_D
  34. #else
  35. # define AO_T_FASIZE _FASZ_W
  36. # define AO_T_SIZE _SZ_W
  37. #endif
  38. AO_INLINE void
  39. AO_nop_full(void)
  40. {
  41. _Asm_mf();
  42. }
  43. #define AO_HAVE_nop_full
  44. #ifndef AO_PREFER_GENERALIZED
  45. AO_INLINE AO_t
  46. AO_fetch_and_add1_acquire (volatile AO_t *p)
  47. {
  48. return _Asm_fetchadd(AO_T_FASIZE, _SEM_ACQ, p, 1,
  49. _LDHINT_NONE, _DOWN_MEM_FENCE);
  50. }
  51. #define AO_HAVE_fetch_and_add1_acquire
  52. AO_INLINE AO_t
  53. AO_fetch_and_add1_release (volatile AO_t *p)
  54. {
  55. return _Asm_fetchadd(AO_T_FASIZE, _SEM_REL, p, 1,
  56. _LDHINT_NONE, _UP_MEM_FENCE);
  57. }
  58. #define AO_HAVE_fetch_and_add1_release
  59. AO_INLINE AO_t
  60. AO_fetch_and_sub1_acquire (volatile AO_t *p)
  61. {
  62. return _Asm_fetchadd(AO_T_FASIZE, _SEM_ACQ, p, -1,
  63. _LDHINT_NONE, _DOWN_MEM_FENCE);
  64. }
  65. #define AO_HAVE_fetch_and_sub1_acquire
  66. AO_INLINE AO_t
  67. AO_fetch_and_sub1_release (volatile AO_t *p)
  68. {
  69. return _Asm_fetchadd(AO_T_FASIZE, _SEM_REL, p, -1,
  70. _LDHINT_NONE, _UP_MEM_FENCE);
  71. }
  72. #define AO_HAVE_fetch_and_sub1_release
  73. #endif /* !AO_PREFER_GENERALIZED */
  74. AO_INLINE AO_t
  75. AO_fetch_compare_and_swap_acquire(volatile AO_t *addr, AO_t old_val,
  76. AO_t new_val)
  77. {
  78. _Asm_mov_to_ar(_AREG_CCV, old_val, _DOWN_MEM_FENCE);
  79. return _Asm_cmpxchg(AO_T_SIZE, _SEM_ACQ, addr,
  80. new_val, _LDHINT_NONE, _DOWN_MEM_FENCE);
  81. }
  82. #define AO_HAVE_fetch_compare_and_swap_acquire
  83. AO_INLINE AO_t
  84. AO_fetch_compare_and_swap_release(volatile AO_t *addr, AO_t old_val,
  85. AO_t new_val)
  86. {
  87. _Asm_mov_to_ar(_AREG_CCV, old_val, _UP_MEM_FENCE);
  88. return _Asm_cmpxchg(AO_T_SIZE, _SEM_REL, addr,
  89. new_val, _LDHINT_NONE, _UP_MEM_FENCE);
  90. }
  91. #define AO_HAVE_fetch_compare_and_swap_release
  92. AO_INLINE unsigned char
  93. AO_char_fetch_compare_and_swap_acquire(volatile unsigned char *addr,
  94. unsigned char old_val, unsigned char new_val)
  95. {
  96. _Asm_mov_to_ar(_AREG_CCV, old_val, _DOWN_MEM_FENCE);
  97. return _Asm_cmpxchg(_SZ_B, _SEM_ACQ, addr,
  98. new_val, _LDHINT_NONE, _DOWN_MEM_FENCE);
  99. }
  100. #define AO_HAVE_char_fetch_compare_and_swap_acquire
  101. AO_INLINE unsigned char
  102. AO_char_fetch_compare_and_swap_release(volatile unsigned char *addr,
  103. unsigned char old_val, unsigned char new_val)
  104. {
  105. _Asm_mov_to_ar(_AREG_CCV, old_val, _UP_MEM_FENCE);
  106. return _Asm_cmpxchg(_SZ_B, _SEM_REL, addr,
  107. new_val, _LDHINT_NONE, _UP_MEM_FENCE);
  108. }
  109. #define AO_HAVE_char_fetch_compare_and_swap_release
  110. AO_INLINE unsigned short
  111. AO_short_fetch_compare_and_swap_acquire(volatile unsigned short *addr,
  112. unsigned short old_val,
  113. unsigned short new_val)
  114. {
  115. _Asm_mov_to_ar(_AREG_CCV, old_val, _DOWN_MEM_FENCE);
  116. return _Asm_cmpxchg(_SZ_B, _SEM_ACQ, addr,
  117. new_val, _LDHINT_NONE, _DOWN_MEM_FENCE);
  118. }
  119. #define AO_HAVE_short_fetch_compare_and_swap_acquire
  120. AO_INLINE unsigned short
  121. AO_short_fetch_compare_and_swap_release(volatile unsigned short *addr,
  122. unsigned short old_val,
  123. unsigned short new_val)
  124. {
  125. _Asm_mov_to_ar(_AREG_CCV, old_val, _UP_MEM_FENCE);
  126. return _Asm_cmpxchg(_SZ_B, _SEM_REL, addr,
  127. new_val, _LDHINT_NONE, _UP_MEM_FENCE);
  128. }
  129. #define AO_HAVE_short_fetch_compare_and_swap_release
  130. #ifndef __LP64__
  131. # define AO_T_IS_INT
  132. #endif