Fix compiler warnings building against Linux uapi headers

Message ID CAJgzZopOniu-Uh128-y3f61zx04D=U-QtjgYTps7sxvef-Nw8g@mail.gmail.com
State New, archived
Headers

Commit Message

enh June 22, 2015, 7:09 p.m. UTC
  building gdb against the Linux kernel's uapi headers (as used by
Android's bionic C library) causes warnings such as:

gdb/gdbserver/linux-arm-low.c:122:0: warning: "HWCAP_VFP" redefined
[enabled by default]

because linux-arm-low.c has #defines like this:

 #define HWCAP_VFP       64

but the current Linux kernel #define looks like this instead:

 #define HWCAP_VFP (1 << 6)

I don't know whether you still need to support versions of glibc that
don't have these constants at all; if you don't, a better fix would be
to remove gdbserver's duplicate definitions. But on the assumption
that you do need to support old versions of glibc, here's a patch to
avoid the redefinition...

2015-06-22  Elliott Hughes  <enh@google.com>

	* linux-arm-low.c: Only define HWCAP_VFP and friends if they're
	not already defined. Fixes build against Linux uapi headers.
  

Comments

Yao Qi June 26, 2015, 3:42 p.m. UTC | #1
enh <enh@google.com> writes:

> to remove gdbserver's duplicate definitions. But on the assumption
> that you do need to support old versions of glibc, here's a patch to
> avoid the redefinition...

We should avoid the redefinition in gdb/arm-linux-tdep.h too.  Could you
please fix it there too?

>
> 2015-06-22  Elliott Hughes  <enh@google.com>
>
> 	* linux-arm-low.c: Only define HWCAP_VFP and friends if they're
> 	not already defined. Fixes build against Linux uapi headers.

OK with the changes.
  
Mike Frysinger Aug. 5, 2015, 8:50 a.m. UTC | #2
On 26 Jun 2015 16:42, Yao Qi wrote:
> enh <enh@google.com> writes:
> > to remove gdbserver's duplicate definitions. But on the assumption
> > that you do need to support old versions of glibc, here's a patch to
> > avoid the redefinition...
> 
> We should avoid the redefinition in gdb/arm-linux-tdep.h too.  Could you
> please fix it there too?
> 
> > 2015-06-22  Elliott Hughes  <enh@google.com>
> >
> > 	* linux-arm-low.c: Only define HWCAP_VFP and friends if they're
> > 	not already defined. Fixes build against Linux uapi headers.
> 
> OK with the changes.

Elliott: you going to respin this ?
-mike
  

Patch

diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index 303d9c8..f199b1c 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -119,11 +119,21 @@  struct arch_lwp_info
 static unsigned long arm_hwcap;

 /* These are in <asm/elf.h> in current kernels.  */
+#ifndef HWCAP_VFP
 #define HWCAP_VFP       64
+#endif
+#ifndef HWCAP_IWMMXT
 #define HWCAP_IWMMXT    512
+#endif
+#ifndef HWCAP_NEON
 #define HWCAP_NEON      4096
+#endif
+#ifndef HWCAP_VFPv3
 #define HWCAP_VFPv3     8192
+#endif
+#ifndef HWCAP_VFPv3D16
 #define HWCAP_VFPv3D16  16384
+#endif

 #ifdef HAVE_SYS_REG_H
 #include <sys/reg.h>