• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2  ****************************************************************************
3  ***
4  ***   This header was automatically generated from a Linux kernel header
5  ***   of the same name, to make information necessary for userspace to
6  ***   call into the kernel available to libc.  It contains only constants,
7  ***   structures, and macros generated from the original header, and thus,
8  ***   contains no copyrightable information.
9  ***
10  ****************************************************************************
11  ****************************************************************************/
12 #ifndef _ARCH_I386_LOCAL_H
13 #define _ARCH_I386_LOCAL_H
14 
15 #include <linux/percpu.h>
16 #include <asm/system.h>
17 #include <asm/atomic.h>
18 
19 typedef struct
20 {
21  atomic_long_t a;
22 } local_t;
23 
24 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
25 
26 #define local_read(l) atomic_long_read(&(l)->a)
27 #define local_set(l,i) atomic_long_set(&(l)->a, (i))
28 
29 #define local_inc_return(l) (local_add_return(1,l))
30 #define local_dec_return(l) (local_sub_return(1,l))
31 #define local_cmpxchg(l, o, n)   (cmpxchg_local(&((l)->a.counter), (o), (n)))
32 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
33 #define local_add_unless(l, a, u)  ({   long c, old;   c = local_read(l);   for (;;) {   if (unlikely(c == (u)))   break;   old = local_cmpxchg((l), c, c + (a));   if (likely(old == c))   break;   c = old;   }   c != (u);  })
34 #define local_inc_not_zero(l) local_add_unless((l), 1, 0)
35 #define __local_inc(l) local_inc(l)
36 #define __local_dec(l) local_dec(l)
37 #define __local_add(i,l) local_add((i),(l))
38 #define __local_sub(i,l) local_sub((i),(l))
39 #define cpu_local_wrap_v(l)   ({ local_t res__;   preempt_disable();   res__ = (l);   preempt_enable();   res__; })
40 #define cpu_local_wrap(l)   ({ preempt_disable();   l;   preempt_enable(); })
41 #define cpu_local_read(l) cpu_local_wrap_v(local_read(&__get_cpu_var(l)))
42 #define cpu_local_set(l, i) cpu_local_wrap(local_set(&__get_cpu_var(l), (i)))
43 #define cpu_local_inc(l) cpu_local_wrap(local_inc(&__get_cpu_var(l)))
44 #define cpu_local_dec(l) cpu_local_wrap(local_dec(&__get_cpu_var(l)))
45 #define cpu_local_add(i, l) cpu_local_wrap(local_add((i), &__get_cpu_var(l)))
46 #define cpu_local_sub(i, l) cpu_local_wrap(local_sub((i), &__get_cpu_var(l)))
47 #define __cpu_local_inc(l) cpu_local_inc(l)
48 #define __cpu_local_dec(l) cpu_local_dec(l)
49 #define __cpu_local_add(i, l) cpu_local_add((i), (l))
50 #define __cpu_local_sub(i, l) cpu_local_sub((i), (l))
51 #endif
52