[PATCH] dix: optimize CallCallbacks

Tomas Carnecky tom at dbservice.com
Tue Oct 12 02:35:02 PDT 2010


On 10/11/10 10:37 PM, Adam Jackson wrote:
> Move the basic sanity checking to an inline wrapper, which avoids the
> function call overhead if the callback list is empty.  On an XACEful
> server on a 2.4GHz Core 2 Duo:
> 
>     1              2           Operation
> --------   -----------------   -----------------
> 20000000.0   25100000.0 (  1.25)   X protocol NoOperation
> 
> Signed-off-by: Adam Jackson <ajax at redhat.com>
> ---
>  dix/dixutils.c     |    9 +--------
>  include/callback.h |    9 ++++++++-
>  2 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/dix/dixutils.c b/dix/dixutils.c
> index 470bb5d..104363b 100644
> --- a/dix/dixutils.c
> +++ b/dix/dixutils.c
> @@ -729,7 +729,7 @@ _DeleteCallback(
>      return FALSE;
>  }
>  
> -static void 
> +void 
>  _CallCallbacks(
>      CallbackListPtr    *pcbl,
>      pointer	    call_data)
> @@ -871,13 +871,6 @@ DeleteCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, pointer data)
>  }
>  
>  void
> -CallCallbacks(CallbackListPtr *pcbl, pointer call_data)
> -{
> -    if (!pcbl || !*pcbl) return;
> -    _CallCallbacks(pcbl, call_data);
> -}
> -
> -void
>  DeleteCallbackList(CallbackListPtr *pcbl)
>  {
>      if (!pcbl || !*pcbl) return;
> diff --git a/include/callback.h b/include/callback.h
> index 632ed4f..9a1da73 100644
> --- a/include/callback.h
> +++ b/include/callback.h
> @@ -75,10 +75,17 @@ extern _X_EXPORT Bool DeleteCallback(
>      CallbackProcPtr /*callback*/,
>      pointer /*data*/);
>  
> -extern _X_EXPORT void CallCallbacks(
> +extern _X_EXPORT void _CallCallbacks(
>      CallbackListPtr * /*pcbl*/,
>      pointer /*call_data*/);
>  
> +static inline void
> +CallCallbacks(CallbackListPtr *pcbl, pointer call_data)

I once tried to clean up all the inline, __inline, __inline__, _X_INLINE
declarations but never actually got an answer which one I should use.
The documentation says that inline is an optional extension and that one
should use _X_INLINE. But too much code already assumes that the
compiler supports inline. Is everyone fine with that?

> +{
> +    if (!pcbl || !*pcbl) return;
> +    _CallCallbacks(pcbl, call_data);
> +}
> +
>  extern _X_EXPORT void DeleteCallbackList(
>      CallbackListPtr * /*pcbl*/);
>  




More information about the xorg-devel mailing list