add (system-type 'word)

Returns 32 or 64 to indicate whether Racket is running as a
32-bit program or a 64-bit program.
This commit is contained in:
Matthew Flatt 2012-12-24 06:38:09 -07:00
parent aa27011f34
commit 4a57db4448
5 changed files with 19 additions and 4 deletions

View File

@ -18,9 +18,9 @@ contain a null character; the environment variable named by
@racket[name] is set to @racket[value]. The return value is
@racket[#t] if the assignment succeeds, @racket[#f] otherwise.}
@defproc[(system-type [mode (or/c 'os 'gc 'link 'so-suffix 'machine)
@defproc[(system-type [mode (or/c 'os 'word 'gc 'link 'so-suffix 'machine)
'os])
(or/c symbol? string? bytes?)]{
(or/c symbol? string? bytes? exact-positive-integer?)]{
Returns information about the operating system, build mode, or machine
for a running Racket.
@ -34,6 +34,10 @@ In @indexed-racket['os] mode,
@item{@indexed-racket['macosx]}
]
In @indexed-racket['word] mode, the result is either @racket[32] or
@racket[64] to indicate whether Racket is running as a 32-bit program
or 64-bit program.
In @indexed-racket['gc] mode,
the possible symbol results are:

View File

@ -2572,6 +2572,9 @@
(test #t symbol? (system-type 'link))
(test #t relative-path? (system-library-subpath))
(test #t pair? (memv (system-type 'word) '(32 64)))
(test (fixnum? (expt 2 32)) = (system-type 'word) 64)
(test #t 'cmdline (let ([v (current-command-line-arguments)])
(and (vector? v)
(andmap string? (vector->list v)))))

View File

@ -1146,7 +1146,8 @@
(-> (-val 'gc) (Un (-val 'cgc) (-val '3m)))
(-> (-val 'link) (Un (-val 'static) (-val 'shared) (-val 'dll) (-val 'framework)))
(-> (-val 'so-suffix) -Bytes)
(-> (-val 'machine) -String))]
(-> (-val 'machine) -String)
(-> (-val 'word) -PosInt))]
[system-language+country (-> -String)]
[system-library-subpath (->opt [(Un (-val #f) (-val 'cgc) (-val '3m))] -Path)]

View File

@ -1,5 +1,7 @@
Version 5.3.1.10
Added phantom byte strings
Added 'word mode to system-type
racket/gui: added display-changed to frame%
Version 5.3.1.9
Changed case to use equal? instead of eqv?

View File

@ -2349,9 +2349,14 @@ static Scheme_Object *system_type(int argc, Scheme_Object *argv[])
#endif
}
sym = scheme_intern_symbol("word");
if (SAME_OBJ(argv[0], sym)) {
return scheme_make_integer(sizeof(void*)*8);
}
sym = scheme_intern_symbol("os");
if (!SAME_OBJ(argv[0], sym)) {
scheme_wrong_contract("system-type", "(or/c 'os 'link 'machine 'gc 'so-suffix)", 0, argc, argv);
scheme_wrong_contract("system-type", "(or/c 'os 'word 'link 'machine 'gc 'so-suffix 'word)", 0, argc, argv);
return NULL;
}
}