[v2,powerpc] fenv_libc.h: protect use of __builtin_cpu_supports()

Message ID 1562683300-7622-1-git-send-email-pc@us.ibm.com
State Superseded
Headers

Commit Message

Paul A. Clarke July 9, 2019, 2:41 p.m. UTC
  From: "Paul A. Clarke" <pc@us.ibm.com>

Using __builtin_cpu_supports() requires support in GCC and Glibc.
My recent patch to fenv_libc.h added an unprotected use of
__builtin_cpu_supports().  Compilation of Glibc itself will fail
with a sufficiently new GCC and sufficiently old Glibc:

../sysdeps/powerpc/fpu/fegetexcept.c: In function ‘__fegetexcept’:
../sysdeps/powerpc/fpu/fenv_libc.h:52:20: error: builtin ‘__builtin_cpu_supports’ needs GLIBC (2.23 and newer) that exports hardware capability bits [-Werror]

Fixes 3db85a9814784a74536a1f0e7b7ddbfef7dc84bb.

2019-07-09  Paul A. Clarke  <pc@us.ibm.com>

	* sysdeps/powerpc/fpu/fenv_libc.h (_FPU_GET_RC): Protect use of
	__builtin_cpu_supports with __BUILTIN_CPU_SUPPORTS__.

v2: No source changes. Corrected subject and commit message to reflect
    correct name of file changed.
---
 sysdeps/powerpc/fpu/fenv_libc.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Florian Weimer July 9, 2019, 4:21 p.m. UTC | #1
* Paul A. Clarke:

>  #ifdef _ARCH_PWR9
>  # define fegetenv_status() fegetenv_status_ISA300()
> -#else
> +#elif defined __BUILTIN_CPU_SUPPORTS__
>  # define fegetenv_status()						\
>    (__glibc_likely (__builtin_cpu_supports ("arch_3_00"))		\
>     ? fegetenv_status_ISA300()						\
>     : fegetenv_register()						\
>    )
> +#else
> +# define fegetenv_status() fegetenv_register()

Missing space before second () on the last line (but it's consistent
with the others 8-/).

Otherwise, this looks fine to me.  Maybe drop the () from the commit
message, per GNU style guidelines.

Thanks,
Florian
  

Patch

diff --git a/sysdeps/powerpc/fpu/fenv_libc.h b/sysdeps/powerpc/fpu/fenv_libc.h
index 55b1697..59a8c44 100644
--- a/sysdeps/powerpc/fpu/fenv_libc.h
+++ b/sysdeps/powerpc/fpu/fenv_libc.h
@@ -47,12 +47,14 @@  extern const fenv_t *__fe_mask_env (void) attribute_hidden;
 
 #ifdef _ARCH_PWR9
 # define fegetenv_status() fegetenv_status_ISA300()
-#else
+#elif defined __BUILTIN_CPU_SUPPORTS__
 # define fegetenv_status()						\
   (__glibc_likely (__builtin_cpu_supports ("arch_3_00"))		\
    ? fegetenv_status_ISA300()						\
    : fegetenv_register()						\
   )
+#else
+# define fegetenv_status() fegetenv_register()
 #endif
 
 /* Equivalent to fesetenv, but takes a fenv_t instead of a pointer.  */