locks.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // locks.h - Thread synchronization primitives. SuperH implementation.
  2. /* Copyright (C) 2002, 2007 Free Software Foundation
  3. This file is part of libgcj.
  4. This software is copyrighted work licensed under the terms of the
  5. Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
  6. details. */
  7. #ifndef __SYSDEP_LOCKS_H__
  8. #define __SYSDEP_LOCKS_H__
  9. typedef size_t obj_addr_t; /* Integer type big enough for object */
  10. /* address. */
  11. inline static bool
  12. compare_and_swap (volatile obj_addr_t *addr, obj_addr_t old,
  13. obj_addr_t new_val)
  14. {
  15. return __sync_bool_compare_and_swap (addr, old, new_val);
  16. }
  17. inline static void
  18. release_set (volatile obj_addr_t *addr, obj_addr_t new_val)
  19. {
  20. __asm__ __volatile__ (" " : : : "memory");
  21. *(addr) = new_val;
  22. }
  23. inline static bool
  24. compare_and_swap_release (volatile obj_addr_t *addr, obj_addr_t old,
  25. obj_addr_t new_val)
  26. {
  27. return compare_and_swap (addr, old, new_val);
  28. }
  29. inline static void
  30. read_barrier()
  31. {
  32. __asm__ __volatile__(" " : : : "memory");
  33. }
  34. inline static void
  35. write_barrier()
  36. {
  37. __asm__ __volatile__(" " : : : "memory");
  38. }
  39. #endif /* ! __SYSDEP_LOCKS_H__ */