Skip to content

Commit

Permalink
generic swap(): introduce global macro swap(a, b)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wu Fengguang authored and torvalds committed Jan 8, 2009
1 parent b53907c commit 91f68b7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 91f68b7

Please sign in to comment.