Re: snag of G_LIKELY()
- From: Mark Mielke <mark mark mielke cc>
- To: Daniel Elstner <daniel elstner gmx net>
- Cc: Owen Taylor <otaylor redhat com>, gtk-devel-list gnome org
- Subject: Re: snag of G_LIKELY()
- Date: Sat, 23 Nov 2002 15:43:53 -0500
On Sat, Nov 23, 2002 at 08:38:06PM +0100, Daniel Elstner wrote:
> > #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
> > #define _G_BOOLEAN_EXPR(expr) \
> > __extension__ ({ \
> > int _g_boolean_var_; \
> > if (expr) \
> > _g_boolean_var_ = 1; \
> > else \
> > _g_boolean_var_ = 0; \
> > _g_boolean_var_; \
> > })
> > #define G_LIKELY(expr) __builtin_expect (_G_BOOLEAN_EXPR(expr), 1)
> > #define G_UNLIKELY(expr) __builtin_expect (_G_BOOLEAN_EXPR(expr), 0)
> > #else
> > #define G_LIKELY(expr) expr
> > #define G_UNLIKELY(expr) expr
> > #endif
I think I missed the point... why shouldn't it be:
#define G_LIKELY(expr) __builtin_expect(!(expr), 0)
#define G_UNLIKELY(expr) __builtin_expect((expr), 0)
mark
--
mark mielke cc/markm ncf ca/markm nortelnetworks com __________________________
. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder
|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ |
| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada
One ring to rule them all, one ring to find them, one ring to bring them all
and in the darkness bind them...
http://mark.mielke.cc/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]