Simple question

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
matthias
Member
Member
Posts: 158
Joined: Fri Oct 22, 2004 11:00 pm
Location: Vlaardingen, Holland
Contact:

Simple question

Post 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 ;)
The source of my problems is in the source.
User avatar
Daedalus
Member
Member
Posts: 74
Joined: Sun Oct 16, 2005 11:00 pm
Location: Australia
Contact:

Post by Daedalus »

Write a normal dos program and check :)
User avatar
matthias
Member
Member
Posts: 158
Joined: Fri Oct 22, 2004 11:00 pm
Location: Vlaardingen, Holland
Contact:

Post by matthias »

I guess not:

Code: Select all

kernel.c:23: warning: integer constant is too large for "long" type
The source of my problems is in the source.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post 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
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Post 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
User avatar
matthias
Member
Member
Posts: 158
Joined: Fri Oct 22, 2004 11:00 pm
Location: Vlaardingen, Holland
Contact:

Post 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 ;)
The source of my problems is in the source.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post 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)
Post Reply