From: Wu Fengguang Date: Thu, 8 Jan 2009 02:09:12 +0000 (-0800) Subject: generic swap(): introduce global macro swap(a, b) X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=91f68b7359144aa40bb9668124543d15284750b4;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git generic swap(): introduce global macro swap(a, b) There have been some local definitions of swap(), it's time to replace them all with a uniform one. Signed-off-by: Wu Fengguang Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 6b8e2027165e..343df9ef2412 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -476,6 +476,12 @@ static inline char *pack_hex_byte(char *buf, u8 byte) __val = __val < __min ? __min: __val; \ __val > __max ? __max: __val; }) + +/* + * swap - swap value of @a and @b + */ +#define swap(a, b) ({ typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; }) + /** * container_of - cast a member of a structure out to the containing structure * @ptr: the pointer to the member.