Re: snag of G_LIKELY()
- From: Daniel Elstner <daniel elstner gmx net>
- To: Owen Taylor <otaylor redhat com>
- Cc: gtk-devel-list gnome org
- Subject: Re: snag of G_LIKELY()
- Date: 23 Nov 2002 20:38:06 +0100
Am Sam, 2002-11-23 um 20.10 schrieb Owen Taylor:
> - The g++ problem can be fixed with __extension__; wen
> already rely on statement expressions working for G++
> in libgobject. (The info page for gcc does suggest
> not using statement expressions with g++, but if they
> break them, we'll need a new release of glib anyways)
OK.
> ===
> #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
> ====
Seems fine to me.
--Daniel
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]