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 <fengguang.wu@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Wu Fengguang 2009-01-07 18:09:12 -08:00 committed by Linus Torvalds
parent b53907c010
commit 91f68b7359
1 changed files with 6 additions and 0 deletions

View File

@ -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.