Reviewed-by: Jamey Sharp <[email protected]>

Seems like there ought to be a better way than listing which compilers
support it, though. I considered an autoconf test to check whether
__builtin_constant_p is defined, but that doesn't tell you which
compiler is pulling in misc.h each time it's used. Which wouldn't be an
issue if misc.h weren't part of the SDK headers. Phooey.

Jamey

On Thu, Sep 22, 2011 at 05:31:17PM -0700, Alan Coopersmith wrote:
> Studio 12.0 and later have builtin support for __builtin_constant_p and
> if you try to define a function with that name, they issue an error:
> "../include/misc.h", line 271: syntax error before or at: __builtin_constant_p
> 
> For older versions, the fallback definition needs to specify it returns
> an int, not claim void while returning 0 and checking the return value.
> 
> Signed-off-by: Alan Coopersmith <[email protected]>
> ---
>  include/misc.h |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/include/misc.h b/include/misc.h
> index 1fea73e..da494e0 100644
> --- a/include/misc.h
> +++ b/include/misc.h
> @@ -268,10 +268,12 @@ static inline void wrong_size(void)
>  {
>  }
>  
> -static inline void __builtin_constant_p(int x)
> +# if !(defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
> +static inline int __builtin_constant_p(int x)
>  {
>       return 0;
>  }
> +# endif
>  #endif
>  
>  /* byte swap a 32-bit value */
> -- 
> 1.7.3.2
> 
> _______________________________________________
> [email protected]: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel

Attachment: signature.asc
Description: Digital signature

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to