m68k.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. /* The cas instruction causes an emulation trap for the */
  18. /* 060 with a misaligned pointer, so let's avoid this. */
  19. #undef AO_t
  20. typedef unsigned long AO_t __attribute__ ((aligned (4)));
  21. /* FIXME. Very incomplete. */
  22. #include "../all_aligned_atomic_load_store.h"
  23. /* Are there any m68k multiprocessors still around? */
  24. /* AFAIK, Alliants were sequentially consistent. */
  25. #include "../ordered.h"
  26. #include "../test_and_set_t_is_char.h"
  27. AO_INLINE AO_TS_VAL_t
  28. AO_test_and_set_full(volatile AO_TS_t *addr) {
  29. AO_TS_t oldval;
  30. /* The value at addr is semi-phony. */
  31. /* 'tas' sets bit 7 while the return */
  32. /* value pretends all bits were set, */
  33. /* which at least matches AO_TS_SET. */
  34. __asm__ __volatile__(
  35. "tas %1; sne %0"
  36. : "=d" (oldval), "=m" (*addr)
  37. : "m" (*addr)
  38. : "memory");
  39. /* This cast works due to the above. */
  40. return (AO_TS_VAL_t)oldval;
  41. }
  42. #define AO_HAVE_test_and_set_full
  43. /* Returns nonzero if the comparison succeeded. */
  44. AO_INLINE int
  45. AO_compare_and_swap_full(volatile AO_t *addr,
  46. AO_t old, AO_t new_val)
  47. {
  48. char result;
  49. __asm__ __volatile__(
  50. "cas.l %3,%4,%1; seq %0"
  51. : "=d" (result), "=m" (*addr)
  52. : "m" (*addr), "d" (old), "d" (new_val)
  53. : "memory");
  54. return -result;
  55. }
  56. #define AO_HAVE_compare_and_swap_full
  57. /* TODO: implement AO_fetch_compare_and_swap. */
  58. #define AO_T_IS_INT