]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/i386/i486/atomicity.h
98a2531365f3c984033d7c3616f133ef105ed386
1 /* Low-level functions for atomitc operations. ix86 version, x >= 4.
2 Copyright (C) 1997 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
27 __attribute__ ((unused
))
28 exchange_and_add (volatile uint32_t *mem
, int val
)
31 __asm__
__volatile__ ("lock; xaddl %0,%1"
32 : "=r" (result
) : "0" (val
), "m" (*mem
) : "memory");
37 __attribute__ ((unused
))
38 atomic_add (volatile uint32_t *mem
, int val
)
40 __asm__
__volatile__ ("lock; addl %0,%1"
41 : : "ir" (val
), "m" (*mem
) : "memory");
45 __attribute__ ((unused
))
46 compare_and_swap (volatile long int *p
, long int oldval
, long int newval
)
51 __asm__
__volatile__ ("lock; cmpxchgl %3, %1; sete %0"
52 : "=q" (ret
), "=m" (*p
), "=a" (readval
)
53 : "r" (newval
), "m" (*p
), "a" (oldval
));
57 #endif /* atomicity.h */