diff options
Diffstat (limited to 'sys/compat/linuxkpi/common/include/asm/atomic-long.h')
-rw-r--r-- | sys/compat/linuxkpi/common/include/asm/atomic-long.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sys/compat/linuxkpi/common/include/asm/atomic-long.h b/sys/compat/linuxkpi/common/include/asm/atomic-long.h index c80c348f95f9..db3a94c539e5 100644 --- a/sys/compat/linuxkpi/common/include/asm/atomic-long.h +++ b/sys/compat/linuxkpi/common/include/asm/atomic-long.h @@ -25,11 +25,9 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ */ -#ifndef _ATOMIC_LONG_H_ -#define _ATOMIC_LONG_H_ +#ifndef _LINUXKPI_ASM_ATOMIC_LONG_H_ +#define _LINUXKPI_ASM_ATOMIC_LONG_H_ #include <linux/compiler.h> #include <sys/types.h> @@ -41,7 +39,7 @@ typedef struct { } atomic_long_t; #define atomic_long_add(i, v) atomic_long_add_return((i), (v)) -#define atomic_long_sub(i, v) atomic_long_add_return(-(i), (v)) +#define atomic_long_sub(i, v) atomic_long_sub_return((i), (v)) #define atomic_long_inc_return(v) atomic_long_add_return(1, (v)) #define atomic_long_inc_not_zero(v) atomic_long_add_unless((v), 1, 0) @@ -51,6 +49,12 @@ atomic_long_add_return(long i, atomic_long_t *v) return i + atomic_fetchadd_long(&v->counter, i); } +static inline long +atomic_long_sub_return(long i, atomic_long_t *v) +{ + return atomic_fetchadd_long(&v->counter, -i) - i; +} + static inline void atomic_long_set(atomic_long_t *v, long i) { @@ -130,4 +134,4 @@ atomic_long_dec_and_test(atomic_long_t *v) return i == 0 ; } -#endif /* _ATOMIC_LONG_H_ */ +#endif /* _LINUXKPI_ASM_ATOMIC_LONG_H_ */ |