ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/vendor/libpeak-0.1.2/peak/arch/m68k/atomic.h
Revision: 3251
Committed: Wed Apr 2 16:58:30 2014 UTC (11 years, 4 months ago) by michael
Content type: text/x-chdr
File size: 1035 byte(s)
Log Message:
- Imported libpeak-0.1.2

File Contents

# Content
1 /* PEAK Library
2 * peak/arch/m68k/atomic.h. Generated from atomic.h.in by configure.
3 *
4 * Motorola 68k atomic operations
5 *
6 * $Id: atomic.h.in,v 1.1 2007/05/24 12:54:09 mbuna Exp $
7 */
8 #ifndef INCLUDED_PEAK_ATOMIC_H_
9 #define INCLUDED_PEAK_ATOMIC_H_
10
11 typedef struct { volatile int counter; } peak_atomic_t;
12
13 #define PEAK_ATOMIC_INIT(i) { (i) }
14
15 #define peak_atomic_read(v) ((v)->counter)
16 #define peak_atomic_set(v,i) (((v)->counter) = (i))
17
18 static __inline__ void peak_atomic_add(int a, peak_atomic_t *v)
19 {
20 __asm__ __volatile__("addl %1,%0" : "=m" (*v) : "id" (a), "0" (*v));
21 }
22
23 static __inline__ void peak_atomic_sub(int a, peak_atomic_t *v)
24 {
25 __asm__ __volatile__("subl %1,%0" : "=m" (*v) : "id" (a), "0" (*v));
26 }
27
28 static __inline__ void peak_atomic_inc(peak_atomic_t *v)
29 {
30 __asm__ __volatile__("addql #1,%0" : "=m" (*v): "0" (*v));
31 }
32
33 static __inline__ void peak_atomic_dec(peak_atomic_t *v)
34 {
35 __asm__ __volatile__("subql #1,%0" : "=m" (*v): "0" (*v));
36 }
37
38 #endif /* INCLUDED_PEAK_ATOMIC_H_ */