1 /* Low-level functions for atomic operations. AM33 version.
2 Copyright 1999, 2001 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Alexandre Oliva <aoliva@redhat.com>.
5 Based on ../sparc/sparc32/atomicity.h
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with the GNU C Library. If not, see
19 <http://www.gnu.org/licenses/>. */
22 #define _ATOMICITY_H 1
26 #define __acquire_lock(lock) \
27 __asm__ __volatile__("1: bset %1, (%0)\n\t" \
29 : : "a" (&(lock)), "d" (1) \
32 #define __release_lock(lock) lock = 0
35 __attribute__ ((unused))
36 exchange_and_add (volatile uint32_t *mem, int val)
38 static unsigned char lock;
41 __acquire_lock (lock);
46 __release_lock (lock);
52 __attribute__ ((unused))
53 atomic_add (volatile uint32_t *mem, int val)
55 static unsigned char lock;
57 __acquire_lock (lock);
61 __release_lock (lock);
65 __attribute__ ((unused))
66 compare_and_swap (volatile long int *p, long int oldval, long int newval)
68 static unsigned char lock;
71 __acquire_lock (lock);
81 __release_lock (lock);
86 #endif /* atomicity.h */