1951a39d68df598db08dfced8b4707755864a0492Ying Wang/**************************************************************************** 2951a39d68df598db08dfced8b4707755864a0492Ying Wang **************************************************************************** 3951a39d68df598db08dfced8b4707755864a0492Ying Wang *** 4951a39d68df598db08dfced8b4707755864a0492Ying Wang *** This header was automatically generated from a Linux kernel header 5951a39d68df598db08dfced8b4707755864a0492Ying Wang *** of the same name, to make information necessary for userspace to 6951a39d68df598db08dfced8b4707755864a0492Ying Wang *** call into the kernel available to libc. It contains only constants, 7951a39d68df598db08dfced8b4707755864a0492Ying Wang *** structures, and macros generated from the original header, and thus, 8951a39d68df598db08dfced8b4707755864a0492Ying Wang *** contains no copyrightable information. 9951a39d68df598db08dfced8b4707755864a0492Ying Wang *** 10951a39d68df598db08dfced8b4707755864a0492Ying Wang **************************************************************************** 11951a39d68df598db08dfced8b4707755864a0492Ying Wang ****************************************************************************/ 12951a39d68df598db08dfced8b4707755864a0492Ying Wang#ifndef _ASM_GENERIC_LOCAL_H 13951a39d68df598db08dfced8b4707755864a0492Ying Wang#define _ASM_GENERIC_LOCAL_H 14951a39d68df598db08dfced8b4707755864a0492Ying Wang 15951a39d68df598db08dfced8b4707755864a0492Ying Wang#include <linux/percpu.h> 16951a39d68df598db08dfced8b4707755864a0492Ying Wang#include <linux/hardirq.h> 17951a39d68df598db08dfced8b4707755864a0492Ying Wang#include <asm/atomic.h> 18951a39d68df598db08dfced8b4707755864a0492Ying Wang#include <asm/types.h> 19951a39d68df598db08dfced8b4707755864a0492Ying Wang 20951a39d68df598db08dfced8b4707755864a0492Ying Wangtypedef struct 21951a39d68df598db08dfced8b4707755864a0492Ying Wang{ 22951a39d68df598db08dfced8b4707755864a0492Ying Wang atomic_long_t a; 23951a39d68df598db08dfced8b4707755864a0492Ying Wang} local_t; 24951a39d68df598db08dfced8b4707755864a0492Ying Wang 25951a39d68df598db08dfced8b4707755864a0492Ying Wang#define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) } 26951a39d68df598db08dfced8b4707755864a0492Ying Wang 27951a39d68df598db08dfced8b4707755864a0492Ying Wang#define local_read(l) atomic_long_read(&(l)->a) 28951a39d68df598db08dfced8b4707755864a0492Ying Wang#define local_set(l,i) atomic_long_set((&(l)->a),(i)) 29951a39d68df598db08dfced8b4707755864a0492Ying Wang#define local_inc(l) atomic_long_inc(&(l)->a) 30951a39d68df598db08dfced8b4707755864a0492Ying Wang#define local_dec(l) atomic_long_dec(&(l)->a) 31951a39d68df598db08dfced8b4707755864a0492Ying Wang#define local_add(i,l) atomic_long_add((i),(&(l)->a)) 32951a39d68df598db08dfced8b4707755864a0492Ying Wang#define local_sub(i,l) atomic_long_sub((i),(&(l)->a)) 33951a39d68df598db08dfced8b4707755864a0492Ying Wang 34951a39d68df598db08dfced8b4707755864a0492Ying Wang#define __local_inc(l) local_set((l), local_read(l) + 1) 35951a39d68df598db08dfced8b4707755864a0492Ying Wang#define __local_dec(l) local_set((l), local_read(l) - 1) 36951a39d68df598db08dfced8b4707755864a0492Ying Wang#define __local_add(i,l) local_set((l), local_read(l) + (i)) 37951a39d68df598db08dfced8b4707755864a0492Ying Wang#define __local_sub(i,l) local_set((l), local_read(l) - (i)) 38951a39d68df598db08dfced8b4707755864a0492Ying Wang 39951a39d68df598db08dfced8b4707755864a0492Ying Wang#define cpu_local_read(v) local_read(&__get_cpu_var(v)) 40951a39d68df598db08dfced8b4707755864a0492Ying Wang#define cpu_local_set(v, i) local_set(&__get_cpu_var(v), (i)) 41951a39d68df598db08dfced8b4707755864a0492Ying Wang#define cpu_local_inc(v) local_inc(&__get_cpu_var(v)) 42951a39d68df598db08dfced8b4707755864a0492Ying Wang#define cpu_local_dec(v) local_dec(&__get_cpu_var(v)) 43951a39d68df598db08dfced8b4707755864a0492Ying Wang#define cpu_local_add(i, v) local_add((i), &__get_cpu_var(v)) 44951a39d68df598db08dfced8b4707755864a0492Ying Wang#define cpu_local_sub(i, v) local_sub((i), &__get_cpu_var(v)) 45951a39d68df598db08dfced8b4707755864a0492Ying Wang 46951a39d68df598db08dfced8b4707755864a0492Ying Wang#define __cpu_local_inc(v) __local_inc(&__get_cpu_var(v)) 47951a39d68df598db08dfced8b4707755864a0492Ying Wang#define __cpu_local_dec(v) __local_dec(&__get_cpu_var(v)) 48951a39d68df598db08dfced8b4707755864a0492Ying Wang#define __cpu_local_add(i, v) __local_add((i), &__get_cpu_var(v)) 49951a39d68df598db08dfced8b4707755864a0492Ying Wang#define __cpu_local_sub(i, v) __local_sub((i), &__get_cpu_var(v)) 50951a39d68df598db08dfced8b4707755864a0492Ying Wang 51951a39d68df598db08dfced8b4707755864a0492Ying Wang#endif 52