[Pixman] [PATCH] test/utils: Check for FE_INVALID definition before use

Siarhei Siamashka siarhei.siamashka at gmail.com
Mon Jun 6 02:42:49 UTC 2016


On Tue, 17 May 2016 17:32:00 -0700
Khem Raj <raj.khem at gmail.com> wrote:

> Some architectures e.g. nios2 do not support all exceptions
> 
> Signed-off-by: Khem Raj <raj.khem at gmail.com>
> ---
>  test/utils.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/test/utils.c b/test/utils.c
> index f8e42a5..fe32b1e 100644
> --- a/test/utils.c
> +++ b/test/utils.c
> @@ -978,9 +978,11 @@ enable_invalid_exceptions (void)
>  {
>  #ifdef HAVE_FENV_H
>  #ifdef HAVE_FEENABLEEXCEPT
> +#ifdef FE_INVALID
>      feenableexcept (FE_INVALID);
>  #endif
>  #endif
> +#endif
>  }
>  
>  void *

Thanks,

I think that we have seen this problem reported earlier, but the
proposed "fix" was an attempt to just disable compiling tests
altogether:
    https://patchwork.freedesktop.org/patch/70676

I'm glad that the root cause is finally getting properly addressed.
But before we can apply your patch, please change it to look like
    https://cgit.freedesktop.org/pixman/commit/?id=4297e9058d252cac653723fe0b1bee559fbac3a4

The reason is that such #ifdef based checks are not always reliable. We
never know what kind of stunts may be hidden in the header files on
various platforms and operating systems. And we already had been
surprised more than once. This is an artificial example, but please
consider the following code:

$ cat test.c 
/*******************************************************************/
static const int SOMETHING_THAT_LOOKS_LIKE_A_DEFINE = 123;

#ifdef SOMETHING_THAT_LOOKS_LIKE_A_DEFINE
#error SOMETHING_THAT_LOOKS_LIKE_A_DEFINE seems to be available
#else
#error SOMETHING_THAT_LOOKS_LIKE_A_DEFINE seems to be not available
#endif
/*******************************************************************/

$ gcc test.c
test.c:7:2: error: #error SOMETHING_THAT_LOOKS_LIKE_A_DEFINE seems to be not available
 #error SOMETHING_THAT_LOOKS_LIKE_A_DEFINE seems to be not available
  ^


-- 
Regards,
Sierž


More information about the Pixman mailing list