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

http://github.com/feyeleanor/RubyGoLightly · C++ Header · 46 lines · 12 code · 8 blank · 26 comment · 0 complexity · 5ab1b83f7147e1b8c5fe69035ab428d2 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. /* FIXME. Very incomplete. No support for sparc64. */
  18. /* Non-ancient SPARCs provide compare-and-swap (casa). */
  19. /* We should make that available. */
  20. #include "../all_atomic_load_store.h"
  21. /* Real SPARC code uses TSO: */
  22. #include "../ordered_except_wr.h"
  23. /* Test_and_set location is just a byte. */
  24. #include "../test_and_set_t_is_char.h"
  25. AO_INLINE AO_TS_VAL_t
  26. AO_test_and_set_full(volatile AO_TS_t *addr) {
  27. int oldval;
  28. __asm__ __volatile__("ldstub %1,%0"
  29. : "=r"(oldval), "=m"(*addr)
  30. : "m"(*addr) : "memory");
  31. return oldval;
  32. }
  33. #define AO_HAVE_test_and_set_full
  34. /* FIXME: This needs to be extended for SPARC v8 and v9. */
  35. /* SPARC V8 also has swap. V9 has CAS. */
  36. /* There are barriers like membar #LoadStore. */
  37. /* CASA (32-bit) and CASXA(64-bit) instructions were */
  38. /* added in V9. */