[Mesa-dev] Mesa (glsl2): mesa: Check that _XOPEN_SOURCE is defined before using it.

Vinson Lee vlee at vmware.com
Mon Aug 16 10:56:16 PDT 2010


> -----Original Message-----
> From: Ian Romanick [mailto:idr at freedesktop.org]
> Sent: Monday, August 16, 2010 10:18 AM
> To: Vinson Lee
> Cc: mesa-dev at lists.freedesktop.org
> Subject: Re: Mesa (glsl2): mesa: Check that _XOPEN_SOURCE is defined
> before using it.
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Vinson Lee wrote:
> > Module: Mesa
> > Branch: glsl2
> > Commit: a0b0afc6944b00df27145a96ad2727a36752e1d6
> > URL:
> http://cgit.freedesktop.org/mesa/mesa/commit/?id=a0b0afc6944b00df27145a96a
> d2727a36752e1d6
> >
> > Author: Vinson Lee <vlee at vmware.com>
> > Date:   Sun Aug 15 13:08:15 2010 -0700
> >
> > mesa: Check that _XOPEN_SOURCE is defined before using it.
> 
> Does MSVC actually fail on that?  I believe that even C89 says that
> undefined preprocessor variables be treated has having value 0 in
> preprocessor statements.  We looked at this quite a bit when writing the
> GLSL preprocessor. :)

No, the MSVC build is okay. It fails all those checks and enters the #define acosf portion.

Mac OS X gcc didn't define _XOPEN_SOURCE either. It doesn't define __STDC_VERSION__ by default either. With -std=c99 it'll set it to 19901.

Reverting this commit would still make the Mac OS X build be okay.


> 
> > ---
> >
> >  src/mesa/main/imports.h |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
> > index a439370..e967b14 100644
> > --- a/src/mesa/main/imports.h
> > +++ b/src/mesa/main/imports.h
> > @@ -120,7 +120,7 @@ typedef union { GLfloat f; GLint i; } fi_type;
> >   * \name Work-arounds for platforms that lack C99 math functions
> >   */
> >  /*@{*/
> > -#if (_XOPEN_SOURCE < 600) && !defined(_ISOC99_SOURCE) \
> > +#if (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE < 600)) &&
> !defined(_ISOC99_SOURCE) \
> >     && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) \
> >     && (!defined(_MSC_VER) || (_MSC_VER < 1400))
> >  #define acosf(f) ((float) acos(f))
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAkxpcsIACgkQX1gOwKyEAw9W4gCeMhBjAQidRp6m4MtDC2KQowEQ
> wF4AnR15Xlj6qoU1L7rrE/zUa7hoezie
> =hFSD
> -----END PGP SIGNATURE-----


More information about the mesa-dev mailing list