[PATCH:x11proto] Add _X_COLD attribute for branch prediction hints

Peter Hutterer peter.hutterer at who-t.net
Sun May 5 16:38:46 PDT 2013


On Wed, Apr 24, 2013 at 10:47:59PM -0700, Alan Coopersmith wrote:
> Unfortunately the Solaris Studio equivalent is a pragma taking the
> function names as arguments, so doesn't translate cleanly into a
> common macro form.
> 
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> ---
> 
> To be used in code we pretty much only call in error paths, such as in Xlib:
>   extern void _XEatData(....) _X_COLD;
> 
> or in the xserver now:
>   extern void c2p_unsupported(void) _X_COLD;

Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

should use this in the BUG_WARN macros in the server too.

Cheers,
   Peter`


> 
>  Xfuncproto.h.in |    9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/Xfuncproto.h.in b/Xfuncproto.h.in
> index 8256fec..dac9229 100644
> --- a/Xfuncproto.h.in
> +++ b/Xfuncproto.h.in
> @@ -97,6 +97,7 @@ in this Software without prior written authorization from The Open Group.
>  # define _X_INTERNAL
>  #endif /* GNUC >= 4 */
>  
> +/* Branch prediction hints for individual conditionals */
>  /* requires xproto >= 7.0.9 */
>  #if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
>  # define _X_LIKELY(x)   __builtin_expect(!!(x), 1)
> @@ -106,6 +107,14 @@ in this Software without prior written authorization from The Open Group.
>  # define _X_UNLIKELY(x) (x)
>  #endif
>  
> +/* Bulk branch prediction hints via marking error path functions as "cold" */
> +/* requires xproto >= 7.0.25 */
> +#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403) /* 4.3+ */
> +# define _X_COLD __attribute__((__cold__))
> +#else
> +# define _X_COLD /* nothing */
> +#endif
> +
>  /* Added in X11R6.9, so available in any version of modular xproto */
>  #if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 301)
>  # define _X_DEPRECATED  __attribute__((deprecated))
> -- 
> 1.7.9.2
 


More information about the xorg-devel mailing list