How can a Chez Scheme program or library find out which operating system and machine architecture it's running on (from within Scheme code)?
From the Chez Scheme Version 9 User's Guide:
(native-endianness) import (rnrs) or (rnrs bytevectors)
(machine-type) import (chezscheme)
(scheme-version) import (chezscheme)
(scheme-version-number) import (chezscheme)
(petite?) import (chezscheme)
(threaded?) import (chezscheme)
(interactive?) import (chezscheme)
Unfortunately (machine-type)
is a cryptic string idiomatic to Chez (instead of a standard symbol like x86-64
) and may change from version to version. The other procedures work in the obvious manner.
I found these in the r7rs-benchmarks repo.
The machine type string is constructed as follows:
t
.Current architectures and operating systems:
(define arch-pairs
'(("a6" . amd64)
("arm32" . arm32)
("i3" . i386)
("ppc32" . ppc32)))
(define os-pairs
'(("fb" . freebsd)
("le" . linux)
("nb" . netbsd)
("nt" . windows)
("ob" . openbsd)
("osx" . macos)
("qnx" . qnx)
("s2" . solaris)))
To find all the machine types, look for all the makefiles named Mf-*
in the c
directory of the Chez Scheme source repo.