1 | // locks.h - Thread synchronization primitives. IA64 implementation.
|
---|
2 |
|
---|
3 | /* Copyright (C) 2002 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,
|
---|
19 | obj_addr_t old,
|
---|
20 | obj_addr_t new_val)
|
---|
21 | {
|
---|
22 | unsigned long oldval;
|
---|
23 | __asm__ __volatile__("mov ar.ccv=%4 ;; cmpxchg8.acq %0=%1,%2,ar.ccv"
|
---|
24 | : "=r"(oldval), "=m"(*addr)
|
---|
25 | : "r"(new_val), "1"(*addr), "r"(old) : "memory");
|
---|
26 | return (oldval == old);
|
---|
27 | }
|
---|
28 |
|
---|
29 | // The fact that *addr is volatile should cause the compiler to
|
---|
30 | // automatically generate an st8.rel.
|
---|
31 | inline static void
|
---|
32 | release_set(volatile obj_addr_t *addr, obj_addr_t new_val)
|
---|
33 | {
|
---|
34 | __asm__ __volatile__(" " : : : "memory");
|
---|
35 | *(addr) = new_val;
|
---|
36 | }
|
---|
37 |
|
---|
38 | inline static bool
|
---|
39 | compare_and_swap_release(volatile obj_addr_t *addr,
|
---|
40 | obj_addr_t old,
|
---|
41 | obj_addr_t new_val)
|
---|
42 | {
|
---|
43 | unsigned long oldval;
|
---|
44 | __asm__ __volatile__("mov ar.ccv=%4 ;; cmpxchg8.rel %0=%1,%2,ar.ccv"
|
---|
45 | : "=r"(oldval), "=m"(*addr)
|
---|
46 | : "r"(new_val), "1"(*addr), "r"(old) : "memory");
|
---|
47 | return (oldval == old);
|
---|
48 | }
|
---|
49 |
|
---|
50 | #endif
|
---|