public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH i-g-t 1/3] lib: Add swap() macro
@ 2014-12-05 15:04 ville.syrjala
  2014-12-05 15:04 ` [PATCH i-g-t 2/3] lib/igt.cocci: Deal with min/max/swap ville.syrjala
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: ville.syrjala @ 2014-12-05 15:04 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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>
---
 lib/igt_aux.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 6c83c53..63e1b06 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 */
-- 
2.0.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-12-05 17:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-05 15:04 [PATCH i-g-t 1/3] lib: Add swap() macro ville.syrjala
2014-12-05 15:04 ` [PATCH i-g-t 2/3] lib/igt.cocci: Deal with min/max/swap ville.syrjala
2014-12-05 15:04 ` [PATCH i-g-t 3/3] tests: Run lib/igt.cocci ville.syrjala
2014-12-05 16:44 ` [PATCH i-g-t 1/3] lib: Add swap() macro Jani Nikula
2014-12-05 17:06   ` Ville Syrjälä
2014-12-05 17:39     ` Jani Nikula

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox