mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* big-endian sandbox issue
@ 2015-07-01  4:55 Antony Pavlov
  2015-07-01  6:24 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Antony Pavlov @ 2015-07-01  4:55 UTC (permalink / raw)
  To: barebox, Sascha Hauer

Hi!

I have tried to build barebox on big-endian MIPS CPU running Debian 8.
It fails because of unconditional <linux/byteorder/little_endian.h> inclusion.

At the first glance this can help:

--- a/arch/sandbox/include/asm/byteorder.h
+++ b/arch/sandbox/include/asm/byteorder.h
@@ -3,6 +3,12 @@

 #include <asm/types.h>

+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#include <linux/byteorder/big_endian.h>
+#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #include <linux/byteorder/little_endian.h>
+#else
+#error "__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ and __BYTE_ORDER__ !=
__ORDER_LITTLE_ENDIAN__"
+#endif

 #endif /* _I386_BYTEORDER_H */

But some warning appears:

In file included from common/filetype.c:21:0:
/barebox.git/arch/sandbox/include/asm/unaligned.h:11:21: warning:
"__LITTLE_ENDIAN" is not defined [-Wundef]
 #if __BYTE_ORDER == __LITTLE_ENDIAN

System-wide <endian.h> can fix the situation, but we use -nostdinc, so
the error occurs:

barebox.git/arch/sandbox/include/asm/byteorder.h:7:20: fatal error:
endian.h: No such file or directory
 #include <endian.h>
                    ^
compilation terminated.

Moreover AFAIR <endian.h> isn't available on BSD, so '#if
defined(__linux__)' has to be used.


Any suggestions?

-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: big-endian sandbox issue
  2015-07-01  4:55 big-endian sandbox issue Antony Pavlov
@ 2015-07-01  6:24 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2015-07-01  6:24 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Wed, Jul 01, 2015 at 07:55:05AM +0300, Antony Pavlov wrote:
> Hi!
> 
> I have tried to build barebox on big-endian MIPS CPU running Debian 8.
> It fails because of unconditional <linux/byteorder/little_endian.h> inclusion.
> 
> At the first glance this can help:
> 
> --- a/arch/sandbox/include/asm/byteorder.h
> +++ b/arch/sandbox/include/asm/byteorder.h
> @@ -3,6 +3,12 @@
> 
>  #include <asm/types.h>
> 
> +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
> +#include <linux/byteorder/big_endian.h>
> +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
>  #include <linux/byteorder/little_endian.h>
> +#else
> +#error "__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ and __BYTE_ORDER__ !=
> __ORDER_LITTLE_ENDIAN__"
> +#endif

This change seems ok.

> 
>  #endif /* _I386_BYTEORDER_H */
> 
> But some warning appears:
> 
> In file included from common/filetype.c:21:0:
> /barebox.git/arch/sandbox/include/asm/unaligned.h:11:21: warning:
> "__LITTLE_ENDIAN" is not defined [-Wundef]
>  #if __BYTE_ORDER == __LITTLE_ENDIAN

This should be #ifdef __LITTLE_ENDIAN

The authoritive answer to this is in include/common.h:

/*
 * sanity check. The Linux Kernel defines only one of __LITTLE_ENDIAN and
 * __BIG_ENDIAN. Endianess can then be tested with #ifdef __xx_ENDIAN. Userspace
 * always defined both __LITTLE_ENDIAN and __BIG_ENDIAN and byteorder can then
 * be tested with #if __BYTE_ORDER == __xx_ENDIAN.
 *
 * As we tend to use a lot of Kernel code in barebox we use the kernel way of
 * determing the byte order. Make sure here that architecture code properly
 * defines it.
 */
#include <asm/byteorder.h>
#if defined __LITTLE_ENDIAN && defined __BIG_ENDIAN
#error "both __LITTLE_ENDIAN and __BIG_ENDIAN are defined"
#endif
#if !defined __LITTLE_ENDIAN && !defined __BIG_ENDIAN
#error "None of __LITTLE_ENDIAN and __BIG_ENDIAN are defined"
#endif

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-01  6:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-01  4:55 big-endian sandbox issue Antony Pavlov
2015-07-01  6:24 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox