2.6.0-test7 byteorder.h ( as you go AGAIN! )

From: Steven Michalske
Date: Thu Oct 09 2003 - 21:20:16 EST


I am running 2.6.0-test7 and this issue is still in the kernel, I guess i'll
have to argue for the fix yet again.

First some background.

This problem was first introduced with the XFS patches back in the 2.4.21
series or so. and it has continued on since then. reading the list i have
seen many patches to attempt to fix this issue.

In my digging I have uncovered that this is because the type __u64 is guarded
as follows

#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif

now with these types being inside of a #ifdef i would expect any subsquent
type dependent to be #ifdefed out as well.

but in byteorder.h

This function is defined:
static inline __u64 ___arch__swab64(__u64 val) with out any protection

Attached is my proposed patch to correct this error.

This patch is required because this file is included from the file
include/linux/cdrom.h

Which states
snip lines 17-18
* As of Linux 2.1.x, all Linux CD-ROM application programs will use this
* (and only this) include file.
end snip

This issuse will always occur unless we patch the file to protect the
___arch__swab64 function in the same fashion as its return type.

Steven Michalske
aka Hardkrash

--- linux-2.6.0-test7/include/asm-i386/byteorder.h.scm 2003-10-09
21:52:16.727080480 -0400
+++ linux-2.6.0-test7/include/asm-i386/byteorder.h 2003-10-08
17:20:10.000000000 -0400
@@ -34,7 +34,7 @@
return x;
}

-
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
static inline __u64 ___arch__swab64(__u64 val)
{
union {
@@ -55,10 +55,11 @@
}

#define __arch__swab64(x) ___arch__swab64(x)
+#define __BYTEORDER_HAS_U64__
+#endif
#define __arch__swab32(x) ___arch__swab32(x)
#define __arch__swab16(x) ___arch__swab16(x)

-#define __BYTEORDER_HAS_U64__

#endif /* __GNUC__ */

Attachment: byteorder.tar.bz2
Description: application/tbz

Attachment: pgp00001.pgp
Description: signature