[PATCH] Fix misc.h changes from d206d52f657c to work with Sun compilers

Jamey Sharp jamey at minilop.net
Thu Sep 22 19:09:08 PDT 2011


Reviewed-by: Jamey Sharp <jamey at minilop.net>

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 <alan.coopersmith at oracle.com>
> ---
>  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
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg-devel/attachments/20110922/a1108307/attachment.pgp>


More information about the xorg-devel mailing list