[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4E6137B8.1040402@gmail.com>
Date: Fri, 02 Sep 2011 14:08:24 -0600
From: David Ahern <dsahern@...il.com>
To: Arnaldo Carvalho de Melo <acme@...stprotocols.net>
CC: linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
mingo@...e.hu, peterz@...radead.org, fweisbec@...il.com,
paulus@...ba.org, tglx@...utronix.de, anton@...ba.org
Subject: Re: [PATCH v2] perf tool: fix endianness handling of u32 data in
samples
On 09/02/2011 02:01 PM, Arnaldo Carvalho de Melo wrote:
> Look again:
>
> #define WARN_ONCE(condition, format...) ({ \
> static bool __warned; \
> int __ret_warn_once = !!(condition); \
> \
> if (unlikely(__ret_warn_once)) \
> if (WARN(!__warned, format)) \
> __warned = true; \
> unlikely(__ret_warn_once); \
> })
>
>
> See that ({ }) construct? It evaluates to what is in its last statement,
> which is...
>
> unlikely(__ret_warn_once);
>
> Forget about the unlikely, __ret_warn_once is:
>
> !!condition
>
> I.e. it always evaluates to what is passed as condition, so in fact it
> could be seen as:
>
> if (swapped) {
> /* undo swap of u64, then swap on individual
> u32s */
> u.val64 = bswap_64(u.val64);
> u.val32[0] = bswap_32(u.val32[0]);
> u.val32[1] = bswap_32(u.val32[1]);
> }
>
> The rest is the boilerplate needed to warn the user the first time
> condition is true.
>
> - Arnaldo
Ok, I get it now.
David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists