* byteorder problem
@ 2012-06-27 22:24 Antony Pavlov
0 siblings, 0 replies; only message in thread
From: Antony Pavlov @ 2012-06-27 22:24 UTC (permalink / raw)
To: barebox
Hi!
Yesterday I have investigated strange clocksource behaviour of JZ4755
MIPS CPU: the function cyc2ns() works wrong.
The problem was in realisation of the '>>' u64 operation (see __lshrdi3()).
In include/linux/byteorder/generic.h we have
#ifndef __LITTLE_ENDIAN
#define __LITTLE_ENDIAN 1234
#endif
#ifndef __BIG_ENDIAN
#define __BIG_ENDIAN 4321
#endif
so after including this file we will have __BIG_ENDIAN and
__LITTLE_ENDIAN both defined.
On the other hand in arch/mips/lib/libgcc.h we have
#ifdef __BIG_ENDIAN
struct DWstruct {
int high, low;
};
#elif defined(__LITTLE_ENDIAN)
struct DWstruct {
int low, high;
};
#else
#error I feel sick.
#endif
In any case we will got big-endian DWstruct, so on little-endian MIPS
machines we will have wrong result of the '>>' u64 operation (the low
and high parts of 64-bit word will be swapped).
The problem can be solved by this patch:
--- a/include/linux/byteorder/generic.h
+++ b/include/linux/byteorder/generic.h
@@ -78,13 +78,6 @@
*
*/
-#ifndef __LITTLE_ENDIAN
-#define __LITTLE_ENDIAN 1234
-#endif
-#ifndef __BIG_ENDIAN
-#define __BIG_ENDIAN 4321
-#endif
-
But in several places we have something like this:
#if __BYTE_ORDER == __LITTLE_ENDIAN
...
#elif __BYTE_ORDER == __BIG_ENDIAN
and we will get the warnings from compiler (e.g. warning:
"__BIG_ENDIAN" is not defined). So we need addition changes like this
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#ifdef __LITTLE_ENDIAN
...
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#elif defined(__BIG_ENDIAN)
There is another solution. We can change arch/mips/lib/libgcc.h:
-#ifdef __LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
...
-#elif defined(__BIG_ENDIAN)
+#elif __BYTE_ORDER == __BIG_ENDIAN
But this solution is not linux-compatible because __LITTLE_ENDIAN and
__BIG_ENDIAN can be defined simultaneously.
Please comment this message.
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-06-27 22:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27 22:24 byteorder problem Antony Pavlov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox