public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* printk and long long
@ 2004-02-11 12:49 sting sting
  2004-02-11 13:35 ` wdebruij
  0 siblings, 1 reply; 20+ messages in thread
From: sting sting @ 2004-02-11 12:49 UTC (permalink / raw)
  To: linux-kernel

Hello,
I am trying to perfrom printk with a variable of type long long.
(loff_t is that type and it is long long , as can be seen in posix+types.h).
what is the format string for such a type ?
I had tried %lld" but it gace wrpng results.
regards,
sting

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 12:49 printk and long long sting sting
@ 2004-02-11 13:35 ` wdebruij
  2004-02-11 13:48   ` Maciej Zenczykowski
                     ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: wdebruij @ 2004-02-11 13:35 UTC (permalink / raw)
  To: sting sting; +Cc: linux-kernel

how about simply using a shift to output two regular longs, i.e.

printk("%ld%ld",loff_t >> (sizeof(long) * 8), loff_t << sizeof(long) * 8 >>
sizeof(long) * 8);

perhaps you could even place this ghastly code in a macro if you have to access
it often (so that you don't have to look at it :)?

I know it's not pretty, but at least the %ld is considered standard printf
functionality. I don't think %lld (even if it is implemented in some printf
derivates) can be considered portable.

Willem
Citeren sting sting <zstingx@hotmail.com>:

> Hello,
> I am trying to perfrom printk with a variable of type long long.
> (loff_t is that type and it is long long , as can be seen in
> posix+types.h).
> what is the format string for such a type ?
> I had tried %lld" but it gace wrpng results.
> regards,
> sting
> 
> _________________________________________________________________
> Protect your PC - get McAfee.com VirusScan Online 
> http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
> 
> -
> 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/
> 




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 13:35 ` wdebruij
@ 2004-02-11 13:48   ` Maciej Zenczykowski
  2004-02-11 14:04     ` vda
  2004-02-11 14:03   ` Måns Rullgård
  2004-02-11 15:23   ` Richard B. Johnson
  2 siblings, 1 reply; 20+ messages in thread
From: Maciej Zenczykowski @ 2004-02-11 13:48 UTC (permalink / raw)
  To: wdebruij; +Cc: sting sting, linux-kernel

> how about simply using a shift to output two regular longs, i.e.
> 
> printk("%ld%ld",loff_t >> (sizeof(long) * 8), loff_t << sizeof(long) * 8 >>
> sizeof(long) * 8);

I'd venture to guess you'd also have to cast the above to long.

Cheers,
MaZe.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
@ 2004-02-11 13:54 Bart Hartgers
  2004-02-11 14:04 ` YOSHIFUJI Hideaki / 吉藤英明
  2004-02-11 14:13 ` Andreas Schwab
  0 siblings, 2 replies; 20+ messages in thread
From: Bart Hartgers @ 2004-02-11 13:54 UTC (permalink / raw)
  To: maze; +Cc: wdebruij, zstingx, linux-kernel

On 11 Feb, Maciej Zenczykowski wrote:
>> how about simply using a shift to output two regular longs, i.e.
>> 
>> printk("%ld%ld",loff_t >> (sizeof(long) * 8), loff_t << sizeof(long) * 8 >>
>> sizeof(long) * 8);
> 
> I'd venture to guess you'd also have to cast the above to long.
> 
> Cheers,
> MaZe.

And use %lx%lx ?

> 
> -
> 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/

-- 
Bart Hartgers - TUE Eindhoven 
http://plasimo.phys.tue.nl/bart/contact.html

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 13:35 ` wdebruij
  2004-02-11 13:48   ` Maciej Zenczykowski
@ 2004-02-11 14:03   ` Måns Rullgård
  2004-02-11 14:15     ` wdebruij
  2004-02-11 15:23   ` Richard B. Johnson
  2 siblings, 1 reply; 20+ messages in thread
From: Måns Rullgård @ 2004-02-11 14:03 UTC (permalink / raw)
  To: linux-kernel

wdebruij@dds.nl writes:

> how about simply using a shift to output two regular longs, i.e.
>
> printk("%ld%ld",loff_t >> (sizeof(long) * 8), loff_t << sizeof(long) * 8 >>
> sizeof(long) * 8);

And how do you plan to make sense of the printed value?

-- 
Måns Rullgård
mru@kth.se


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 13:54 Bart Hartgers
@ 2004-02-11 14:04 ` YOSHIFUJI Hideaki / 吉藤英明
  2004-02-11 14:13 ` Andreas Schwab
  1 sibling, 0 replies; 20+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2004-02-11 14:04 UTC (permalink / raw)
  To: bart; +Cc: maze, wdebruij, zstingx, linux-kernel

In article <20040211135456.B33ED2BD4@etpmod.phys.tue.nl> (at Wed, 11 Feb 2004 14:54:56 +0100 (CET)), Bart Hartgers <bart@etpmod.phys.tue.nl> says:

> On 11 Feb, Maciej Zenczykowski wrote:
> >> how about simply using a shift to output two regular longs, i.e.
> >> 
> >> printk("%ld%ld",loff_t >> (sizeof(long) * 8), loff_t << sizeof(long) * 8 >>
> >> sizeof(long) * 8);
> > 
> > I'd venture to guess you'd also have to cast the above to long.
:
> And use %lx%lx ?

%08lx%08lx

--yoshfuji

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 13:48   ` Maciej Zenczykowski
@ 2004-02-11 14:04     ` vda
  2004-02-11 15:58       ` Maciej Zenczykowski
  2004-02-11 16:59       ` Dick Streefland
  0 siblings, 2 replies; 20+ messages in thread
From: vda @ 2004-02-11 14:04 UTC (permalink / raw)
  To: Maciej Zenczykowski, wdebruij; +Cc: sting sting, linux-kernel

On Wednesday 11 February 2004 15:48, Maciej Zenczykowski wrote:
> > how about simply using a shift to output two regular longs, i.e.
> >
> > printk("%ld%ld",loff_t >> (sizeof(long) * 8), loff_t << sizeof(long) * 8
> > >> sizeof(long) * 8);
>
> I'd venture to guess you'd also have to cast the above to long.

Hey that will work only for %x, not %d.

BTW, man printf says:

The character L specifying that a following e, E, f, g, or G
conversion corresponds to a long double argument, or a following
d, i, o, u, x, or X conversion corresponds to a long long argument.
Note that long long is not specified in ANSI C and therefore
not portable to all architectures.
--
vda

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 13:54 Bart Hartgers
  2004-02-11 14:04 ` YOSHIFUJI Hideaki / 吉藤英明
@ 2004-02-11 14:13 ` Andreas Schwab
  1 sibling, 0 replies; 20+ messages in thread
From: Andreas Schwab @ 2004-02-11 14:13 UTC (permalink / raw)
  To: Bart Hartgers; +Cc: maze, wdebruij, zstingx, linux-kernel

Bart Hartgers <bart@etpmod.phys.tue.nl> writes:

> On 11 Feb, Maciej Zenczykowski wrote:
>>> how about simply using a shift to output two regular longs, i.e.
>>> 
>>> printk("%ld%ld",loff_t >> (sizeof(long) * 8), loff_t << sizeof(long) * 8 >>
>>> sizeof(long) * 8);
>> 
>> I'd venture to guess you'd also have to cast the above to long.
>> 
>> Cheers,
>> MaZe.
>
> And use %lx%lx ?

Rather %lx%0lx.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 14:03   ` Måns Rullgård
@ 2004-02-11 14:15     ` wdebruij
  0 siblings, 0 replies; 20+ messages in thread
From: wdebruij @ 2004-02-11 14:15 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: linux-kernel

Quoting Måns Rullgård <mru@kth.se>:

> 
> And how do you plan to make sense of the printed value?
> 

perhaps I was a bit quick with replying. As others have pointed out, you should
specify the precision to be able to glue the two parts together. Ideally, this
should be done using a "%.8lx%.8lx", since the length of the variable in hex is
static. Unfortunately, it seems %ld is requested, in which case "%ld*(2^32)+%ld"
works (for humans), but is obviously not great.

I guess you'll need a number of extra tests (if lower 32bits > 1 billion ..) and
specific printk statements if the output should be shown as a correct 10-base
number. 

I don't know, it depends on the specific use-case, really. If at all possible, I
would stick to the hex-representation.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 13:35 ` wdebruij
  2004-02-11 13:48   ` Maciej Zenczykowski
  2004-02-11 14:03   ` Måns Rullgård
