OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libgomp/] [config/] [linux/] [ia64/] [futex.h] - Blame information for rev 359

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 273 jeremybenn
/* Copyright (C) 2005, 2008, 2009 Free Software Foundation, Inc.
2
   Contributed by Richard Henderson <rth@redhat.com>.
3
 
4
   This file is part of the GNU OpenMP Library (libgomp).
5
 
6
   Libgomp is free software; you can redistribute it and/or modify it
7
   under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 3, or (at your option)
9
   any later version.
10
 
11
   Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
12
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14
   more details.
15
 
16
   Under Section 7 of GPL version 3, you are granted additional
17
   permissions described in the GCC Runtime Library Exception, version
18
   3.1, as published by the Free Software Foundation.
19
 
20
   You should have received a copy of the GNU General Public License and
21
   a copy of the GCC Runtime Library Exception along with this program;
22
   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23
   <http://www.gnu.org/licenses/>.  */
24
 
25
/* Provide target-specific access to the futex system call.  */
26
 
27
#include <sys/syscall.h>
28
 
29
 
30
 
31
static inline long
32
sys_futex0(int *addr, long op, int val)
33
{
34
  register long out0 asm ("out0") = (long) addr;
35
  register long out1 asm ("out1") = op;
36
  register long out2 asm ("out2") = val;
37
  register long out3 asm ("out3") = 0;
38
  register long r8 asm ("r8");
39
  register long r10 asm ("r10");
40
  register long r15 asm ("r15") = SYS_futex;
41
 
42
  __asm __volatile ("break 0x100000"
43
        : "=r"(r15), "=r"(out0), "=r"(out1), "=r"(out2), "=r"(out3),
44
          "=r"(r8), "=r"(r10)
45
        : "r"(r15), "r"(out0), "r"(out1), "r"(out2), "r"(out3)
46
        : "memory", "out4", "out5", "out6", "out7",
47
          /* Non-stacked integer registers, minus r8, r10, r15.  */
48
          "r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18",
49
          "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27",
50
          "r28", "r29", "r30", "r31",
51
          /* Predicate registers.  */
52
          "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15",
53
          /* Non-rotating fp registers.  */
54
          "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
55
          /* Branch registers.  */
56
          "b6");
57
  return r8 & r10;
58
}
59
 
60
static inline void
61
futex_wait (int *addr, int val)
62
{
63
  long err = sys_futex0 (addr, gomp_futex_wait, val);
64
  if (__builtin_expect (err == ENOSYS, 0))
65
    {
66
      gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
67
      gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
68
      sys_futex0 (addr, gomp_futex_wait, val);
69
    }
70
}
71
 
72
static inline void
73
futex_wake (int *addr, int count)
74
{
75
  long err = sys_futex0 (addr, gomp_futex_wake, count);
76
  if (__builtin_expect (err == ENOSYS, 0))
77
    {
78
      gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
79
      gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
80
      sys_futex0 (addr, gomp_futex_wake, count);
81
    }
82
}
83
 
84
static inline void
85
cpu_relax (void)
86
{
87
  __asm volatile ("hint @pause" : : : "memory");
88
}
89
 
90
static inline void
91
atomic_write_barrier (void)
92
{
93
  __sync_synchronize ();
94
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.