[plt-scheme] how to tell 32/64bit platform?

From: Eli Barzilay (eli at barzilay.org)
Date: Wed Sep 30 16:37:43 EDT 2009

On Sep 30, Thomas Chust wrote:
> 2009/9/30 Eli Barzilay <eli at barzilay.org>:
> > [...]
> > ((dynamic-require 'scheme/foreign 'compiler-sizeof) 'int)
> > [...]
> 
> Hello,
> 
> unless PLT Scheme's notion of "compiler-sizeof" is incompatible with
> common C compilers' notion of "sizeof", this is not going to be a
> reliable indicator whether the platform has a 64bit userland. There
> are definitely some examples of 64bit userlands that still have 32bit
> default word size for integers and hence sizeof(int) == 4 in C --
> usually because computations on the smaller datatype are still faster
> or to save memory. If I recall correctly, all early AMD64 platforms
> fall into that category.
> 
> It would probably be wiser to check the size of pointers instead using
> something like
> 
>   (define platform-64bit?
>     (= ((dynamic-require 'scheme/foreign 'compiler-sizeof) '*) 8))
> 
> All 64bit platforms I know of also have sizeof(long) == 8 in C, but
> since the size of the address space is really the most relevant
> discriminating factor between 32bit and 64bit platforms, checking the
> size of pointers seems most logical to me.

(Yes, that's all true -- by pointing at that direction I was implying
about all of these information bits that you can inspect, depending on
what is really needed -- which might after all be just the size of
int.)

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the users mailing list.