/vendor/gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/alpha.h

http://github.com/feyeleanor/RubyGoLightly · C++ Header · 68 lines · 35 code · 13 blank · 20 comment · 0 complexity · 183e2ab0a58216fe8eef14572ced67ca MD5 · raw file

  1. /*
  2. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  3. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  4. * Copyright (c) 1999-2003 by Hewlett-Packard Company. All rights reserved.
  5. *
  6. *
  7. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  8. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  9. *
  10. * Permission is hereby granted to use or copy this program
  11. * for any purpose, provided the above notices are retained on all copies.
  12. * Permission to modify the code and to distribute modified code is granted,
  13. * provided the above notices are retained, and a notice that the code was
  14. * modified is included with the above copyright notice.
  15. *
  16. */
  17. #include "../atomic_load_store.h"
  18. #include "../test_and_set_t_is_ao_t.h"
  19. #define AO_NO_DD_ORDERING
  20. /* Data dependence does not imply read ordering. */
  21. AO_INLINE void
  22. AO_nop_full()
  23. {
  24. __asm__ __volatile__("mb" : : : "memory");
  25. }
  26. #define AO_HAVE_nop_full
  27. AO_INLINE void
  28. AO_nop_write()
  29. {
  30. __asm__ __volatile__("wmb" : : : "memory");
  31. }
  32. #define AO_HAVE_nop_write
  33. /* mb should be used for AO_nop_read(). That's the default. */
  34. /* We believe that ldq_l ... stq_c does not imply any memory barrier. */
  35. /* We should add an explicit fetch_and_add definition. */
  36. AO_INLINE int
  37. AO_compare_and_swap(volatile AO_t *addr,
  38. AO_t old, AO_t new_val)
  39. {
  40. unsigned long was_equal;
  41. unsigned long temp;
  42. __asm__ __volatile__(
  43. "1: ldq_l %0,%1\n"
  44. " cmpeq %0,%4,%2\n"
  45. " mov %3,%0\n"
  46. " beq %2,2f\n"
  47. " stq_c %0,%1\n"
  48. " beq %0,1b\n"
  49. "2:\n"
  50. :"=&r" (temp), "=m" (*addr), "=&r" (was_equal)
  51. : "r" (new_val), "Ir" (old)
  52. :"memory");
  53. return was_equal;
  54. }
  55. #define AO_HAVE_compare_and_swap