Back to index

glibc  2.9
lowlevel-atomic.h
Go to the documentation of this file.
00001 /* Copyright (C) 2003, 2004, 2008 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifdef __ASSEMBLER__
00020 
00021 #define _IMP1 #1
00022 #define _IMM1 #-1
00023 #define _IMM4 #-4
00024 #define _IMM6 #-6
00025 #define _IMM8 #-8
00026 
00027 #define       INC(mem, reg) \
00028        .align 2; \
00029        mova   99f, r0; \
00030        mov    r15, r1; \
00031        mov    _IMM6, r15; \
00032 98:    mov.l  mem, reg; \
00033        add    _IMP1, reg; \
00034        mov.l  reg, mem; \
00035 99:    mov    r1, r15
00036 
00037 #define       DEC(mem, reg) \
00038        .align 2; \
00039        mova   99f, r0; \
00040        mov    r15, r1; \
00041        mov    _IMM6, r15; \
00042 98:    mov.l  mem, reg; \
00043        add    _IMM1, reg; \
00044        mov.l  reg, mem; \
00045 99:    mov    r1, r15
00046 
00047 #define       XADD(reg, mem, old, tmp) \
00048        .align 2; \
00049        mova   99f, r0; \
00050        nop; \
00051        mov    r15, r1; \
00052        mov    _IMM8, r15; \
00053 98:    mov.l  mem, old; \
00054        mov    reg, tmp; \
00055        add    old, tmp; \
00056        mov.l  tmp, mem; \
00057 99:    mov    r1, r15
00058 
00059 #define       XCHG(reg, mem, old) \
00060        .align 2; \
00061        mova   99f, r0; \
00062        nop; \
00063        mov    r15, r1; \
00064        mov    _IMM4, r15; \
00065 98:    mov.l  mem, old; \
00066        mov.l  reg, mem; \
00067 99:    mov    r1, r15
00068 
00069 #define       CMPXCHG(reg, mem, new, old) \
00070        .align 2; \
00071        mova   99f, r0; \
00072        nop; \
00073        mov    r15, r1; \
00074        mov    _IMM8, r15; \
00075 98:    mov.l  mem, old; \
00076        cmp/eq old, reg; \
00077        bf     99f; \
00078        mov.l  new, mem; \
00079 99:    mov    r1, r15
00080 
00081 #endif  /* __ASSEMBLER__ */