elf32-nds32: Don't define fls if it is provided by the system
authorSimon Marchi <simon.marchi@ericsson.com>
Fri, 21 Sep 2018 14:27:30 +0000 (10:27 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Fri, 21 Sep 2018 14:27:30 +0000 (10:27 -0400)
The fls function already exists on macOS and FreeBSD (and probably others),
leading to this error:

/Users/simark/src/binutils-gdb/bfd/elf32-nds32.c:5074:1: error: static declaration of 'fls' follows non-static declaration
fls (register unsigned int x)
^
/usr/include/strings.h:87:6: note: previous declaration is here
int      fls(int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
         ^

Add a configure-time check for it, and only define it if the system doesn't
provide it.

bfd/ChangeLog:

* configure.ac: Check for fls.
* elf32-nds32.c (fls): Only define if !HAVE_FLS.
* config.in: Re-generate.
* configure: Re-generate.

bfd/ChangeLog
bfd/config.in
bfd/configure
bfd/configure.ac
bfd/elf32-nds32.c

index cfd89cbd807f27ae866010c0a05398507044c261..a5c857ad7185ae289629fd813948a33f1fef732d 100644 (file)
@@ -1,3 +1,10 @@
+2018-09-21  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * configure.ac: Check for fls.
+       * elf32-nds32.c (fls): Only define if !HAVE_FLS.
+       * config.in: Re-generate.
+       * configure: Re-generate.
+
 2018-09-20  Maciej W. Rozycki  <macro@linux-mips.org>
 
        * config.bfd <rs6000-*-aix5.[01], rs6000-*-aix[5-9]*>: Remove
index 6ebdc51b981d245d4e9a952b221dd9cafe1cf652..be572969fc04ea4ab36a72e3ebf7b3823c4eb9f6 100644 (file)
 /* Define to 1 if you have the `fileno' function. */
 #undef HAVE_FILENO
 
+/* Define to 1 if you have the `fls' function. */
+#undef HAVE_FLS
+
 /* Define to 1 if you have the `fopen64' function. */
 #undef HAVE_FOPEN64
 
index 8c83a6a08eebed87837997f5ad5f8e6b580c2e5f..4c94cf0b8dd4a3d5b864567209f2ab99c02fa94f 100755 (executable)
@@ -14089,7 +14089,7 @@ $as_echo "#define STRING_WITH_STRINGS 1" >>confdefs.h
 
 fi
 
-for ac_func in fcntl getpagesize setitimer sysconf fdopen getuid getgid fileno
+for ac_func in fcntl getpagesize setitimer sysconf fdopen getuid getgid fileno fls
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
index 787ac7fa658350168dffb069f0b9fa03143d10b2..270e54e7d13ff418c46eeb9ec683b47bff3c268b 100644 (file)
@@ -229,7 +229,7 @@ AC_HEADER_TIME
 AC_HEADER_DIRENT
 
 ACX_HEADER_STRING
-AC_CHECK_FUNCS(fcntl getpagesize setitimer sysconf fdopen getuid getgid fileno)
+AC_CHECK_FUNCS(fcntl getpagesize setitimer sysconf fdopen getuid getgid fileno fls)
 AC_CHECK_FUNCS(strtoull getrlimit)
 
 AC_CHECK_DECLS(basename)
index 6215f2880093858b58c9c5e5a141f97e1b6705ad..8844166921110191938d2166a18d94251302c29b 100644 (file)
@@ -5083,11 +5083,13 @@ ones32 (register unsigned int x)
   return (x & 0x0000003f);
 }
 
+#if !HAVE_FLS
 static unsigned int
 fls (register unsigned int x)
 {
   return ffs (x & (-x));
 }
+#endif /* !HAVE_FLS */
 
 #define nds32_elf_local_tlsdesc_gotent(bfd) \
   (elf_nds32_tdata (bfd)->local_tlsdesc_gotent)
This page took 0.038892 seconds and 4 git commands to generate.