2000-11-22 08:56:05

by 64738

[permalink] [raw]
Subject: Kernel bits

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


2000-11-27 13:55:29

by Chad Schwartz

[permalink] [raw]
Subject: Re: Kernel bits

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


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

2000-11-27 14:01:51

by Keith Owens

[permalink] [raw]
Subject: Re: Kernel bits

On Mon, 27 Nov 2000 07:36:22 -0600 (CST),
Chad Schwartz <[email protected]> wrote:
>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.

2000-11-27 14:23:46

by Richard B. Johnson

[permalink] [raw]
Subject: Re: Kernel bits

On Mon, 27 Nov 2000, Chad Schwartz wrote:

> 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

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.


2000-11-27 14:41:15

by Chad Schwartz

[permalink] [raw]
Subject: Re: Kernel bits

> 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