u64 casts
PATCH 1/1 u64 casts
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.
include/asm-alpha/types.h +4 -4
@@ -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 ;
include/asm-ia64/types.h +2 -2
@@ -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
include/asm-mips/types.h +0 -18
@@ -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 ;
include/asm-ppc64/types.h +4 -4
@@ -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 ;
include/asm-s390/types.h +0 -10
@@ -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 ;
include/asm-sparc64/types.h +4 -4
@@ -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. */
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Albert Cahalan
Albert> Casts are considered harmful, because they bypass Albert> type checking, but how do you print a u64 value? Albert> You cast it to "unsigned long long" like this:
Albert> printk("%llu\n", (unsigned long long)foo);Albert> Well, this is silly and ugly. As x86-64 has shown, Albert> even a 64-bit port can use "long long" for 64-bit Albert> values. This patch changes all other 64-bit ports. Albert> It now becomes possible to avoid adding new casts Albert> all over the place; existing ones may be removed Albert> if so desired.
Did you verify that none of the kernel header files that are still being used by glibc contain declarations based on __u64 or __s64? If not, your patch breaks user-level code.
--david
Quoted 15 lines · David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Albert Cahalan
Albert> Casts are considered harmful, because they bypass Albert> type checking, but how do you print a u64 value? Albert> You cast it to "unsigned long long" like this:
Albert> printk("%llu\n", (unsigned long long)foo);Albert> Well, this is silly and ugly. As x86-64 has shown, Albert> even a 64-bit port can use "long long" for 64-bit Albert> values. This patch changes all other 64-bit ports. Albert> It now becomes possible to avoid adding new casts Albert> all over the place; existing ones may be removed Albert> if so desired.
Quoted 3 lines
Did you verify that none of the kernel header files that are still being used by glibc contain declarations based on
__u64or__s64? If not, your patch breaks user-level code.
Supposing that this is the case, you may get warnings. Well, good, maybe somebody will fix glibc. The data types are obviously the same size, so no data-corrupting errors will result.
Note that x86-64, a 64-bit port using glibc, is just fine with "long long" already.
Also note that /usr/include/asm is a modified copy of kernel headers. It won't be suddenly changing as a result of the patch, even after a kernel upgrade. (the symlink hasn't been OK since libc5 days)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Albert Cahalan
Albert> Supposing that this is the case, you may get warnings.
Well, then do it on your own kernel/system. I'm not interested in spending time on this now, so please don't touch ia64 unless you verified that all the other pieces are in place.
--david
Quoted 7 lines · David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Albert Cahalan
Albert> Supposing that this is the case, you may get warnings.
Well, then do it on your own kernel/system. I'm not interested in spending time on this now, so please don't touch ia64 unless you verified that all the other pieces are in place.
Remember, that is only if all of:
1. glibc improperly uses raw kernel headers
2. usage is in such a way that warnings happen
3. you rebuild glibc with these kernel headers
If this is really the case, the warnings may be eliminated by running a 1-line sed script over the headers as they are imported into glibc. It's something like this: s/__u64/u_int64_t/
In return, you can have type-safety w/o warnings during the kernel build.
In my example, suppose that foo is a pointer to u64. You'd like to print the u64. If by mistake you use the pointer itself, you won't be getting a warning. The cast hides it.
Quoted 7 lines · On Fri, 27 Feb 2004 16:45:16 -0800 David Mosberger <[email protected]>…
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Albert Cahalan
Albert> Supposing that this is the case, you may get warnings.
Well, then do it on your own kernel/system. I'm not interested in spending time on this now, so please don't touch ia64 unless you verified that all the other pieces are in place.
Yes, and I already know that trying to do things this way results in more warnings and more problems on sparc64, as I've tried it.
Quoted 1 line · Albert Cahalan
Supposing that this is the case, you may get warnings.
It wouldn't be just about warnings if somebody uses current kernel headers for /usr/include/linux and /usr/include/asm. Think about C++ name mangling, there it matters a lot of a type is long long or just long, although they are the same size.
It is true that (hopefully) most of the distributions use separate modified kernel headers and glibc uses only very few kernel headers in its headers, but there are certainly many apps in the wild who #include <linux/*> or #include <asm/*> and I'm afraid still some people use newest kernel headers for userland stuff.
So if you want to change that, I'd suggest to
#ifdef __KERNEL__
typedef unsigned long long __u64;
#else
typedef unsigned long __u64; /* Provided it has been defined that way before */ #endif
Jakub
PATCH 1/1 new version, u64 cast avoidance
Quoted 8 lines · Jakub Jelinek
Quoted 1 line · Albert Cahalan
Supposing that this is the case, you may get warnings.
It wouldn't be just about warnings if somebody uses current kernel headers for
/usr/include/linuxand/usr/include/asm. Think about C++ name mangling, there it matters a lot of a type is long long or just long, although they are the same size.
That's disgusting.
Quoted 6 lines
So if you want to change that, I'd suggest to
#ifdef__KERNEL__
typedef unsigned long long__u64;
#else
typedef unsigned long__u64; /* Provided it has been defined that way before */ #endif
OK, got it. For the changelog:
If the u64 type is "unsigned long" on some platforms and "unsigned long long" on others, a cast is often required to avoid warnings. Type safety goes away when you do that; even a pointer is accepted. Thus the u64 type should be "unsigned long long" on all platforms. Now this:
printk("%llu\n", (unsigned long long)some_u64_value);
can become this:
printk("%llu\n", some_u64_value);
asm-alpha/types.h | 14 ++++++++++++-- asm-ia64/types.h | 10 ++++++++++ asm-mips/types.h | 25 ++++++++++++------------- asm-ppc64/types.h | 14 ++++++++++++-- asm-s390/types.h | 17 +++++++++-------- asm-sparc64/types.h | 14 ++++++++++++-- 6 files changed, 67 insertions(+), 27 deletions(-)
include/asm-alpha/types.h +12 -2
@@ -27,8 +27,18 @@ typedef __signed__ int __s32;typedef unsigned int __u32 ; +/* +* We want "long long" in the kernel to reduce the need for casts, +* but foul user-space C++ code might rely on this being "long". +* (name mangling leads to a purely user-space ABI problem) +*/ +#ifdef __KERNEL__ +typedef __signed__ long long __s64 ; +typedef unsigned long long __u64 ; +#else typedef __signed__ long __s64 ;typedef unsigned long __u64 ; +#endif #endif /* __ASSEMBLY__ */
@@ -50,8 +60,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 ;
include/asm-ia64/types.h +10 -0
@@ -41,8 +41,18 @@ typedef __signed__ int __s32;typedef unsigned int __u32 ; +/* +* We want "long long" in the kernel to reduce the need for casts, +* but foul user-space C++ code might rely on this being "long". +* (name mangling leads to a purely user-space ABI problem) +*/ +#ifdef __KERNEL__ +typedef __signed__ long long __s64 ; +typedef unsigned long long __u64 ; +#else typedef __signed__ long __s64 ;typedef unsigned long __u64 ; +#endif /* * These aren't exported outside the kernel to avoid name space clashes
include/asm-mips/types.h +12 -13
@@ -36,8 +36,18 @@#if (_MIPS_SZLONG ==64 ) +/* +* We want "long long" in the kernel to reduce the need for casts, +* but foul user-space C++ code might rely on this being "long". +* (name mangling leads to a purely user-space ABI problem) +*/ +#ifdef __KERNEL__ +typedef __signed__ long long __s64 ; +typedef unsigned long long __u64 ; +#else typedef __signed__ long __s64 ;typedef unsigned long __u64 ; +#endif #else
@@ -68,19 +78,8 @@ 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 +typedef __s64 s64 ; +typedef __u64 u64 ;#if (defined(CONFIG_HIGHMEM ) && defined(CONFIG_64BIT_PHYS_ADDR )) \ || defined(CONFIG_MIPS64 )
include/asm-ppc64/types.h +12 -2
@@ -32,8 +32,18 @@ typedef __signed__ int __s32;typedef unsigned int __u32 ; +/* +* We want "long long" in the kernel to reduce the need for casts, +* but foul user-space C++ code might rely on this being "long". +* (name mangling leads to a purely user-space ABI problem) +*/ +#ifdef __KERNEL__ +typedef __signed__ long long __s64 ; +typedef unsigned long long __u64 ; +#else typedef __signed__ long __s64 ;typedef unsigned long __u64 ; +#endif typedef struct { __u32 u[4];
@@ -58,8 +68,8 @@typedef signed int s32 ;typedef unsigned int u32 ; -typedef signed long s64 ; -typedef unsigned long u64 ; +typedef __s64 s64 ; +typedef __u64 u64 ;typedef __vector128 vector128 ;
include/asm-s390/types.h +9 -8
@@ -27,7 +27,13 @@ typedef __signed__ int __s32;typedef unsigned int __u32 ; -#ifndef __s390x__ + +/* +* We want "long long" in the kernel to reduce the need for casts, +* but foul 64-bit user-space C++ code might rely on this being "long". +* (name mangling leads to a purely user-space ABI problem) +*/ +#if defined(__KERNEL__) || !defined(__s390x__)#if defined(__GNUC__) && !defined(__STRICT_ANSI__)typedef __signed__ long long __s64 ;typedef unsigned long long __u64 ;
@@ -67,13 +73,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 __s64 s64 ; +typedef __u64 u64 ;typedef u32 dma_addr_t ;
include/asm-sparc64/types.h +12 -2
@@ -28,8 +28,18 @@ typedef __signed__ int __s32;typedef unsigned int __u32 ; +/* +* We want "long long" in the kernel to reduce the need for casts, +* but foul user-space C++ code might rely on this being "long". +* (name mangling leads to a purely user-space ABI problem) +*/ +#ifdef __KERNEL__ +typedef __signed__ long long __s64 ; +typedef unsigned long long __u64 ; +#else typedef __signed__ long __s64 ;typedef unsigned long __u64 ; +#endif #endif /* __ASSEMBLY__ */
@@ -48,8 +58,8 @@ typedef __signed__ int s32;typedef unsigned int u32 ; -typedef __signed__ long s64 ; -typedef unsigned long u64 ; +typedef __s64 s64 ; +typedef __u64 u64 ;/* Dma addresses come in generic and 64-bit flavours. */
Re: [patch] new version, u64 cast avoidance
Quoted 2 lines
asm-ppc64/types.h | 14 ++++++++++++--
Please, do not mess with ppc64 at this point, I'm not sure I like the approach anyway, I can live with some warnings in printk...
Ben.
Re: [patch] new version, u64 cast avoidance
Quoted 5 lines · Benjamin Herrenschmidt
Quoted 1 line
asm-ppc64/types.h | 14 ++++++++++++--Please, do not mess with ppc64 at this point, I'm not sure I like the approach anyway, I can live with some warnings in printk...
I meant some casts of course ;)
Ben.
Re: [patch] new version, u64 cast avoidance
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 5 lines · Benjamin Herrenschmidt
Quoted 1 line
asm-ppc64/types.h | 14 ++++++++++++--Please, do not mess with ppc64 at this point, I'm not sure I like the approach anyway, I can live with some warnings in printk...
I meant some casts of course ;)
If only those were casts under arch/ppc64, sure. All 32-bit ports and x86-64 are being affected. Besides being ugly and verbose, the current situation isn't type-safe.
I'd be interested to hear why you don't like the approach, and interested to hear your alternatives. For example:
a. my solution, as given
b. move u64 and friends to include/linux/*.h c. you promise to never complain about warnings d. printk("Ugly: " U64_FMT "\n", some_u64_value); e. you patch gcc to modify format strings :-) f. ...
In other words, how do you propose to eliminate the casts?
Re: [patch] new version, u64 cast avoidance
Quoted 10 lines
a. my solution, as given
b. move u64 and friends toinclude/linux/*.hc. you promise to never complain about warnings d.printk("Ugly: " U64_FMT "\n", some_u64_value); e. you patch gcc to modify format strings :-) f. ...In other words, how do you propose to eliminate the casts?
Can't we live with those casts at least for a while ?
I don't know honestly what is the best solution, they all sound equally ugly to me.
Ben.
Re: [patch] new version, u64 cast avoidance
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 7 lines
a. my solution, as given
b. move u64 and friends toinclude/linux/*.hc. you promise to never complain about warnings d.printk("Ugly: " U64_FMT "\n", some_u64_value); e. you patch gcc to modify format strings :-) f. ...
Quoted 7 lines
Quoted 2 lines
In other words, how do you propose to eliminate the casts?
Can't we live with those casts at least for a while ?
I don't know honestly what is the best solution,
they all sound equally ugly to me.
They are, until you count the number of occurances. My solution, as given, puts #if crud in just 6 files. The existing situation has crud all over the place, growing day by day.
If there is some patch merging issue, I'd be happy to send you a separate patch for ppc64.
If you'd prefer, I can create <linux/bit_types.h> for these types and pull that in. For now it would be included by all the asm-*/types.h files. Like so:
#if defined(_BROKEN_USER_TYPES) && !defined(__KERNEL__) typedef unsigned long __u64;
typedef __signed__ long __s64;
#else
#if defined(__GNUC__)__extension__ typedef unsigned long long __u64; __extension__ typedef __signed__ long long __s64; endif
#endif
/* ... */
Re: [patch] new version, u64 cast avoidance
Quoted 28 lines · Albert Cahalan
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 7 lines
a. my solution, as given
b. move u64 and friends toinclude/linux/*.hc. you promise to never complain about warnings d.printk("Ugly: " U64_FMT "\n", some_u64_value); e. you patch gcc to modify format strings :-) f. ...Quoted 7 lines
Quoted 2 lines
In other words, how do you propose to eliminate the casts?
Can't we live with those casts at least for a while ?
I don't know honestly what is the best solution,
they all sound equally ugly to me.They are, until you count the number of occurances. My solution, as given, puts #if crud in just 6 files. The existing situation has crud all over the place, growing day by day.
If there is some patch merging issue, I'd be happy to send you a separate patch for ppc64.
If you'd prefer, I can create <
linux/bit_types.h> for these types and pull that in. For now it would be included by all theasm-*/types.hfiles. Like so:
Quoted 10 lines
#if
defined(_BROKEN_USER_TYPES)&& !defined(__KERNEL__) typedef unsigned long__u64;
typedef__signed__long__s64;
#else
#ifdefined(__GNUC__)__extension__typedef unsigned long long__u64;__extension__typedef__signed__long long__s64; endif
#endif
/* ... */
And if we can actually manage to eliminate the long-deprecated inclusion of kernel headers by userspace in 2.7, we can kill that conditional too.
Signature · 1 line
Matt Mackall : http://www.selenic.com : Linux development and consulting
PATCH 1/1 3rd version, u64 cast avoidance
In reply to Benjamin HerrenschmidtThis is option 'b', which eliminates lots of redundant code. Mult-width arch are handled.
User-space types are unchanged. For the kernel, all u64 and related types are done with long long, eliminating the need to lose type-safety with casts all over the place.
asm-alpha/types.h | 30 ++---------------------------- asm-arm/types.h | 31 +------------------------------ asm-arm26/types.h | 31 +------------------------------ asm-cris/types.h | 31 +------------------------------ asm-h8300/types.h | 31 +------------------------------ asm-i386/types.h | 31 +------------------------------ asm-ia64/types.h | 30 ++---------------------------- asm-m68k/types.h | 31 +------------------------------ asm-mips/types.h | 49 ++----------------------------------------------- asm-parisc/types.h | 31 +------------------------------ asm-ppc/types.h | 26 +------------------------- asm-ppc64/types.h | 30 ++---------------------------- asm-s390/types.h | 42 +++--------------------------------------- asm-sh/types.h | 31 +------------------------------ asm-sparc/types.h | 24 +----------------------- asm-sparc64/types.h | 30 ++---------------------------- asm-v850/types.h | 31 +------------------------------ asm-x86_64/types.h | 29 +---------------------------- linux/bit_types.h | 37 +++++++++++++++++++++++++++++++++++++ 19 files changed, 62 insertions(+), 544 deletions(-)
include/asm-alpha/types.h +2 -28
@@ -13,22 +13,8 @@typedef unsigned int umode_t ; -/* -* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the -* header files exported to user space -*/ - -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -typedef __signed__ long __s64 ; -typedef unsigned long __u64 ; +#define _BROKEN_U64_S64 +#include <linux/bit_types.h> #endif /* __ASSEMBLY__ */
@@ -41,18 +27,6 @@#ifndef __ASSEMBLY__ -typedef signed char s8 ; -typedef unsigned char u8 ; - -typedef signed short s16 ; -typedef unsigned short u16 ; - -typedef signed int s32 ; -typedef unsigned int u32 ; - -typedef signed long s64 ; -typedef unsigned long u64 ; -typedef u64 dma_addr_t ;typedef u64 dma64_addr_t ;
include/asm-arm/types.h +1 -30
@@ -5,24 +5,7 @@typedef unsigned short umode_t ; -/* -* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the -* header files exported to user space -*/ - -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64 ; -typedef unsigned long long __u64 ; -#endif +#include <linux/bit_types.h> #endif /* __ASSEMBLY__ */
@@ -35,18 +18,6 @@#ifndef __ASSEMBLY__ -typedef signed char s8 ; -typedef unsigned char u8 ; - -typedef signed short s16 ; -typedef unsigned short u16 ; - -typedef signed int s32 ; -typedef unsigned int u32 ; - -typedef signed long long s64 ; -typedef unsigned long long u64 ; -/* Dma addresses are 32-bits wide. */ typedef u32 dma_addr_t ;
include/asm-arm26/types.h +1 -30
@@ -5,24 +5,7 @@typedef unsigned short umode_t ; -/* -* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the -* header files exported to user space -*/ - -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64 ; -typedef unsigned long long __u64 ; -#endif +#include <linux/bit_types.h> #endif /* __ASSEMBLY__ */
@@ -35,18 +18,6 @@#ifndef __ASSEMBLY__ -typedef signed char s8 ; -typedef unsigned char u8 ; - -typedef signed short s16 ; -typedef unsigned short u16 ; - -typedef signed int s32 ; -typedef unsigned int u32 ; - -typedef signed long long s64 ; -typedef unsigned long long u64 ; -/* Dma addresses are 32-bits wide. */ typedef u32 dma_addr_t ;
include/asm-cris/types.h +1 -30
@@ -5,24 +5,7 @@typedef unsigned short umode_t ; -/* -* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the -* header files exported to user space -*/ - -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64 ; -typedef unsigned long long __u64 ; -#endif +#include <linux/bit_types.h> #endif /* __ASSEMBLY__ */
@@ -35,18 +18,6 @@#ifndef __ASSEMBLY__ -typedef signed char s8 ; -typedef unsigned char u8 ; - -typedef signed short s16 ; -typedef unsigned short u16 ; - -typedef signed int s32 ; -typedef unsigned int u32 ; - -typedef signed long long s64 ; -typedef unsigned long long u64 ; -/* Dma addresses are 32-bits wide, just like our other addresses. */ typedef u32 dma_addr_t ;
include/asm-h8300/types.h +1 -30
@@ -13,42 +13,13 @@typedef unsigned short umode_t ; -/* -* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the -* header files exported to user space -*/ - -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64 ; -typedef unsigned long long __u64 ; -#endif +#include <linux/bit_types.h> /* * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ -typedef signed char s8 ; -typedef unsigned char u8 ; - -typedef signed short s16 ; -typedef unsigned short u16 ; - -typedef signed int s32 ; -typedef unsigned int u32 ; - -typedef signed long long s64 ; -typedef unsigned long long u64 ; -#define BITS_PER_LONG 32/* Dma addresses are 32-bits wide. */
include/asm-i386/types.h +1 -30
@@ -5,24 +5,7 @@typedef unsigned short umode_t ; -/* -* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the -* header files exported to user space -*/ - -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64 ; -typedef unsigned long long __u64 ; -#endif +#include <linux/bit_types.h> #endif /* __ASSEMBLY__ */
@@ -37,18 +20,6 @@#include <linux/config.h> -typedef signed char s8 ; -typedef unsigned char u8 ; - -typedef signed short s16 ; -typedef unsigned short u16 ; - -typedef signed int s32 ; -typedef unsigned int u32 ; - -typedef signed long long s64 ; -typedef unsigned long long u64 ; -/* DMA addresses come in generic and 64-bit flavours. */ #ifdef CONFIG_HIGHMEM64G
include/asm-ia64/types.h +2 -28
@@ -27,40 +27,14 @@typedef unsigned int umode_t ; -/* -* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the -* header files exported to user space -*/ - -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -typedef __signed__ long __s64 ; -typedef unsigned long __u64 ; +#define _BROKEN_U64_S64 +#include <linux/bit_types.h> /* * These aren't exported outside the kernel to avoid name space clashes */ # ifdef __KERNEL__ -typedef __s8 s8 ; -typedef __u8 u8 ; - -typedef __s16 s16 ; -typedef __u16 u16 ; - -typedef __s32 s32 ; -typedef __u32 u32 ; - -typedef __s64 s64 ; -typedef __u64 u64 ; -#define BITS_PER_LONG 64/* DMA addresses are 64-bits wide, in general. */
include/asm-m68k/types.h +1 -30
@@ -13,24 +13,7 @@typedef unsigned short umode_t ; -/* -* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the -* header files exported to user space -*/ - -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64 ; -typedef unsigned long long __u64 ; -#endif +#include <linux/bit_types.h> #endif /* __ASSEMBLY__ */
@@ -43,18 +26,6 @@#ifndef __ASSEMBLY__ -typedef signed char s8 ; -typedef unsigned char u8 ; - -typedef signed short s16 ; -typedef unsigned short u16 ; - -typedef signed int s32 ; -typedef unsigned int u32 ; - -typedef signed long long s64 ; -typedef unsigned long long u64 ; -/* DMA addresses are always 32-bits wide */ typedef u32 dma_addr_t ;
include/asm-mips/types.h +2 -47
64 lines not on this page · raw message
include/asm-parisc/types.h +1 -30
@@ -5,24 +5,7 @@typedef unsigned short umode_t ; -/* -* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the -* header files exported to user space -*/ - -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64 ; -typedef unsigned long long __u64 ; -#endif +#include <linux/bit_types.h> #endif /* __ASSEMBLY__ */
@@ -39,18 +22,6 @@#ifndef __ASSEMBLY__ -typedef signed char s8 ; -typedef unsigned char u8 ; - -typedef signed short s16 ; -typedef unsigned short u16 ; - -typedef signed int s32 ; -typedef unsigned int u32 ; - -typedef signed long long s64 ; -typedef unsigned long long u64 ; -/* Dma addresses are 32-bits wide. */ typedef u32 dma_addr_t ;
include/asm-ppc/types.h +1 -25
@@ -3,19 +3,7 @@ #ifndef __ASSEMBLY__ -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64; -typedef unsigned long long __u64; -#endif +#include <linux/bit_types.h> typedef struct { __u32 u[4];
@@ -37,18 +25,6 @@#ifndef __ASSEMBLY__ -typedef signed char s8 ; -typedef unsigned char u8 ; - -typedef signed short s16 ; -typedef unsigned short u16 ; - -typedef signed int s32 ; -typedef unsigned int u32 ; - -typedef signed long long s64 ; -typedef unsigned long long u64 ; -typedef __vector128 vector128 ;/* DMA addresses are 32-bits wide */
include/asm-ppc64/types.h +2 -28
@@ -18,22 +18,8 @@typedef unsigned int umode_t ; -/* -* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the -* header files exported to user space -*/ - -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -typedef __signed__ long __s64 ; -typedef unsigned long __u64 ; +#define _BROKEN_U64_S64 +#include <linux/bit_types.h> typedef struct { __u32 u[4];
@@ -49,18 +35,6 @@#ifndef __ASSEMBLY__ -typedef signed char s8 ; -typedef unsigned char u8 ; - -typedef signed short s16 ; -typedef unsigned short u16 ; - -typedef signed int s32 ; -typedef unsigned int u32 ; - -typedef signed long s64 ; -typedef unsigned long u64 ; -typedef __vector128 vector128 ;typedef u32 dma_addr_t ;
include/asm-s390/types.h +3 -39
55 lines not on this page · raw message
include/asm-sh/types.h +1 -30
@@ -5,24 +5,7 @@typedef unsigned short umode_t ; -/* -* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the -* header files exported to user space -*/ - -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64 ; -typedef unsigned long long __u64 ; -#endif +#include <linux/bit_types.h> #endif /* __ASSEMBLY__ */
@@ -35,18 +18,6 @@#ifndef __ASSEMBLY__ -typedef __signed__ char s8; -typedef unsigned char u8 ; - -typedef __signed__ short s16 ; -typedef unsigned short u16 ; - -typedef __signed__ int s32; -typedef unsigned int u32 ; - -typedef __signed__ long long s64 ; -typedef unsigned long long u64 ; -/* Dma addresses are 32-bits wide. */ typedef u32 dma_addr_t ;
include/asm-sparc/types.h +1 -23
@@ -19,17 +19,7 @@typedef unsigned short umode_t ; -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -typedef __signed__ long long __s64 ; -typedef unsigned long long __u64 ; +#include <linux/bit_types.h> #endif /* __ASSEMBLY__ */
@@ -39,18 +29,6 @@#ifndef __ASSEMBLY__ -typedef __signed__ char s8; -typedef unsigned char u8 ; - -typedef __signed__ short s16 ; -typedef unsigned short u16 ; - -typedef __signed__ int s32; -typedef unsigned int u32 ; - -typedef __signed__ long long s64 ; -typedef unsigned long long u64 ; -typedef u32 dma_addr_t ;typedef u32 dma64_addr_t ;
include/asm-sparc64/types.h +2 -28
@@ -14,22 +14,8 @@typedef unsigned short umode_t ; -/* -* _xx is ok: it doesn't pollute the POSIX namespace. Use these in the -* header files exported to user space. -*/ - -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -typedef __signed__ long __s64 ; -typedef unsigned long __u64 ; +#define _BROKEN_U64_S64 +#include <linux/bit_types.h> #endif /* __ASSEMBLY__ */
@@ -39,18 +25,6 @@#ifndef __ASSEMBLY__ -typedef __signed__ char s8; -typedef unsigned char u8 ; - -typedef __signed__ short s16 ; -typedef unsigned short u16 ; - -typedef __signed__ int s32; -typedef unsigned int u32 ; - -typedef __signed__ long s64 ; -typedef unsigned long u64 ; -/* Dma addresses come in generic and 64-bit flavours. */ typedef u32 dma_addr_t ;
include/asm-v850/types.h +1 -30
@@ -13,24 +13,7 @@typedef unsigned short umode_t ; -/* -* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the -* header files exported to user space -*/ - -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64 ; -typedef unsigned long long __u64 ; -#endif +#include <linux/bit_types.h> #endif /* !__ASSEMBLY__ */
@@ -43,18 +26,6 @@#ifndef __ASSEMBLY__ -typedef signed char s8 ; -typedef unsigned char u8 ; - -typedef signed short s16 ; -typedef unsigned short u16 ; - -typedef signed int s32 ; -typedef unsigned int u32 ; - -typedef signed long long s64 ; -typedef unsigned long long u64 ; -/* Dma addresses are 32-bits wide. */ typedef u32 dma_addr_t ;
include/asm-x86_64/types.h +1 -28
@@ -5,22 +5,7 @@typedef unsigned short umode_t ; -/* -* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the -* header files exported to user space -*/ - -typedef __signed__ char __s8; -typedef unsigned char __u8 ; - -typedef __signed__ short __s16 ; -typedef unsigned short __u16 ; - -typedef __signed__ int __s32; -typedef unsigned int __u32 ; - -typedef __signed__ long long __s64 ; -typedef unsigned long long __u64 ; +#include <linux/bit_types.h> #endif /* __ASSEMBLY__ */
@@ -33,18 +18,6 @@#ifndef __ASSEMBLY__ -typedef signed char s8 ; -typedef unsigned char u8 ; - -typedef signed short s16 ; -typedef unsigned short u16 ; - -typedef signed int s32 ; -typedef unsigned int u32 ; - -typedef signed long long s64 ; -typedef unsigned long long u64 ; -typedef u64 dma64_addr_t ;typedef u64 dma_addr_t ;
include/linux/bit_types.h +37 -0
@@ -0,0 +1,37 @@ +#ifndef _LINUX_BIT_TYPES_H +#define _LINUX_BIT_TYPES_H + +typedef __signed__ char s8; +typedef unsigned char u8 ; +typedef __signed__ short s16 ; +typedef unsigned short u16 ; +typedef __signed__ int s32; +typedef unsigned int u32 ; + +/* +* We want "long long" in the kernel to reduce the need for casts, +* but foul user-space C++ code might rely on this being "long". +* (name mangling leads to a purely user-space ABI problem) +*/ +#if defined(_BROKEN_U64_S64) && !defined(__KERNEL__) +typedef unsigned long __u64 ; +typedef __signed__ long __s64 ; +#else +#if defined(__GNUC__) +__extension__typedef unsigned long long __u64 ; +__extension__typedef __signed__ long long __s64 ; +endif +#endif + +#ifdef __KERNEL__ +typedef __s8 s8 ; +typedef __u8 u8 ; +typedef __s16 s16 ; +typedef __u16 u16 ; +typedef __s32 s32 ; +typedef __u32 u32 ; +typedef __s64 s64 ; +typedef __u64 u64 ; +#endif + +#endif /* _LINUX_BIT_TYPES_H */