[Mesa-dev] [PATCH 02/13] isl: Add an ISL_RESTRICT #define for use in isl.h

Matt Turner mattst88 at gmail.com
Tue Apr 19 22:01:10 UTC 2016


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


More information about the mesa-dev mailing list