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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libc/] [sysdeps/] [linux/] [m68k/] [bits/] [atomicity.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/* Low-level functions for atomic operations.  m680x0 version, x >= 2.
2
   Copyright (C) 1997 Free Software Foundation, Inc.
3
   Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>.
4
   This file is part of the GNU C Library.
5
 
6
   The GNU C Library is free software; you can redistribute it and/or
7
   modify it under the terms of the GNU Lesser General Public
8
   License as published by the Free Software Foundation; either
9
   version 2.1 of the License, or (at your option) any later version.
10
 
11
   The GNU C Library is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
   Lesser General Public License for more details.
15
 
16
   You should have received a copy of the GNU Lesser General Public
17
   License along with the GNU C Library; if not, write to the Free
18
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19
   02111-1307 USA.  */
20
 
21
#ifndef _ATOMICITY_H
22
#define _ATOMICITY_H    1
23
 
24
#include <inttypes.h>
25
 
26
 
27
static inline int
28
__attribute__ ((unused))
29
exchange_and_add (volatile uint32_t *mem, int val)
30
{
31
  register int result = *mem;
32
  register int temp;
33
  __asm__ __volatile__ ("1: move%.l %0,%1;"
34
                        "   add%.l %2,%1;"
35
                        "   cas%.l %0,%1,%3;"
36
                        "   jbne 1b"
37
                        : "=d" (result), "=&d" (temp)
38
                        : "d" (val), "m" (*mem), "0" (result) : "memory");
39
  return result;
40
}
41
 
42
static inline void
43
__attribute__ ((unused))
44
atomic_add (volatile uint32_t *mem, int val)
45
{
46
  /* XXX Use cas here as well?  */
47
  __asm__ __volatile__ ("add%.l %0,%1"
48
                        : : "id" (val), "m" (*mem) : "memory");
49
}
50
 
51
static inline int
52
__attribute__ ((unused))
53
compare_and_swap (volatile long int *p, long int oldval, long int newval)
54
{
55
  char ret;
56
  long int readval;
57
 
58
  __asm__ __volatile__ ("cas%.l %2,%3,%1; seq %0"
59
                        : "=dm" (ret), "=m" (*p), "=d" (readval)
60
                        : "d" (newval), "m" (*p), "2" (oldval));
61
  return ret;
62
}
63
 
64
#endif /* atomicity.h */

powered by: WebSVN 2.1.0

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