Page 1 of 1

Simple question

Posted: Sat Aug 12, 2006 5:03 pm
by matthias
Can I use unsigned long long in djgpp as a 64-bit integer?

like:

Code: Select all

typedef unsigned long long size_t64;

size_t64 var = 0xffffffffffffffff;
Seen this once, but I don't know if it'll work. Since my printf() function has no 64-bit implementation I cannot chek ;)

Posted: Sun Aug 13, 2006 1:22 am
by Daedalus
Write a normal dos program and check :)

Posted: Mon Aug 14, 2006 3:55 pm
by matthias
I guess not:

Code: Select all

kernel.c:23: warning: integer constant is too large for "long" type

Posted: Fri Aug 18, 2006 7:21 pm
by earlz
seems to only set long 1 time; I think some other implementation of gcc supports it with some runtime helper functions(for 64bit mult and div) but a way to be sure is use sizeof() on it but in MinGW long long is just 32bit

Posted: Fri Aug 18, 2006 9:47 pm
by carbonBased
matthias wrote:I guess not:

Code: Select all

kernel.c:23: warning: integer constant is too large for "long" type
This is an annoyance of mine, as well... there doesn't appear to be an accurate way to print out a 64-bit integer.

I've been known to do the following:

long long bigInt;
printf("0x%x%x\n", bigInt, 0 );

This is far from perfect, but works on some compilers (it really depends on the warnings level). bigInt is 64-bits on my compiler (gcc 4.0) and so fills up both %x %x (it's interpreted as two 32-bit integers on the stack, for printf), and two avoid the compiler warning of one param to a printf with two params defined in the format string (yes, GCC will warn about this), I enter another variable.

Since the caller cleans the stack, there is no stack issue here.

However, let me state that I do this only at work. In osdev, who cares? You wrote printf, right? Add in a %hx (huge hex ;)) that prints a 64-bit int :)

Cheers,
Jeff

Posted: Sat Aug 19, 2006 2:23 pm
by matthias
My idea was to not print values of int64' But use it in a bitmap form, since this will give me more performance, since I'll have to do less iterations to find a free space (this idea only goes up in my idea, I won't use this in general form). I'll stick @ 32 ;)

Posted: Sat Aug 19, 2006 3:21 pm
by earlz
even if it did support 64bit ints it wouldn't be faster, as the cpu is 32bit it can only handle 32bits at a time(even if its smaller)