On Saturday 15 of November 2003 16:41, Jakub Bogusz wrote:

> Może to "-ansi" w opcjach przeszkadza?

-ansi na pewno przeszkadza, bo wylacza (i zreszta slusznie) typ __u64.

> Teraz pytanie - czy:
> - bierzemy jako bazę paczkę nagłówków z RH i próbujemy łatać nakładając
>   kolejne patche (takowe będą - te nagłówki nie są doskonałe; poza tym
>   w ostatnich wersjach nie ma sparca)
>
> - czy wrzucamy bazowe nagłówki[1] do modułu w CVS[2] i w ten sposób
>   poprawiamy, pakując co jakiś czas nową wersję
>
> [1] z RH, 2.4.22 czy 2.6.0-test9? nie uciekniemy od porównywania ich :/
> [2] świadomie napisałem _te_ 3 litery ;)

skrobnalem taki testowy program: test.cpp

#include <asm/byteorder.h>
#include <stdio.h>
__u64 x = (__u64)0x0000000000000001ULL;
int main()
{
  printf("x = %016llx\n", x);
  __arch__swab64s(&x);
  printf("x = %016llx\n", x);
}

proba kompilacji /g++ -Wall -O3 -pedantic test.cpp/ konczy sie bledem.

# In file included from /usr/include/linux/byteorder/little_endian.h:11,
#                  from /usr/include/asm/byteorder.h:65,
#                  from test.cpp:1:
# /usr/include/linux/byteorder/swab.h:
#   In function `const __u32 __fswab24(unsigned int)':
# /usr/include/linux/byteorder/swab.h:174:
#   error: ISO C++ forbids braced-groups within expressions
# /usr/include/linux/byteorder/swab.h:174:
#   error: ISO C++ forbids braced-groups within expressions
# /usr/include/linux/byteorder/swab.h:
#   In function `__u32 __swab24p(__u32*)':
# /usr/include/linux/byteorder/swab.h:178:
#   error: ISO C++ forbids braced-groups within expressions
# /usr/include/linux/byteorder/swab.h:178:
#   error: ISO C++ forbids braced-groups within expressions
# /usr/include/linux/byteorder/swab.h:
#   In function `void __swab24s(__u32*)':
# /usr/include/linux/byteorder/swab.h:182:
#   error: ISO C++ forbids braced-groups within expressions
# /usr/include/linux/byteorder/swab.h:182:
#   error: ISO C++ forbids braced-groups within expressions
# test.cpp:4:18: warning: use of C99 long long integer constant

po aplikacji latki na kernel-source-2.4.22-1.5
i rekompilacji pozostaje tylko:

# test.cpp:4:18: warning: use of C99 long long integer constant

-- 
The only thing necessary for the triumph of evil
  is for good men to do nothing.
                                           - Edmund Burke
--- linux-2.4.22/include/linux/byteorder/swab.h.orig	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22/include/linux/byteorder/swab.h	2003-11-15 22:07:35.000000000 +0000
@@ -18,87 +18,57 @@
 /* casts are necessary for constants, because we never know how for sure
  * how U/UL/ULL map to __u16, __u32, __u64. At least not in a portable way.
  */
-#define ___swab16(x) \
-({ \
-	__u16 __x = (x); \
-	((__u16)( \
-		(((__u16)(__x) & (__u16)0x00ffU) << 8) | \
-		(((__u16)(__x) & (__u16)0xff00U) >> 8) )); \
-})
-
-#define ___swab24(x) \
-({ \
-	__u32 __x = (x); \
-	((__u32)( \
-		((__x & (__u32)0x000000ffUL) << 16) | \
-		 (__x & (__u32)0x0000ff00UL)        | \
-		((__x & (__u32)0x00ff0000UL) >> 16) )); \
-})
-
-#define ___swab32(x) \
-({ \
-	__u32 __x = (x); \
-	((__u32)( \
-		(((__u32)(__x) & (__u32)0x000000ffUL) << 24) | \
-		(((__u32)(__x) & (__u32)0x0000ff00UL) <<  8) | \
-		(((__u32)(__x) & (__u32)0x00ff0000UL) >>  8) | \
-		(((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); \
-})
-
-#define ___swab64(x) \
-({ \
-	__u64 __x = (x); \
-	((__u64)( \
-		(__u64)(((__u64)(__x) & (__u64)0x00000000000000ffULL) << 56) | \
-		(__u64)(((__u64)(__x) & (__u64)0x000000000000ff00ULL) << 40) | \
-		(__u64)(((__u64)(__x) & (__u64)0x0000000000ff0000ULL) << 24) | \
-		(__u64)(((__u64)(__x) & (__u64)0x00000000ff000000ULL) <<  8) | \
-	        (__u64)(((__u64)(__x) & (__u64)0x000000ff00000000ULL) >>  8) | \
-		(__u64)(((__u64)(__x) & (__u64)0x0000ff0000000000ULL) >> 24) | \
-		(__u64)(((__u64)(__x) & (__u64)0x00ff000000000000ULL) >> 40) | \
-		(__u64)(((__u64)(__x) & (__u64)0xff00000000000000ULL) >> 56) )); \
-})
-
-#define ___constant_swab16(x) \
-	((__u16)( \
-		(((__u16)(x) & (__u16)0x00ffU) << 8) | \
-		(((__u16)(x) & (__u16)0xff00U) >> 8) ))
-#define ___constant_swab24(x) \
-	((__u32)( \
-		(((__u32)(x) & (__u32)0x000000ffU) << 16) | \
-		(((__u32)(x) & (__u32)0x0000ff00U)	  | \
-		(((__u32)(x) & (__u32)0x00ff0000U) >> 16) ))
-#define ___constant_swab32(x) \
-	((__u32)( \
-		(((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
-		(((__u32)(x) & (__u32)0x0000ff00UL) <<  8) | \
-		(((__u32)(x) & (__u32)0x00ff0000UL) >>  8) | \
-		(((__u32)(x) & (__u32)0xff000000UL) >> 24) ))
-#define ___constant_swab64(x) \
-	((__u64)( \
-		(__u64)(((__u64)(x) & (__u64)0x00000000000000ffULL) << 56) | \
-		(__u64)(((__u64)(x) & (__u64)0x000000000000ff00ULL) << 40) | \
-		(__u64)(((__u64)(x) & (__u64)0x0000000000ff0000ULL) << 24) | \
-		(__u64)(((__u64)(x) & (__u64)0x00000000ff000000ULL) <<  8) | \
-	        (__u64)(((__u64)(x) & (__u64)0x000000ff00000000ULL) >>  8) | \
-		(__u64)(((__u64)(x) & (__u64)0x0000ff0000000000ULL) >> 24) | \
-		(__u64)(((__u64)(x) & (__u64)0x00ff000000000000ULL) >> 40) | \
-		(__u64)(((__u64)(x) & (__u64)0xff00000000000000ULL) >> 56) ))
+inline __u16 ___swab16(const __u16 x)
+{
+  return (((x & (__u16)0x00ffU) << 8) | ((x & (__u16)0xff00U) >> 8));
+}
+
+inline __u32 ___swab24(const __u32 x)
+{
+  return (((x & (__u32)0x000000ffUL) << 16) |
+           (x & (__u32)0x0000ff00UL) |
+          ((x & (__u32)0x00ff0000UL) >> 16));
+}
+
+inline __u32 ___swab32(const __u32 x)
+{
+  return (((x & (__u32)0x000000ffUL) << 24) |
+          ((x & (__u32)0x0000ff00UL) <<  8) |
+          ((x & (__u32)0x00ff0000UL) >>  8) |
+          ((x & (__u32)0xff000000UL) >> 24));
+}
+
+inline __u64 ___swab64(const __u64 x)
+{
+  return (((x & (__u64)0x00000000000000ffULL) << 56) |
+          ((x & (__u64)0x000000000000ff00ULL) << 40) |
+          ((x & (__u64)0x0000000000ff0000ULL) << 24) |
+          ((x & (__u64)0x00000000ff000000ULL) <<  8) |
+          ((x & (__u64)0x000000ff00000000ULL) >>  8) |
+          ((x & (__u64)0x0000ff0000000000ULL) >> 24) |
+          ((x & (__u64)0x00ff000000000000ULL) >> 40) |
+          ((x & (__u64)0xff00000000000000ULL) >> 56));
+}
+
+#define ___constant_swab16(x) ___swab16(x)
+#define ___constant_swab24(x) ___swab24(x)
+#define ___constant_swab32(x) ___swab64(x)
+#define ___constant_swab64(x) ___swab64(x)
 
 /*
  * provide defaults when no architecture-specific optimization is detected
  */
 #ifndef __arch__swab16
-#  define __arch__swab16(x) ({ __u16 __tmp = (x) ; ___swab16(__tmp); })
+#  define __arch__swab16(x) ___swab16(x)
 #endif
 #ifndef __arch__swab24
-#  define __arch__swab24(x) ({ __u32 __tmp = (x) ; ___swab24(__tmp); })
+#  define __arch__swab24(x) ___swab24(x)
 #endif
 #ifndef __arch__swab32
-#  define __arch__swab32(x) ({ __u32 __tmp = (x) ; ___swab32(__tmp); })
+#  define __arch__swab32(x) ___swab32(x)
 #endif
 #ifndef __arch__swab64
-#  define __arch__swab64(x) ({ __u64 __tmp = (x) ; ___swab64(__tmp); })
+#  define __arch__swab64(x) ___swab64(x)
 #endif
 
 #ifndef __arch__swab16p
@@ -115,16 +85,16 @@
 #endif
 
 #ifndef __arch__swab16s
-#  define __arch__swab16s(x) do { *(x) = __arch__swab16p((x)); } while (0)
+#  define __arch__swab16s(x) (*(x) = __arch__swab16p(x))
 #endif
 #ifndef __arch__swab24s
-#  define __arch__swab24s(x) do { *(x) = __arch__swab24p((x)); } while (0)
+#  define __arch__swab24s(x) (*(x) = __arch__swab24p(x))
 #endif
 #ifndef __arch__swab32s
-#  define __arch__swab32s(x) do { *(x) = __arch__swab32p((x)); } while (0)
+#  define __arch__swab32s(x) (*(x) = __arch__swab32p(x))
 #endif
 #ifndef __arch__swab64s
-#  define __arch__swab64s(x) do { *(x) = __arch__swab64p((x)); } while (0)
+#  define __arch__swab64s(x) (*(x) = __arch__swab64p(x))
 #endif
 
 

__________________________________________________________
nie pytaj co inni zrobili dla pld, pomysl ile sam zrobiles

Odpowiedź listem elektroniczym