Skip to contentSkip to conversation

bch: Fix build on FreeBSD host

PATCH New Emmanuel Vadot 3 participants 4 messages Jun 20, 2017 – Jul 19, 2017 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bch: Fix build on FreeBSD host

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.

---
 lib/bch.c | 6 ++++++
 1 file changed, 6 insertions(+)
lib/bch.c +6 -0
index ec53483774..7a2d9d3b86 100644
@@ -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
Signature · 1 line
2.13.1
#1 lore raw

PATCH 1/1 bch: Fix build on FreeBSD host

Quoted 3 lines · Emmanuel Vadot

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.

Quoted 45 lines
---
 lib/bch.c | 6 ++++++
 1 file changed, 6 insertions(+)
lib/bch.c +6 -0
index ec53483774..7a2d9d3b86 100644
@@ -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
Signature · 6 lines
2.13.1

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
#2 lore raw

PATCH 1/1 bch: Fix build on FreeBSD host

Quoted 7 lines · On Wed, 19 Jul 2017 16:26:13 +1000 Jonathan Gray <[email protected]> wrote:
Quoted 3 lines · Emmanuel Vadot

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 ?

Quoted 45 lines
Quoted 45 lines
---
 lib/bch.c | 6 ++++++
 1 file changed, 6 insertions(+)
lib/bch.c +6 -0
index ec53483774..7a2d9d3b86 100644
@@ -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
Signature · 6 lines
2.13.1

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
Signature · 1 line
Emmanuel Vadot <[email protected]> <[email protected]>
#3 lore raw

PATCH 1/1 bch: Fix build on FreeBSD host

Quoted 11 lines

Date: Wed, 19 Jul 2017 09:56:20 +0200
From: Emmanuel Vadot <[email protected]>

Quoted 5 lines · On Wed, 19 Jul 2017 16:26:13 +1000 Jonathan Gray <[email protected]> wrote:
Quoted 3 lines · Emmanuel Vadot

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.

Quoted 5 lines
Quoted 2 lines

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.

Quoted 54 lines
Quoted 44 lines
Quoted 44 lines
---
 lib/bch.c | 6 ++++++
 1 file changed, 6 insertions(+)
lib/bch.c +6 -0
index ec53483774..7a2d9d3b86 100644
@@ -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
Signature · 6 lines
2.13.1

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
Signature · 5 lines
Emmanuel Vadot <[email protected]> <[email protected]>
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot