* u64 vs %llu format
@ 2004-02-11 18:17 Grant Grundler
2004-02-11 18:47 ` David Mosberger
2004-02-11 19:26 ` Grant Grundler
0 siblings, 2 replies; 3+ messages in thread
From: Grant Grundler @ 2004-02-11 18:17 UTC (permalink / raw)
To: linux-ia64
Hi David, et al,
Why is __u64 defined as "unsigned long" and not "unsigned long long"?
I ask because:
u64 i;
...
printk("i %llu\n, i);
will generate this warning:
<file>:<line>: warning: long long unsigned int format, __u64 arg (arg 2)
The code is correct, but the warning is "wrong".
(It might be technically correct, but doesn't flag a problem).
ia64 compiler could equate "long long" and "long" types or
the kernel could define __u64 as "unsigned long long".
The code above could cast "(unsigned long long) i" but it seems
silly this would be necessary. Maybe that's the right (but ugly) way.
Or is there a different printk format the code should be using?
Survey of other arches shows several use "unsigned long" for __u64
and I'm wondering if someone knows how this issue was resolved
in those arches:
asm-alpha/types.h:typedef unsigned long __u64;
asm-ia64/types.h:typedef unsigned long __u64;
asm-mips/types.h:typedef unsigned long __u64;
asm-ppc64/types.h:typedef unsigned long __u64;
asm-s390/types.h:typedef unsigned long __u64;
asm-sparc64/types.h:typedef unsigned long __u64;
Note that parisc uses "unsigned long long" for both 32 and 64-bit kernels.
thanks,
grant
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: u64 vs %llu format
2004-02-11 18:17 u64 vs %llu format Grant Grundler
@ 2004-02-11 18:47 ` David Mosberger
2004-02-11 19:26 ` Grant Grundler
1 sibling, 0 replies; 3+ messages in thread
From: David Mosberger @ 2004-02-11 18:47 UTC (permalink / raw)
To: linux-ia64
>>>>> On Wed, 11 Feb 2004 10:17:30 -0800, Grant Grundler <iod00d@hp.com> said:
Grant> Why is __u64 defined as "unsigned long" and not "unsigned long long"?
Because that's the way it is for pretty much every other 64-bit
UNIX-like platform. 64-bit UNIX/Linux platforms existed long before
"long long" was widely supported.
Grant> I ask because:
Grant> u64 i;
Grant> ...
Grant> printk("i %llu\n, i);
Grant> will generate this warning:
Grant> <file>:<line>: warning: long long unsigned int format, __u64 arg (arg 2)
Just cast "i" to (unsigned long long) and the code will be fine.
--david
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: u64 vs %llu format
2004-02-11 18:17 u64 vs %llu format Grant Grundler
2004-02-11 18:47 ` David Mosberger
@ 2004-02-11 19:26 ` Grant Grundler
1 sibling, 0 replies; 3+ messages in thread
From: Grant Grundler @ 2004-02-11 19:26 UTC (permalink / raw)
To: linux-ia64
On Wed, Feb 11, 2004 at 10:47:42AM -0800, David Mosberger wrote:
> >>>>> On Wed, 11 Feb 2004 10:17:30 -0800, Grant Grundler <iod00d@hp.com> said:
>
> Grant> Why is __u64 defined as "unsigned long" and not "unsigned long long"?
>
> Because that's the way it is for pretty much every other 64-bit
> UNIX-like platform. 64-bit UNIX/Linux platforms existed long before
> "long long" was widely supported.
ok. I initially read this as "64-bit unix source compat is more important
than ILP32-linux compat". But that's not a fair statement since it implies
alot more than this silly %llu vs u64 issue.
> Grant> will generate this warning:
> Grant> <file>:<line>: warning: long long unsigned int format, __u64 arg (arg 2)
>
> Just cast "i" to (unsigned long long) and the code will be fine.
Yes, or use "unsigned long long" instead of u64 in the first place.
I'll try to convince the code owner to only use "u64" for stuff
representing HW or other "shared" data structures. The distinction
is artificial since both are the same size on LP64 platforms.
But it would reduce the number of warnings we need to fix.
thanks,
grant
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-02-11 19:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-11 18:17 u64 vs %llu format Grant Grundler
2004-02-11 18:47 ` David Mosberger
2004-02-11 19:26 ` Grant Grundler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox