[Intel-gfx] [PATCH i-g-t 1/3] lib: Add swap() macro
Ville Syrjälä
ville.syrjala at linux.intel.com
Fri Dec 5 09:06:50 PST 2014
On Fri, Dec 05, 2014 at 06:44:19PM +0200, Jani Nikula wrote:
> On Fri, 05 Dec 2014, ville.syrjala at linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala at 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 at 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)
>
> Nitpick, make the macro take pointers instead, and amend the cocci patch
> accordingly? To a grumpy old C coder, swap(&a, &b) is so much more
> obvious than swap(a, b)...
But then it's different than the kernel swap() we all love.
>
> Jani.
>
>
> > +
> > #endif /* IGT_AUX_H */
> > --
> > 2.0.4
> >
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
> --
> Jani Nikula, Intel Open Source Technology Center
--
Ville Syrjälä
Intel OTC
More information about the Intel-gfx
mailing list