]>
sourceware.org Git - glibc.git/blob - sysdeps/sparc/sparc32/sparcv9/atomicity.h
1 /* Low-level functions for atomic operations. Sparc32+v9 version.
2 Copyright (C) 1999 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
21 #define _ATOMICITY_H 1
26 __attribute__ ((unused
))
27 exchange_and_add (volatile uint32_t *mem
, int val
)
31 __asm__
__volatile__("1: lduw [%2], %0\n\t"
33 " cas [%2], %0, %1\n\t"
37 : "=&r" (tmp1
), "=&r" (tmp2
)
38 : "r" (mem
), "r" (val
)
44 __attribute__ ((unused
))
45 atomic_add (volatile uint32_t *mem
, int val
)
49 __asm__
__volatile__("1: lduw [%2], %0\n\t"
51 " cas [%2], %0, %1\n\t"
55 : "=&r" (tmp1
), "=&r" (tmp2
)
56 : "r" (mem
), "r" (val
)
61 __attribute__ ((unused
))
62 compare_and_swap (volatile long int *p
, long int oldval
, long int newval
)
64 register long int tmp
, tmp2
;
66 __asm__
__volatile__("1: lduw [%4], %0\n\t"
69 " bne,a,pn %%xcc, 2f\n\t"
71 " cas [%4], %0, %1\n\t"
76 : "=&r" (tmp
), "=&r" (tmp2
)
77 : "r" (newval
), "r" (oldval
), "r" (p
)
82 #endif /* atomicity.h */
This page took 0.038732 seconds and 5 git commands to generate.