]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/mips/atomicity.h
1 /* Low-level functions for atomic operations. Mips version.
2 Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 #ifndef _MIPS_ATOMICITY_H
21 #define _MIPS_ATOMICITY_H 1
27 __attribute__ ((unused
))
28 exchange_and_add (volatile uint32_t *mem
, int val
)
33 ("/* Inline exchange & add */\n"
36 #if _MIPS_SIM == _ABIO32
44 "/* End exchange & add */"
45 : "=&r"(result
), "=&r"(tmp
), "=m"(*mem
)
46 : "m" (*mem
), "r"(val
)
53 __attribute__ ((unused
))
54 atomic_add (volatile uint32_t *mem
, int val
)
59 ("/* Inline atomic add */\n"
62 #if _MIPS_SIM == _ABIO32
70 "/* End atomic add */"
71 : "=&r"(result
), "=m"(*mem
)
72 : "m" (*mem
), "r"(val
)
77 __attribute__ ((unused
))
78 compare_and_swap (volatile long int *p
, long int oldval
, long int newval
)
83 ("/* Inline compare & swap */\n"
86 #if _MIPS_SIM == _ABIO32
89 #if _MIPS_SIM == _ABI64
97 #if _MIPS_SIM == _ABI64
105 "/* End compare & swap */"
106 : "=&r" (ret
), "=&r" (temp
), "=m" (*p
)
107 : "r" (oldval
), "r" (newval
), "m" (*p
)
113 #endif /* atomicity.h */