Updated to fedora-glibc-20090427T1419
[glibc/history.git] / nptl / sysdeps / unix / sysv / linux / sh / lowlevel-atomic.h
blobc7028360f54cc65c3ec4f5d5e240cb5ee94f7bf2
1 /* Copyright (C) 2003, 2004, 2008 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #ifdef __ASSEMBLER__
21 #define _IMP1 #1
22 #define _IMM1 #-1
23 #define _IMM4 #-4
24 #define _IMM6 #-6
25 #define _IMM8 #-8
27 #define INC(mem, reg) \
28 .align 2; \
29 mova 99f, r0; \
30 mov r15, r1; \
31 mov _IMM6, r15; \
32 98: mov.l mem, reg; \
33 add _IMP1, reg; \
34 mov.l reg, mem; \
35 99: mov r1, r15
37 #define DEC(mem, reg) \
38 .align 2; \
39 mova 99f, r0; \
40 mov r15, r1; \
41 mov _IMM6, r15; \
42 98: mov.l mem, reg; \
43 add _IMM1, reg; \
44 mov.l reg, mem; \
45 99: mov r1, r15
47 #define XADD(reg, mem, old, tmp) \
48 .align 2; \
49 mova 99f, r0; \
50 nop; \
51 mov r15, r1; \
52 mov _IMM8, r15; \
53 98: mov.l mem, old; \
54 mov reg, tmp; \
55 add old, tmp; \
56 mov.l tmp, mem; \
57 99: mov r1, r15
59 #define XCHG(reg, mem, old) \
60 .align 2; \
61 mova 99f, r0; \
62 nop; \
63 mov r15, r1; \
64 mov _IMM4, r15; \
65 98: mov.l mem, old; \
66 mov.l reg, mem; \
67 99: mov r1, r15
69 #define CMPXCHG(reg, mem, new, old) \
70 .align 2; \
71 mova 99f, r0; \
72 nop; \
73 mov r15, r1; \
74 mov _IMM8, r15; \
75 98: mov.l mem, old; \
76 cmp/eq old, reg; \
77 bf 99f; \
78 mov.l new, mem; \
79 99: mov r1, r15
81 #endif /* __ASSEMBLER__ */