Date: Thu, 14 Oct 2010 01:46:20 +0000 (UTC) From: Jeff Roberson <jeff@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r213819 - projects/ofed/head/sys/ofed/include/linux Message-ID: <201010140146.o9E1kKJ5008374@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jeff Date: Thu Oct 14 01:46:20 2010 New Revision: 213819 URL: http://svn.freebsd.org/changeset/base/213819 Log: - Add implementations of test_and_set and test_and_clear Sponsored by: Isilon Systems, iX Systems, and Panasas. Modified: projects/ofed/head/sys/ofed/include/linux/bitops.h Modified: projects/ofed/head/sys/ofed/include/linux/bitops.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/bitops.h Thu Oct 14 01:45:49 2010 (r213818) +++ projects/ofed/head/sys/ofed/include/linux/bitops.h Thu Oct 14 01:46:20 2010 (r213819) @@ -280,4 +280,30 @@ bitmap_empty(unsigned long *addr, int si #define test_bit(i, a) \ !!(atomic_load_acq_int(&((volatile int *)(a))[(i)/NBINT]) & 1 << ((i) % NBINT)) +static inline long +test_and_clear_bit(long bit, long *var) +{ + long val; + + bit = 1 << bit; + do { + val = *(volatile long *)var; + } while (atomic_cmpset_long(var, val, val & ~bit) == 0); + + return !!(val & bit); +} + +static inline long +test_and_set_bit(long bit, long *var) +{ + long val; + + bit = 1 << bit; + do { + val = *(volatile long *)var; + } while (atomic_cmpset_long(var, val, val | bit) == 0); + + return !!(val & bit); +} + #endif /* _LINUX_BITOPS_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010140146.o9E1kKJ5008374>