@ 2004-02-11 15:23   ` Richard B. Johnson
  2004-02-13  0:26     ` Peter Chubb
  2 siblings, 1 reply; 20+ messages in thread
From: Richard B. Johnson @ 2004-02-11 15:23 UTC (permalink / raw)
  To: wdebruij; +Cc: sting sting, linux-kernel

On Wed, 11 Feb 2004 wdebruij@dds.nl wrote:

> how about simply using a shift to output two regular longs, i.e.
>
> printk("%ld%ld",loff_t >> (sizeof(long) * 8), loff_t << sizeof(long) * 8 >>
> sizeof(long) * 8);
>
> perhaps you could even place this ghastly code in a macro if you have to access
> it often (so that you don't have to look at it :)?
>
> I know it's not pretty, but at least the %ld is considered standard printf
> functionality. I don't think %lld (even if it is implemented in some printf
> derivates) can be considered portable.
>
> Willem
> Citeren sting sting <zstingx@hotmail.com>:
>
> > Hello,
> > I am trying to perfrom printk with a variable of type long long.
> > (loff_t is that type and it is long long , as can be seen in
> > posix+types.h).
> > what is the format string for such a type ?
> > I had tried %lld" but it gace wrpng results.
> > regards,
> > sting

This is probably portable. I could do it much simpler in
assembly but it wouldn't be portable.

Printing both unsigned long long and signed long long.




#include <stdio.h>

unsigned long long tester0 = 12345678901234567890ULL;
unsigned long long tester1 = 0xffffffffffffffff;


char *ulltoa(char *buf, unsigned long long val)
{
    char tmp[0x20];
    char *cp = tmp;
    char *rp = buf;
    do {
            *cp++ = (char) (val%10ULL) + '0';
            val /= 10ULL;
       } while (val);
    do {
           *buf++ = *(--cp);
       } while (cp != tmp);
    *buf = 0x00;
    return rp;
}

char *lltoa(char *buf, long long val)
{
   char *cp = buf;
   if(val < 0) {
        *cp++ = (char) '-';
        val = ~val + 1LL;
   }
   (void) ulltoa(cp, (unsigned long)val);
   return buf;
}

int main()
{
    char buf[0x100];

    printf("%llu\n", 0ULL);
    printf("%llu\n", tester0);
    printf("%llu\n", tester1);
    printf("%s\n", ulltoa(buf, 0ULL));
    printf("%s\n", ulltoa(buf, tester0));
    printf("%s\n", ulltoa(buf, tester1));
    printf("%s\n", lltoa(buf, tester1));

    return 0;
}



Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an i686 machine (797.90 BogoMips).
            Note 96.31% of all statistics are fiction.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 14:04     ` vda
@ 2004-02-11 15:58       ` Maciej Zenczykowski
  2004-02-11 19:41         ` H. Peter Anvin
  2004-02-11 16:59       ` Dick Streefland
  1 sibling, 1 reply; 20+ messages in thread
From: Maciej Zenczykowski @ 2004-02-11 15:58 UTC (permalink / raw)
  To: vda; +Cc: wdebruij, sting sting, Linux Kernel Mailing List

On Wed, 11 Feb 2004, vda wrote:

> The character L specifying that a following e, E, f, g, or G
> conversion corresponds to a long double argument, or a following
> d, i, o, u, x, or X conversion corresponds to a long long argument.
> Note that long long is not specified in ANSI C and therefore
> not portable to all architectures.

[ personally I'd say screw the un-portable architectures ;) ]
Long long is here to stay.
Besides if a linux architecture utilises long long in the kernel and 
doesn't support it in printf via %lld then it's horked.
printf/libc should be fixed instead.
Maybe that's the problem - the libc support fragment in the kernel tree is 
not up to date on that architecture - maybe the fixes should applied there 
instead - instead of trying to work around the problem, fix the cause.

Cheers,
MaZe.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 14:04     ` vda
  2004-02-11 15:58       ` Maciej Zenczykowski
@ 2004-02-11 16:59       ` Dick Streefland
  1 sibling, 0 replies; 20+ messages in thread
From: Dick Streefland @ 2004-02-11 16:59 UTC (permalink / raw)
  To: linux-kernel

vda <vda@port.imtp.ilyichevsk.odessa.ua> wrote:
| Note that long long is not specified in ANSI C and therefore
| not portable to all architectures.

ANSI C corresponds to ISO-C90, which is 14 years old now. The current
C standard is ISO-C99, which specifies "ll" as the length modifier for
"long long" integer arguments.

-- 
Dick Streefland                      ////                      Altium BV
dick.streefland@altium.nl           (@ @)          http://www.altium.com
--------------------------------oOO--(_)--OOo---------------------------


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 15:58       ` Maciej Zenczykowski
@ 2004-02-11 19:41         ` H. Peter Anvin
  2004-02-11 20:32           ` Måns Rullgård
  0 siblings, 1 reply; 20+ messages in thread
From: H. Peter Anvin @ 2004-02-11 19:41 UTC (permalink / raw)
  To: linux-kernel

Followup to:  <Pine.LNX.4.44.0402111655170.17933-100000@gaia.cela.pl>
By author:    Maciej Zenczykowski <maze@cela.pl>
In newsgroup: linux.dev.kernel
>
> On Wed, 11 Feb 2004, vda wrote:
> 
> > The character L specifying that a following e, E, f, g, or G
> > conversion corresponds to a long double argument, or a following
> > d, i, o, u, x, or X conversion corresponds to a long long argument.
> > Note that long long is not specified in ANSI C and therefore
> > not portable to all architectures.
> 
> [ personally I'd say screw the un-portable architectures ;) ]
> Long long is here to stay.

long long is C99, so it's *definitely* here to say.  The conversion specifier
is "ll" not "L", however.

> Besides if a linux architecture utilises long long in the kernel and 
> doesn't support it in printf via %lld then it's horked.
> printf/libc should be fixed instead.
> Maybe that's the problem - the libc support fragment in the kernel tree is 
> not up to date on that architecture - maybe the fixes should applied there 
> instead - instead of trying to work around the problem, fix the cause.

Indeed.  Feel free to steal the code from klibc :)

	-hpa
-- 
PGP public key available - finger hpa@zytor.com
Key fingerprint: 2047/2A960705 BA 03 D3 2C 14 A8 A8 BD  1E DF FE 69 EE 35 BD 74
"The earth is but one country, and mankind its citizens."  --  Bahá'u'lláh
Just Say No to Morden * The Shadows were defeated -- Babylon 5 is renewed!!

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 19:41         ` H. Peter Anvin
@ 2004-02-11 20:32           ` Måns Rullgård
  2004-02-11 21:46             ` Chris Friesen
  2004-02-11 22:23             ` Andreas Schwab
  0 siblings, 2 replies; 20+ messages in thread
From: Måns Rullgård @ 2004-02-11 20:32 UTC (permalink / raw)
  To: linux-kernel

hpa@zytor.com (H. Peter Anvin) writes:

> Followup to:  <Pine.LNX.4.44.0402111655170.17933-100000@gaia.cela.pl>
> By author:    Maciej Zenczykowski <maze@cela.pl>
> In newsgroup: linux.dev.kernel
>>
>> On Wed, 11 Feb 2004, vda wrote:
>> 
>> > The character L specifying that a following e, E, f, g, or G
>> > conversion corresponds to a long double argument, or a following
>> > d, i, o, u, x, or X conversion corresponds to a long long argument.
>> > Note that long long is not specified in ANSI C and therefore
>> > not portable to all architectures.
>> 
>> [ personally I'd say screw the un-portable architectures ;) ]
>> Long long is here to stay.
>
> long long is C99, so it's *definitely* here to say.  The conversion specifier
> is "ll" not "L", however.

What is the proper way to deal with printing an int64_t when int64_t
can be either long or long long depending on machine?

-- 
Måns Rullgård
mru@kth.se


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 20:32           ` Måns Rullgård
@ 2004-02-11 21:46             ` Chris Friesen
  2004-02-11 22:38               ` Timothy Miller
  2004-02-11 22:23             ` Andreas Schwab
  1 sibling, 1 reply; 20+ messages in thread
From: Chris Friesen @ 2004-02-11 21:46 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: linux-kernel

Måns Rullgård wrote:

> What is the proper way to deal with printing an int64_t when int64_t
> can be either long or long long depending on machine?

Print it as long long, and even if there is an arch where that is 128 
bits it'll still work.

Chris


-- 
Chris Friesen                    | MailStop: 043/33/F10
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 20:32           ` Måns Rullgård
  2004-02-11 21:46             ` Chris Friesen
@ 2004-02-11 22:23             ` Andreas Schwab
  2004-02-11 23:11               ` Måns Rullgård
  1 sibling, 1 reply; 20+ messages in thread
From: Andreas Schwab @ 2004-02-11 22:23 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: linux-kernel

mru@kth.se (Måns Rullgård) writes:

> What is the proper way to deal with printing an int64_t when int64_t
> can be either long or long long depending on machine?

PRId64 from <inttypes.h> (replace d with the desired format character).
This is for user space, not sure whether that is acceptable for kernel
code (<intttypes.h> is not one of the required headers for freestanding
implementations).

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 21:46             ` Chris Friesen
@ 2004-02-11 22:38               ` Timothy Miller
  0 siblings, 0 replies; 20+ messages in thread
From: Timothy Miller @ 2004-02-11 22:38 UTC (permalink / raw)
  To: Chris Friesen; +Cc: Måns Rullgård, linux-kernel



Chris Friesen wrote:
> Måns Rullgård wrote:
> 
>> What is the proper way to deal with printing an int64_t when int64_t
>> can be either long or long long depending on machine?
> 
> 
> Print it as long long, and even if there is an arch where that is 128 
> bits it'll still work.


In that case you'll want to cast it to (long long) before you pass it so 
as to be sure that "%lld" and the parameter are the same size.  Right?


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 22:23             ` Andreas Schwab
@ 2004-02-11 23:11               ` Måns Rullgård
  2004-02-11 23:53                 ` H. Peter Anvin
  0 siblings, 1 reply; 20+ messages in thread
From: Måns Rullgård @ 2004-02-11 23:11 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: linux-kernel

Andreas Schwab <schwab@suse.de> writes:

> mru@kth.se (Måns Rullgård) writes:
>
>> What is the proper way to deal with printing an int64_t when int64_t
>> can be either long or long long depending on machine?
>
> PRId64 from <inttypes.h> (replace d with the desired format character).
> This is for user space, not sure whether that is acceptable for kernel
> code (<intttypes.h> is not one of the required headers for freestanding
> implementations).

That should work for userspace.  What standard specifies those?
What about kernel sources?

-- 
Måns Rullgård
mru@kth.se

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 23:11               ` Måns Rullgård
@ 2004-02-11 23:53                 ` H. Peter Anvin
  0 siblings, 0 replies; 20+ messages in thread
From: H. Peter Anvin @ 2004-02-11 23:53 UTC (permalink / raw)
  To: linux-kernel

Followup to:  <yw1xn07pw6sy.fsf@kth.se>
By author:    mru@kth.se (=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=)
In newsgroup: linux.dev.kernel
>
> Andreas Schwab <schwab@suse.de> writes:
> 
> > mru@kth.se (Måns Rullgård) writes:
> >
> >> What is the proper way to deal with printing an int64_t when int64_t
> >> can be either long or long long depending on machine?
> >
> > PRId64 from <inttypes.h> (replace d with the desired format character).
> > This is for user space, not sure whether that is acceptable for kernel
> > code (<intttypes.h> is not one of the required headers for freestanding
> > implementations).
> 
> That should work for userspace.  What standard specifies those?
> What about kernel sources?
> 

C99 defines those.

Another (frequently easier) way is to cast to (intmax_t) and use the %j size modifier:

	printf("foo = %jd\n", (intmax_t)foo);

	-hpa
-- 
PGP public key available - finger hpa@zytor.com
Key fingerprint: 2047/2A960705 BA 03 D3 2C 14 A8 A8 BD  1E DF FE 69 EE 35 BD 74
"The earth is but one country, and mankind its citizens."  --  Bahá'u'lláh
Just Say No to Morden * The Shadows were defeated -- Babylon 5 is renewed!!

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: printk and long long
  2004-02-11 15:23   ` Richard B. Johnson
@ 2004-02-13  0:26     ` Peter Chubb
  0 siblings, 0 replies; 20+ messages in thread
From: Peter Chubb @ 2004-02-13  0:26 UTC (permalink / raw)
  To: root; +Cc: wdebruij, sting sting, linux-kernel

>>>>> "Richard" == Richard B Johnson <root@chaos.analogic.com> writes:

Richard> On Wed, 11 Feb 2004 wdebruij@dds.nl wrote:
>> how about simply using a shift to output two regular longs, i.e.
>> 
>> printk("%ld%ld",loff_t >> (sizeof(long) * 8), loff_t <<
>> sizeof(long) * 8 >> sizeof(long) * 8);

Why bother?  printk already handles 64-bit types just fine.

Do
	loff_t x;
	printk("%lld\n" (long long)x)

You need the cast, because on 64-bit architectures, loff_t is long not
long long.

Peter c

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2004-02-13  0:31 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-11 12:49 printk and long long sting sting
2004-02-11 13:35 ` wdebruij
2004-02-11 13:48   ` Maciej Zenczykowski
2004-02-11 14:04     ` vda
2004-02-11 15:58       ` Maciej Zenczykowski
2004-02-11 19:41         ` H. Peter Anvin
2004-02-11 20:32           ` Måns Rullgård
2004-02-11 21:46             ` Chris Friesen
2004-02-11 22:38               ` Timothy Miller
2004-02-11 22:23             ` Andreas Schwab
2004-02-11 23:11               ` Måns Rullgård
2004-02-11 23:53                 ` H. Peter Anvin
2004-02-11 16:59       ` Dick Streefland
2004-02-11 14:03   ` Måns Rullgård
2004-02-11 14:15     ` wdebruij
2004-02-11 15:23   ` Richard B. Johnson
2004-02-13  0:26     ` Peter Chubb
  -- strict thread matches above, loose matches on Subject: below --
2004-02-11 13:54 Bart Hartgers
2004-02-11 14:04 ` YOSHIFUJI Hideaki / 吉藤英明
2004-02-11 14:13 ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox