lkml.org 
[lkml]   [2004]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[patch] u64 casts
From
Date
Casts are considered harmful, because they bypass
type checking, but how do you print a u64 value?
You cast it to "unsigned long long" like this:

printk("%llu\n", (unsigned long long)foo);

Well, this is silly and ugly. As x86-64 has shown,
even a 64-bit port can use "long long" for 64-bit
values. This patch changes all other 64-bit ports.
It now becomes possible to avoid adding new casts
all over the place; existing ones may be removed
if so desired.

diff -Naurd old/include/asm-alpha/types.h new/include/asm-alpha/types.h
--- old/include/asm-alpha/types.h 2004-02-21 03:25:04.000000000 -0500
+++ new/include/asm-alpha/types.h 2004-02-27 15:37:40.000000000 -0500
@@ -27,8 +27,8 @@
typedef __signed__ int __s32;
typedef unsigned int __u32;

-typedef __signed__ long __s64;
-typedef unsigned long __u64;
+typedef __signed__ long long __s64;
+typedef unsigned long long __u64;

#endif /* __ASSEMBLY__ */

@@ -50,8 +50,8 @@
typedef signed int s32;
typedef unsigned int u32;

-typedef signed long s64;
-typedef unsigned long u64;
+typedef signed long long s64;
+typedef unsigned long long u64;

typedef u64 dma_addr_t;
typedef u64 dma64_addr_t;
diff -Naurd old/include/asm-ia64/types.h new/include/asm-ia64/types.h
--- old/include/asm-ia64/types.h 2004-02-21 03:20:17.000000000 -0500
+++ new/include/asm-ia64/types.h 2004-02-27 15:40:14.000000000 -0500
@@ -41,8 +41,8 @@
typedef __signed__ int __s32;
typedef unsigned int __u32;

-typedef __signed__ long __s64;
-typedef unsigned long __u64;
+typedef __signed__ long long __s64;
+typedef unsigned long long __u64;

/*
* These aren't exported outside the kernel to avoid name space clashes
diff -Naurd old/include/asm-mips/types.h new/include/asm-mips/types.h
--- old/include/asm-mips/types.h 2004-02-21 03:19:29.000000000 -0500
+++ new/include/asm-mips/types.h 2004-02-27 15:39:51.000000000 -0500
@@ -34,20 +34,11 @@
typedef __signed__ int __s32;
typedef unsigned int __u32;

-#if (_MIPS_SZLONG == 64)
-
-typedef __signed__ long __s64;
-typedef unsigned long __u64;
-
-#else
-
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif

-#endif
-
#endif /* __ASSEMBLY__ */

/*
@@ -68,20 +59,11 @@
typedef __signed int s32;
typedef unsigned int u32;

-#if (_MIPS_SZLONG == 64)
-
-typedef __signed__ long s64;
-typedef unsigned long u64;
-
-#else
-
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
typedef __signed__ long long s64;
typedef unsigned long long u64;
#endif

-#endif
-
#if (defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR)) \
|| defined(CONFIG_MIPS64)
typedef u64 dma_addr_t;
diff -Naurd old/include/asm-ppc64/types.h new/include/asm-ppc64/types.h
--- old/include/asm-ppc64/types.h 2004-02-21 03:21:11.000000000 -0500
+++ new/include/asm-ppc64/types.h 2004-02-27 15:41:06.000000000 -0500
@@ -32,8 +32,8 @@
typedef __signed__ int __s32;
typedef unsigned int __u32;

-typedef __signed__ long __s64;
-typedef unsigned long __u64;
+typedef __signed__ long long __s64;
+typedef unsigned long long __u64;

typedef struct {
__u32 u[4];
@@ -58,8 +58,8 @@
typedef signed int s32;
typedef unsigned int u32;

-typedef signed long s64;
-typedef unsigned long u64;
+typedef signed long long s64;
+typedef unsigned long long u64;

typedef __vector128 vector128;

diff -Naurd old/include/asm-s390/types.h new/include/asm-s390/types.h
--- old/include/asm-s390/types.h 2004-02-21 03:22:57.000000000 -0500
+++ new/include/asm-s390/types.h 2004-02-27 15:43:42.000000000 -0500
@@ -27,15 +27,10 @@
typedef __signed__ int __s32;
typedef unsigned int __u32;

-#ifndef __s390x__
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif
-#else /* __s390x__ */
-typedef __signed__ long __s64;
-typedef unsigned long __u64;
-#endif

/* A address type so that arithmetic can be done on it & it can be upgraded to
64 bit when necessary
@@ -67,13 +62,8 @@
typedef signed int s32;
typedef unsigned int u32;

-#ifndef __s390x__
typedef signed long long s64;
typedef unsigned long long u64;
-#else /* __s390x__ */
-typedef signed long s64;
-typedef unsigned long u64;
-#endif /* __s390x__ */

typedef u32 dma_addr_t;

diff -Naurd old/include/asm-sparc64/types.h new/include/asm-sparc64/types.h
--- old/include/asm-sparc64/types.h 2004-02-21 03:28:23.000000000 -0500
+++ new/include/asm-sparc64/types.h 2004-02-27 15:42:19.000000000 -0500
@@ -28,8 +28,8 @@
typedef __signed__ int __s32;
typedef unsigned int __u32;

-typedef __signed__ long __s64;
-typedef unsigned long __u64;
+typedef __signed__ long long __s64;
+typedef unsigned long long __u64;

#endif /* __ASSEMBLY__ */

@@ -48,8 +48,8 @@
typedef __signed__ int s32;
typedef unsigned int u32;

-typedef __signed__ long s64;
-typedef unsigned long u64;
+typedef __signed__ long long s64;
+typedef unsigned long long u64;

/* Dma addresses come in generic and 64-bit flavours. */



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:01    [from the cache]
©2003-2011 Jasper Spaans