[Mesa-dev] [PATCH 02/13] isl: Add an ISL_RESTRICT #define for use in isl.h
Chad Versace
chad.versace at intel.com
Tue Apr 19 23:00:42 UTC 2016
On Tue 19 Apr 2016, Jason Ekstrand wrote:
> On Tue, Apr 19, 2016 at 3:14 PM, Chad Versace <chad.versace at intel.com>
> wrote:
>
> > On Tue 19 Apr 2016, Matt Turner wrote:
> > > On Sat, Apr 16, 2016 at 12:45 PM, Jason Ekstrand <jason at jlekstrand.net>
> > wrote:
> > > > C++ doesn't define the "restrict" keyword so g++ barfs when it sees
> > isl.h.
> > > > Having our own define lets us define it to be a no-op for C++.
> > > > ---
> > > > src/intel/isl/isl.h | 18 ++++++++++++++----
> > > > 1 file changed, 14 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
> > > > index 8f796b0..33d43d7 100644
> > > > --- a/src/intel/isl/isl.h
> > > > +++ b/src/intel/isl/isl.h
> > > > @@ -47,6 +47,16 @@
> > > > extern "C" {
> > > > #endif
> > > >
> > > > +/* The restrict keyword is simply a hint to the optimizer and doesn't
> > affect
> > > > + * the caller of a function in any way. We want it in the header for
> > the sake
> > > > + * of documentation but we can safely remove it to make C++ happy.
> > > > + */
> > > > +#ifdef __cplusplus
> > > > +#define ISL_RESTRICT
> > > > +#else
> > > > +#define ISL_RESTRICT restrict
> > > > +#endif
> > >
> > > Don't you just want __restrict?
> > >
> > > https://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html
> > >
> > > Maybe even just #define restrict __restrict
> >
> > Yes, please. Let's just do
> > #define restrict __restrict
> > or
> > #define restrict __restrict__
> >
> > Both work on Clang as well.
> >
>
> How about we just include c99_compat.h at the top of the file?
If it doesn't break the build, then that sounds good to me.
More information about the mesa-dev
mailing list