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