Author: hselasky Date: Thu Feb 16 12:56:10 2017 New Revision: 313808 URL: https://svnweb.freebsd.org/changeset/base/313808
Log: Implement more LinuxKPI atomic functions and macros. Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/compat/linuxkpi/common/include/asm/atomic-long.h head/sys/compat/linuxkpi/common/include/asm/atomic.h head/sys/compat/linuxkpi/common/include/asm/atomic64.h Modified: head/sys/compat/linuxkpi/common/include/asm/atomic-long.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/asm/atomic-long.h Thu Feb 16 12:20:57 2017 (r313807) +++ head/sys/compat/linuxkpi/common/include/asm/atomic-long.h Thu Feb 16 12:56:10 2017 (r313808) @@ -75,6 +75,12 @@ atomic_long_dec(atomic_long_t *v) return atomic_fetchadd_long(&v->counter, -1) - 1; } +static inline long +atomic_long_xchg(atomic_long_t *v, long val) +{ + return atomic_swap_long(&v->counter, val); +} + static inline int atomic_long_add_unless(atomic_long_t *v, long a, long u) { Modified: head/sys/compat/linuxkpi/common/include/asm/atomic.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/asm/atomic.h Thu Feb 16 12:20:57 2017 (r313807) +++ head/sys/compat/linuxkpi/common/include/asm/atomic.h Thu Feb 16 12:56:10 2017 (r313808) @@ -75,6 +75,12 @@ atomic_set(atomic_t *v, int i) } static inline void +atomic_set_release(atomic_t *v, int i) +{ + atomic_store_rel_int(&v->counter, i); +} + +static inline void atomic_set_mask(unsigned int mask, atomic_t *v) { atomic_set_int(&v->counter, mask); @@ -187,8 +193,26 @@ static inline void atomic_##op(int i, at c = old; \ } +#define LINUX_ATOMIC_FETCH_OP(op, c_op) \ +static inline int atomic_fetch_##op(int i, atomic_t *v) \ +{ \ + int c, old; \ + \ + c = v->counter; \ + while ((old = atomic_cmpxchg(v, c, c c_op i)) != c) \ + c = old; \ + \ + return (c); \ +} + LINUX_ATOMIC_OP(or, |) LINUX_ATOMIC_OP(and, &) +LINUX_ATOMIC_OP(andnot, &~) LINUX_ATOMIC_OP(xor, ^) +LINUX_ATOMIC_FETCH_OP(or, |) +LINUX_ATOMIC_FETCH_OP(and, &) +LINUX_ATOMIC_FETCH_OP(andnot, &~) +LINUX_ATOMIC_FETCH_OP(xor, ^) + #endif /* _ASM_ATOMIC_H_ */ Modified: head/sys/compat/linuxkpi/common/include/asm/atomic64.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/asm/atomic64.h Thu Feb 16 12:20:57 2017 (r313807) +++ head/sys/compat/linuxkpi/common/include/asm/atomic64.h Thu Feb 16 12:56:10 2017 (r313808) @@ -36,6 +36,8 @@ typedef struct { volatile int64_t counter; } atomic64_t; +#define ATOMIC64_INIT(x) { .counter = (x) } + /*------------------------------------------------------------------------* * 64-bit atomic operations *------------------------------------------------------------------------*/ _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"