ia64/linux-2.6.18-xen.hg

view include/asm-generic/atomic.h @ 782:9ab1c319531f

merge with linux-2.6.18-xen.hg
author Isaku Yamahata <yamahata@valinux.co.jp>
date Wed Jan 28 13:07:23 2009 +0900 (2009-01-28)
parents 831230e53067
children
line source
1 #ifndef _ASM_GENERIC_ATOMIC_H
2 #define _ASM_GENERIC_ATOMIC_H
3 /*
4 * Copyright (C) 2005 Silicon Graphics, Inc.
5 * Christoph Lameter <clameter@sgi.com>
6 *
7 * Allows to provide arch independent atomic definitions without the need to
8 * edit all arch specific atomic.h files.
9 */
11 #include <asm/types.h>
13 /*
14 * Suppport for atomic_long_t
15 *
16 * Casts for parameters are avoided for existing atomic functions in order to
17 * avoid issues with cast-as-lval under gcc 4.x and other limitations that the
18 * macros of a platform may have.
19 */
21 #if BITS_PER_LONG == 64
23 typedef atomic64_t atomic_long_t;
25 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
27 static inline long atomic_long_read(atomic_long_t *l)
28 {
29 atomic64_t *v = (atomic64_t *)l;
31 return (long)atomic64_read(v);
32 }
34 static inline void atomic_long_set(atomic_long_t *l, long i)
35 {
36 atomic64_t *v = (atomic64_t *)l;
38 atomic64_set(v, i);
39 }
41 static inline void atomic_long_inc(atomic_long_t *l)
42 {
43 atomic64_t *v = (atomic64_t *)l;
45 atomic64_inc(v);
46 }
48 static inline void atomic_long_dec(atomic_long_t *l)
49 {
50 atomic64_t *v = (atomic64_t *)l;
52 atomic64_dec(v);
53 }
55 static inline void atomic_long_add(long i, atomic_long_t *l)
56 {
57 atomic64_t *v = (atomic64_t *)l;
59 atomic64_add(i, v);
60 }
62 static inline void atomic_long_sub(long i, atomic_long_t *l)
63 {
64 atomic64_t *v = (atomic64_t *)l;
66 atomic64_sub(i, v);
67 }
69 #else
71 typedef atomic_t atomic_long_t;
73 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
74 static inline long atomic_long_read(atomic_long_t *l)
75 {
76 atomic_t *v = (atomic_t *)l;
78 return (long)atomic_read(v);
79 }
81 static inline void atomic_long_set(atomic_long_t *l, long i)
82 {
83 atomic_t *v = (atomic_t *)l;
85 atomic_set(v, i);
86 }
88 static inline void atomic_long_inc(atomic_long_t *l)
89 {
90 atomic_t *v = (atomic_t *)l;
92 atomic_inc(v);
93 }
95 static inline void atomic_long_dec(atomic_long_t *l)
96 {
97 atomic_t *v = (atomic_t *)l;
99 atomic_dec(v);
100 }
102 static inline void atomic_long_add(long i, atomic_long_t *l)
103 {
104 atomic_t *v = (atomic_t *)l;
106 atomic_add(i, v);
107 }
109 static inline void atomic_long_sub(long i, atomic_long_t *l)
110 {
111 atomic_t *v = (atomic_t *)l;
113 atomic_sub(i, v);
114 }
116 #endif
117 #endif