1255932Salfred#ifndef _COMPAT_LINUX_ATOMIC_H 2255932Salfred#define _COMPAT_LINUX_ATOMIC_H 1 3255932Salfred 4255932Salfred/* 5255932Salfred#include <linux/version.h> 6255932Salfred 7255932Salfred#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36)) 8255932Salfred#include_next <linux/atomic.h> 9255932Salfred#else 10255932Salfred*/ 11255932Salfred 12255932Salfred#include <asm/atomic.h> 13255932Salfred 14255932Salfred/* Shahar Klein: atomic_inc_not_zero_hint do we need it? */ 15255932Salfred#if 0 16255932Salfred 17255932Salfred/** 18255932Salfred * atomic_inc_not_zero_hint - increment if not null 19255932Salfred * @v: pointer of type atomic_t 20255932Salfred * @hint: probable value of the atomic before the increment 21255932Salfred * 22255932Salfred * This version of atomic_inc_not_zero() gives a hint of probable 23255932Salfred * value of the atomic. This helps processor to not read the memory 24255932Salfred * before doing the atomic read/modify/write cycle, lowering 25255932Salfred * number of bus transactions on some arches. 26255932Salfred * 27255932Salfred * Returns: 0 if increment was not done, 1 otherwise. 28255932Salfred */ 29255932Salfred 30255932Salfred#ifndef atomic_inc_not_zero_hint 31255932Salfredstatic inline int atomic_inc_not_zero_hint(atomic_t *v, int hint) 32255932Salfred{ 33255932Salfred int val, c = hint; 34255932Salfred 35255932Salfred /* sanity test, should be removed by compiler if hint is a constant */ 36255932Salfred if (!hint) 37255932Salfred return atomic_inc_not_zero(v); 38255932Salfred 39255932Salfred do { 40255932Salfred val = atomic_cmpxchg(v, c, c + 1); 41255932Salfred if (val == c) 42255932Salfred return 1; 43255932Salfred c = val; 44255932Salfred } while (c); 45255932Salfred 46255932Salfred return 0; 47255932Salfred} 48255932Salfred#endif 49255932Salfred#endif 50255932Salfred 51255932Salfred//#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36)) */ 52255932Salfred 53255932Salfred#endif /* _COMPAT_LINUX_ATOMIC_H */ 54