Re: [PATCH v3 06/13] epoll: introduce helpers for adding/removing events to uring

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 16, 2019 at 10:58:03AM +0200, Roman Penyaev wrote:
> +#define atomic_set_unless_zero(ptr, flags)			\
> +({								\
> +	typeof(ptr) _ptr = (ptr);				\
> +	typeof(flags) _flags = (flags);				\
> +	typeof(*_ptr) _old, _val = READ_ONCE(*_ptr);		\
> +								\
> +	for (;;) {						\
> +		if (!_val)					\
> +			break;					\
> +		_old = cmpxchg(_ptr, _val, _flags);		\
> +		if (_old == _val)				\
> +			break;					\
> +		_val = _old;					\
> +	}							\
> +	_val;							\
> +})

> +#define atomic_or_with_mask(ptr, flags, mask)			\
> +({								\
> +	typeof(ptr) _ptr = (ptr);				\
> +	typeof(flags) _flags = (flags);				\
> +	typeof(flags) _mask = (mask);				\
> +	typeof(*_ptr) _old, _new, _val = READ_ONCE(*_ptr);	\
> +								\
> +	for (;;) {						\
> +		_new = (_val & ~_mask) | _flags;		\
> +		_old = cmpxchg(_ptr, _val, _new);		\
> +		if (_old == _val)				\
> +			break;					\
> +		_val = _old;					\
> +	}							\
> +	_val;							\
> +})

Don't call them atomic_*() if they're not part of the atomic_t
interface.




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux