From: Albert Cahalan <albert@users.sf.net>
To: linux-kernel mailing list <linux-kernel@vger.kernel.org>
Cc: Linus Torvalds <torvalds@osdl.org>, Andrew Morton OSDL <akpm@osdl.org>
Subject: [patch] u64 casts
Date: 27 Feb 2004 15:58:42 -0500 [thread overview]
Message-ID: <1077915522.2255.28.camel@cube> (raw)
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. */
next reply other threads:[~2004-02-27 23:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-27 20:58 Albert Cahalan [this message]
2004-02-28 0:18 ` [patch] u64 casts David Mosberger
2004-02-27 22:16 ` Albert Cahalan
2004-02-28 0:45 ` David Mosberger
2004-02-27 22:53 ` Albert Cahalan
2004-02-28 7:44 ` David S. Miller
2004-02-28 10:42 ` Jakub Jelinek
2004-02-28 14:46 ` [patch] new version, u64 cast avoidance Albert Cahalan
2004-02-28 23:58 ` Benjamin Herrenschmidt
2004-02-28 23:59 ` Benjamin Herrenschmidt
2004-02-28 22:21 ` Albert Cahalan
2004-02-29 1:08 ` Benjamin Herrenschmidt
2004-02-28 23:49 ` Albert Cahalan
2004-02-29 3:25 ` Matt Mackall
2004-02-29 1:01 ` [patch] 3rd " Albert Cahalan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1077915522.2255.28.camel@cube \
--to=albert@users.sf.net \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox