eal: fix build issue
diff mbox series

Message ID 20181106114435.14770-1-jerin.jacob@caviumnetworks.com
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • eal: fix build issue
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK

Commit Message

Jerin Jacob Nov. 6, 2018, 11:45 a.m. UTC
Some toolchain has fls() definition in string.h as argument type int,
which is conflicting uint32_t argument type.

/export/dpdk.org/lib/librte_eal/common/rte_reciprocal.c:47:19:
error: conflicting types for ‘fls’
 static inline int fls(uint32_t x)
                  ^~~

/opt/marvell-tools-201/aarch64-marvell-elf/include/strings.h:59:6:
note: previous declaration of ‘fls’ was here
 int  fls(int) __pure2;

FreeBSD string.h also has fls() with argument as int type.
https://www.freebsd.org/cgi/man.cgi?query=fls&sektion=3

Fixing the conflict by renaming internal function as __fls

Fixes: ffe3ec811ef5 ("sched: introduce reciprocal divide")
Cc: stable@dpdk.org

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 lib/librte_eal/common/rte_reciprocal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Thomas Monjalon Nov. 6, 2018, 12:29 p.m. UTC | #1
06/11/2018 12:45, Jerin Jacob:
> Some toolchain has fls() definition in string.h as argument type int,
> which is conflicting uint32_t argument type.
> 
> /export/dpdk.org/lib/librte_eal/common/rte_reciprocal.c:47:19:
> error: conflicting types for ‘fls’
>  static inline int fls(uint32_t x)
>                   ^~~
> 
> /opt/marvell-tools-201/aarch64-marvell-elf/include/strings.h:59:6:
> note: previous declaration of ‘fls’ was here
>  int  fls(int) __pure2;
> 
> FreeBSD string.h also has fls() with argument as int type.
> https://www.freebsd.org/cgi/man.cgi?query=fls&sektion=3
> 
> Fixing the conflict by renaming internal function as __fls

Why not rte_fls? Would it be more future proof?
Jerin Jacob Nov. 6, 2018, 1:31 p.m. UTC | #2
-----Original Message-----
> Date: Tue, 06 Nov 2018 13:29:19 +0100
> From: Thomas Monjalon <thomas@monjalon.net>
> To: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Cc: "dev@dpdk.org" <dev@dpdk.org>, "Jacob, Jerin"
>  <Jerin.JacobKollanukkaran@cavium.com>, "stable@dpdk.org" <stable@dpdk.org>
> Subject: Re: [dpdk-dev] [PATCH] eal: fix build issue
> 
> 
> 06/11/2018 12:45, Jerin Jacob:
> > Some toolchain has fls() definition in string.h as argument type int,
> > which is conflicting uint32_t argument type.
> >
> > /export/dpdk.org/lib/librte_eal/common/rte_reciprocal.c:47:19:
> > error: conflicting types for ‘fls’
> >  static inline int fls(uint32_t x)
> >                   ^~~
> >
> > /opt/marvell-tools-201/aarch64-marvell-elf/include/strings.h:59:6:
> > note: previous declaration of ‘fls’ was here
> >  int  fls(int) __pure2;
> >
> > FreeBSD string.h also has fls() with argument as int type.
> > https://www.freebsd.org/cgi/man.cgi?query=fls&sektion=3
> >
> > Fixing the conflict by renaming internal function as __fls
> 
> Why not rte_fls? Would it be more future proof?

Agreed. There are two instance of fls in dpdk code base now,

1) lib/librte_eal/common/rte_reciprocal.c takes uint32_t
2) drivers/net/fm10k/fm10k_ethdev.c has macro, used with uint16_t as
argument.

Should we make it as macro or follow libc prototype where argument is
int.

Something like below,

static inline int
rte_fls(int x)
{
	return (x == 0) ? 0 : sizeof(x) * 8 - __builtin_clz(x);
}


 

> 
>
Thomas Monjalon Nov. 6, 2018, 8:27 p.m. UTC | #3
06/11/2018 14:31, Jerin Jacob:
> From: Thomas Monjalon <thomas@monjalon.net>
> > 06/11/2018 12:45, Jerin Jacob:
> > > Some toolchain has fls() definition in string.h as argument type int,
> > > which is conflicting uint32_t argument type.
> > >
> > > /export/dpdk.org/lib/librte_eal/common/rte_reciprocal.c:47:19:
> > > error: conflicting types for ‘fls’
> > >  static inline int fls(uint32_t x)
> > >                   ^~~
> > >
> > > /opt/marvell-tools-201/aarch64-marvell-elf/include/strings.h:59:6:
> > > note: previous declaration of ‘fls’ was here
> > >  int  fls(int) __pure2;
> > >
> > > FreeBSD string.h also has fls() with argument as int type.
> > > https://www.freebsd.org/cgi/man.cgi?query=fls&sektion=3
> > >
> > > Fixing the conflict by renaming internal function as __fls
> > 
> > Why not rte_fls? Would it be more future proof?
> 
> Agreed. There are two instance of fls in dpdk code base now,
> 
> 1) lib/librte_eal/common/rte_reciprocal.c takes uint32_t
> 2) drivers/net/fm10k/fm10k_ethdev.c has macro, used with uint16_t as
> argument.
> 
> Should we make it as macro or follow libc prototype where argument is
> int.
> 
> Something like below,
> 
> static inline int
> rte_fls(int x)
> {
> 	return (x == 0) ? 0 : sizeof(x) * 8 - __builtin_clz(x);
> }

I tend to think that using uint32_t parameter would be more useful in DPDK.

Patch
diff mbox series

diff --git a/lib/librte_eal/common/rte_reciprocal.c b/lib/librte_eal/common/rte_reciprocal.c
index d81b11db6..f2c7453d2 100644
--- a/lib/librte_eal/common/rte_reciprocal.c
+++ b/lib/librte_eal/common/rte_reciprocal.c
@@ -44,7 +44,7 @@ 
 /* find largest set bit.
  * portable and slow but does not matter for this usage.
  */
-static inline int fls(uint32_t x)
+static inline int __fls(uint32_t x)
 {
 	int b;
 
@@ -62,7 +62,7 @@  struct rte_reciprocal rte_reciprocal_value(uint32_t d)
 	uint64_t m;
 	int l;
 
-	l = fls(d - 1);
+	l = __fls(d - 1);
 	m = ((1ULL << 32) * ((1ULL << l) - d));
 	m /= d;