Skip to contentSkip to conversation

Kernel bits

DISCUSSION 64738 4 participants 5 messages Nov 22, 2000 – Nov 27, 2000

lore
Share & tools
lore

64738

author
#0 lore raw

Hi.

Is there a syscall or something that can tell me whether I'm working on a 32- or a 64-bit kernel?

Greeting,
Alain
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw
int main(void) {
	printf("Size of an unsigned long is %d bytes\n",sizeof(unsigned long));
	return(0);
}

That simple program will tell you that an unsigned long is 4 bytes, or 8 bytes.

It is then a safe assumption - that if you get back '8', that you're running a 64bit kernel, on a 64bit processor.

Chad

Quoted 5 lines · On Wed, 22 Nov 2000, 64738 wrote:

Hi.

Is there a syscall or something that can tell me whether I'm working on a 32- or a 64-bit kernel?

Quoted 7 lines

Greeting,
Alain
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
Quoted 10 lines · Chad Schwartz
int main(void) {
	printf("Size of an unsigned long is %d bytes\n",sizeof(unsigned long));
	return(0);
}

That simple program will tell you that an unsigned long is 4 bytes, or 8 bytes.

It is then a safe assumption - that if you get back '8', that you're running a 64bit kernel, on a 64bit processor.

No, that only tells you the size of a long under the compiler you used. If you are on an Intel IA64 (64 bit kernel) but you compile with gcc for ix86 (32 bit userspace) then sizeof(long) is 4. IA64 runs both native and ix86 code, sizeof(any userspace field) tells you nothing about the kernel.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#3 lore raw
Quoted 5 lines

No, that only tells you the size of a long under the compiler you used. If you are on an Intel IA64 (64 bit kernel) but you compile with gcc for ix86 (32 bit userspace) then sizeof(long) is 4. IA64 runs both native and ix86 code, sizeof(any userspace field) tells you nothing about the kernel.

Doh. Well, it *DOES* tell you if you're running 64bit - if you're running the 64bit compiler. :)

It was a simple check. Obviously, its not perfect. (In the cases you pointed out, for instance, we'd report the wrong thing.)

Chad

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#4 lore raw
In reply to Chad Schwartz
Quoted 5 lines · Chad Schwartz
int main(void) {
	printf("Size of an unsigned long is %d bytes\n",sizeof(unsigned long));
	return(0);
}
Quoted 7 lines

That simple program will tell you that an unsigned long is 4 bytes, or 8 bytes.

It is then a safe assumption - that if you get back '8', that you're running a 64bit kernel, on a 64bit processor.

Chad

I think sizeof(size_t) is more correct!

Cheers,
Dick Johnson

Penguin : Linux version 2.4.0 on an i686 machine (799.54 BogoMips).

"Memory is like gasoline. You use it up when you are running. Of course you get it all back when you reboot..."; Actual explanation obtained from the Micro$oft help desk.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/