This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] bfd/elf32-arm.c: Rename 'popcount' to 'elf32_arm_popcount'


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b25e998d0be7d7ec2a14bfdca03370155355d215

commit b25e998d0be7d7ec2a14bfdca03370155355d215
Author: Christian Groessler <chris@groessler.org>
Date:   Mon Dec 19 13:56:22 2016 +0100

    bfd/elf32-arm.c: Rename 'popcount' to 'elf32_arm_popcount'
    
    bfd/elf32_arm.c contains a function 'popcount' which conflicts
    with a function of the same name in NetBSD's libc.
    This change also changes popcount's 'sum' variable to signed
    since the function returns a signed integer.
    
    bfd/
    * elf32-arm.c (elf32_arm_popcount): Rename from 'popcount'.  Make
    'sum' local variable signed.

Diff:
---
 bfd/ChangeLog   |  5 +++++
 bfd/elf32-arm.c | 15 ++++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8c09c2c..36d83e9 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2016-12-19  Christian Groessler  <chris@groessler.org>
+
+	* elf32-arm.c (elf32_arm_popcount): Rename from 'popcount'.  Make
+	'sum' local variable signed.
+
 2016-12-16  fincs  <fincs.alt1@gmail.com>
 
 	* elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Add handling
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 8a20260..fd6d3ac 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -3245,12 +3245,13 @@ ctz (unsigned int mask)
 }
 
 static inline int
-popcount (unsigned int mask)
+elf32_arm_popcount (unsigned int mask)
 {
 #if GCC_VERSION >= 3004
   return __builtin_popcount (mask);
 #else
-  unsigned int i, sum = 0;
+  unsigned int i;
+  int sum = 0;
 
   for (i = 0; i < 8 * sizeof (mask); i++)
     {
@@ -8496,7 +8497,7 @@ stm32l4xx_need_create_replacing_stub (const insn32 insn,
   /* The field encoding the register list is the same for both LDMIA
      and LDMDB encodings.  */
   if (is_thumb2_ldmia (insn) || is_thumb2_ldmdb (insn))
-    nb_words = popcount (insn & 0x0000ffff);
+    nb_words = elf32_arm_popcount (insn & 0x0000ffff);
   else if (is_thumb2_vldm (insn))
    nb_words = (insn & 0xff);
 
@@ -17903,7 +17904,7 @@ stm32l4xx_create_replacing_stub_ldmia (struct elf32_arm_link_hash_table * htab,
   int insn_all_registers = initial_insn & 0x0000ffff;
   int insn_low_registers, insn_high_registers;
   int usable_register_mask;
-  int nb_registers = popcount (insn_all_registers);
+  int nb_registers = elf32_arm_popcount (insn_all_registers);
   int restore_pc = (insn_all_registers & (1 << 15)) ? 1 : 0;
   int restore_rn = (insn_all_registers & (1 << rn)) ? 1 : 0;
   bfd_byte *current_stub_contents = base_stub_contents;
@@ -17947,7 +17948,7 @@ stm32l4xx_create_replacing_stub_ldmia (struct elf32_arm_link_hash_table * htab,
   BFD_ASSERT (!wback || !restore_rn);
 
   /* - nb_registers > 8.  */
-  BFD_ASSERT (popcount (insn_all_registers) > 8);
+  BFD_ASSERT (elf32_arm_popcount (insn_all_registers) > 8);
 
   /* At this point, LDMxx initial insn loads between 9 and 14 registers.  */
 
@@ -18049,7 +18050,7 @@ stm32l4xx_create_replacing_stub_ldmdb (struct elf32_arm_link_hash_table * htab,
   int usable_register_mask;
   int restore_pc = (insn_all_registers & (1 << 15)) ? 1 : 0;
   int restore_rn = (insn_all_registers & (1 << rn)) ? 1 : 0;
-  int nb_registers = popcount (insn_all_registers);
+  int nb_registers = elf32_arm_popcount (insn_all_registers);
   bfd_byte *current_stub_contents = base_stub_contents;
 
   BFD_ASSERT (is_thumb2_ldmdb (initial_insn));
@@ -18090,7 +18091,7 @@ stm32l4xx_create_replacing_stub_ldmdb (struct elf32_arm_link_hash_table * htab,
   BFD_ASSERT (!wback || !restore_rn);
 
   /* - nb_registers > 8.  */
-  BFD_ASSERT (popcount (insn_all_registers) > 8);
+  BFD_ASSERT (elf32_arm_popcount (insn_all_registers) > 8);
 
   /* At this point, LDMxx initial insn loads between 9 and 14 registers.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]