source: trunk/gcc/libjava/sysdep/alpha/locks.h

Last change on this file was 2, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.3 KB
Line 
1// locks.h - Thread synchronization primitives. Alpha implementation.
2
3/* Copyright (C) 2002 Free Software Foundation
4
5 This file is part of libgcj.
6
7This software is copyrighted work licensed under the terms of the
8Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9details. */
10
11#ifndef __SYSDEP_LOCKS_H__
12#define __SYSDEP_LOCKS_H__
13
14typedef size_t obj_addr_t; /* Integer type big enough for object */
15 /* address. */
16
17inline static bool
18compare_and_swap(volatile obj_addr_t *addr,
19 obj_addr_t old,
20 obj_addr_t new_val)
21{
22 unsigned long oldval;
23 char result;
24 __asm__ __volatile__(
25 "1:ldq_l %0, %1\n\t" \
26 "cmpeq %0, %5, %2\n\t" \
27 "beq %2, 2f\n\t" \
28 "mov %3, %0\n\t" \
29 "stq_c %0, %1\n\t" \
30 "bne %0, 2f\n\t" \
31 "br 1b\n\t" \
32 "2:mb"
33 : "=&r"(oldval), "=m"(*addr), "=&r"(result)
34 : "r" (new_val), "m"(*addr), "r"(old) : "memory");
35 return (bool) result;
36}
37
38inline static void
39release_set(volatile obj_addr_t *addr, obj_addr_t new_val)
40{
41 __asm__ __volatile__("mb" : : : "memory");
42 *(addr) = new_val;
43}
44
45inline static bool
46compare_and_swap_release(volatile obj_addr_t *addr,
47 obj_addr_t old,
48 obj_addr_t new_val)
49{
50 return compare_and_swap(addr, old, new_val);
51}
52
53#endif
Note: See TracBrowser for help on using the repository browser.