[racket] Detecting 32/64-bit racket
On Sat, Oct 29, 2011 at 11:43 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> At Sat, 29 Oct 2011 16:19:53 +0200, Niklas Larsson wrote:
>> 2011/10/29 Thomas Chust <chust at web.de>:
>> > 2011/10/29 Norman Gray <norman at astro.gla.ac.uk>:
>> >> [...]
>> >> Is there a recommended way to detect whether racket is a 32- or
>> >> 64-bit executable?
>> >> [...]
>> >
>> > Hello Norman,
>> >
>> > while I don't know whether this strategy is particularly
>> > recommendable, I would suggest to use utilities from the FFI module:
>> >
>> > (require (only-in ffi/unsafe compiler-sizeof))
>> >
>> > (compiler-sizeof 'long) ; => 8 on a 64-bit system
>> > ; => 4 on a 32-bit system
>> >
>>
>> That doesn't work in all cases, sizeof(long) is 4 on 64-bit Windows.
>
> Right -- use `_pointer' or `_intptr', and that's probably the strategy
> I'd use.
>
> At Sat, 29 Oct 2011 09:31:17 -0500, Robby Findler wrote:
>> Another not so great way, in Racket, to tell if the current racket is
>> built as a 64 bit or 32 bit executable (is that what you're wanting?)
>>
>> ;; 64bit? : -> boolean
>> (define (64bit?) (eq? (expt 2 61) (expt 2 61)))
>
> This is not a good approach. If you happen to compile on a 64-bit
> machine, the compiler will end up constant-folding to
>
> (define (64bit?) #t)
I guess you're also saying that this is not a bug in the compiler
because eq?'s behavior is unspecified?
(but yeah, I should have thought to use fixnum? instead of eq?.)
Robby