diff mbox

[U-Boot] bch: Fix build on FreeBSD host

Message ID 20170620070229.32613-1-manu@bidouilliste.com
State Accepted
Commit 4ecc988301bc8e981e6d7538c57cdb3aa82f7c1d
Delegated to: Tom Rini
Headers show

Commit Message

Emmanuel Vadot June 20, 2017, 7:02 a.m. UTC
endian.h on FreeBSD system exist in sys/ subdirectory.
FreeBSD already have a fls function defined in strings.h which is included
in string.h if __BSD_VISIBLE is defined, as a check for this.

Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
---
 lib/bch.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Jonathan Gray July 19, 2017, 6:26 a.m. UTC | #1
On Tue, Jun 20, 2017 at 09:02:29AM +0200, Emmanuel Vadot wrote:
> endian.h on FreeBSD system exist in sys/ subdirectory.
> FreeBSD already have a fls function defined in strings.h which is included
> in string.h if __BSD_VISIBLE is defined, as a check for this.

This broke the build of u-boot on OpenBSD where there is no fls in
strings.h.

> 
> Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
> ---
>  lib/bch.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/lib/bch.c b/lib/bch.c
> index ec53483774..7a2d9d3b86 100644
> --- a/lib/bch.c
> +++ b/lib/bch.c
> @@ -61,7 +61,11 @@
>  #include <linux/bitops.h>
>  #else
>  #include <errno.h>
> +#if defined(__FreeBSD__)
> +#include <sys/endian.h>
> +#else
>  #include <endian.h>
> +#endif
>  #include <stdint.h>
>  #include <stdlib.h>
>  #include <string.h>
> @@ -113,6 +117,7 @@ struct gf_poly_deg1 {
>  };
>  
>  #ifdef USE_HOSTCC
> +#ifndef __BSD_VISIBLE
>  static int fls(int x)
>  {
>  	int r = 32;
> @@ -142,6 +147,7 @@ static int fls(int x)
>  	return r;
>  }
>  #endif
> +#endif
>  
>  /*
>   * same as encode_bch(), but process input data one byte at a time
> -- 
> 2.13.1
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
Emmanuel Vadot July 19, 2017, 7:56 a.m. UTC | #2
On Wed, 19 Jul 2017 16:26:13 +1000
Jonathan Gray <jsg@jsg.id.au> wrote:

> On Tue, Jun 20, 2017 at 09:02:29AM +0200, Emmanuel Vadot wrote:
> > endian.h on FreeBSD system exist in sys/ subdirectory.
> > FreeBSD already have a fls function defined in strings.h which is included
> > in string.h if __BSD_VISIBLE is defined, as a check for this.
> 
> This broke the build of u-boot on OpenBSD where there is no fls in
> strings.h.

 Ok, I'll come up with a more specific patch for FreeBSD.
 Does OpenBSD have endian.h under sys/ too ?

> > 
> > Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
> > ---
> >  lib/bch.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/lib/bch.c b/lib/bch.c
> > index ec53483774..7a2d9d3b86 100644
> > --- a/lib/bch.c
> > +++ b/lib/bch.c
> > @@ -61,7 +61,11 @@
> >  #include <linux/bitops.h>
> >  #else
> >  #include <errno.h>
> > +#if defined(__FreeBSD__)
> > +#include <sys/endian.h>
> > +#else
> >  #include <endian.h>
> > +#endif
> >  #include <stdint.h>
> >  #include <stdlib.h>
> >  #include <string.h>
> > @@ -113,6 +117,7 @@ struct gf_poly_deg1 {
> >  };
> >  
> >  #ifdef USE_HOSTCC
> > +#ifndef __BSD_VISIBLE
> >  static int fls(int x)
> >  {
> >  	int r = 32;
> > @@ -142,6 +147,7 @@ static int fls(int x)
> >  	return r;
> >  }
> >  #endif
> > +#endif
> >  
> >  /*
> >   * same as encode_bch(), but process input data one byte at a time
> > -- 
> > 2.13.1
> > 
> > _______________________________________________
> > U-Boot mailing list
> > U-Boot@lists.denx.de
> > https://lists.denx.de/listinfo/u-boot
Mark Kettenis July 19, 2017, 9:03 a.m. UTC | #3
> Date: Wed, 19 Jul 2017 09:56:20 +0200
> From: Emmanuel Vadot <manu@bidouilliste.com>
> 
> On Wed, 19 Jul 2017 16:26:13 +1000
> Jonathan Gray <jsg@jsg.id.au> wrote:
> 
> > On Tue, Jun 20, 2017 at 09:02:29AM +0200, Emmanuel Vadot wrote:
> > > endian.h on FreeBSD system exist in sys/ subdirectory.
> > > FreeBSD already have a fls function defined in strings.h which is included
> > > in string.h if __BSD_VISIBLE is defined, as a check for this.
> > 
> > This broke the build of u-boot on OpenBSD where there is no fls in
> > strings.h.
> 
>  Ok, I'll come up with a more specific patch for FreeBSD.
>  Does OpenBSD have endian.h under sys/ too ?

We have both <endian.h> and <sys/endian.h>, the former being a symlink
to the latter.

> > > Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
> > > ---
> > >  lib/bch.c | 6 ++++++
> > >  1 file changed, 6 insertions(+)
> > > 
> > > diff --git a/lib/bch.c b/lib/bch.c
> > > index ec53483774..7a2d9d3b86 100644
> > > --- a/lib/bch.c
> > > +++ b/lib/bch.c
> > > @@ -61,7 +61,11 @@
> > >  #include <linux/bitops.h>
> > >  #else
> > >  #include <errno.h>
> > > +#if defined(__FreeBSD__)
> > > +#include <sys/endian.h>
> > > +#else
> > >  #include <endian.h>
> > > +#endif
> > >  #include <stdint.h>
> > >  #include <stdlib.h>
> > >  #include <string.h>
> > > @@ -113,6 +117,7 @@ struct gf_poly_deg1 {
> > >  };
> > >  
> > >  #ifdef USE_HOSTCC
> > > +#ifndef __BSD_VISIBLE
> > >  static int fls(int x)
> > >  {
> > >  	int r = 32;
> > > @@ -142,6 +147,7 @@ static int fls(int x)
> > >  	return r;
> > >  }
> > >  #endif
> > > +#endif
> > >  
> > >  /*
> > >   * same as encode_bch(), but process input data one byte at a time
> > > -- 
> > > 2.13.1
> > > 
> > > _______________________________________________
> > > U-Boot mailing list
> > > U-Boot@lists.denx.de
> > > https://lists.denx.de/listinfo/u-boot
> 
> 
> -- 
> Emmanuel Vadot <manu@bidouilliste.com> <manu@freebsd.org>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
> 
>
diff mbox

Patch

diff --git a/lib/bch.c b/lib/bch.c
index ec53483774..7a2d9d3b86 100644
--- a/lib/bch.c
+++ b/lib/bch.c
@@ -61,7 +61,11 @@ 
 #include <linux/bitops.h>
 #else
 #include <errno.h>
+#if defined(__FreeBSD__)
+#include <sys/endian.h>
+#else
 #include <endian.h>
+#endif
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
@@ -113,6 +117,7 @@  struct gf_poly_deg1 {
 };
 
 #ifdef USE_HOSTCC
+#ifndef __BSD_VISIBLE
 static int fls(int x)
 {
 	int r = 32;
@@ -142,6 +147,7 @@  static int fls(int x)
 	return r;
 }
 #endif
+#endif
 
 /*
  * same as encode_bch(), but process input data one byte at a time