diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2014-11-28 10:03:38 +0200 |
---|---|---|
committer | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2014-12-08 19:26:39 +0200 |
commit | 1658edceee85bd5f57e8dd39075f1d127260d5b6 (patch) | |
tree | 927d68177c7d433d36b5ade8a7e269af04f06ef3 /lib/igt_aux.h | |
parent | b32b5327a20b3747890235c362b093439b854f59 (diff) |
lib: Add swap() macro
swap() will swap its two arguments while keeping the required
tmp variable hidden. Makes for neater code.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Diffstat (limited to 'lib/igt_aux.h')
-rw-r--r-- | lib/igt_aux.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 6c83c53e..63e1b06a 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -90,4 +90,10 @@ void intel_require_memory(uint32_t count, uint32_t size, unsigned mode); #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) +#define swap(a, b) do { \ + typeof(a) _tmp = (a); \ + (a) = (b); \ + (b) = _tmp; \ +} while (0) + #endif /* IGT_AUX_H */ |