factor/core/system/system.factor

85 lines
2.0 KiB
Factor
Raw Normal View History

! Copyright (c) 2007, 2010 slava pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs continuations init io kernel kernel.private make
math math.parser namespaces sequences ;
IN: system
2007-09-20 18:09:08 -04:00
PRIMITIVE: (exit) ( n -- * )
2016-11-01 20:16:11 -04:00
PRIMITIVE: disable-ctrl-break ( -- )
PRIMITIVE: enable-ctrl-break ( -- )
PRIMITIVE: nano-count ( -- ns )
2011-05-20 18:11:50 -04:00
SINGLETONS: x86.32 x86.64 arm ppc.32 ppc.64 ;
2008-04-02 17:32:58 -04:00
UNION: x86 x86.32 x86.64 ;
2011-05-20 18:11:50 -04:00
UNION: ppc ppc.32 ppc.64 ;
: cpu ( -- class ) \ cpu get-global ; foldable
2008-04-02 17:32:58 -04:00
SINGLETONS: windows macosx linux ;
2008-04-02 19:25:33 -04:00
UNION: unix macosx linux ;
2008-04-02 17:32:58 -04:00
: os ( -- class ) \ os get-global ; foldable
2008-04-02 17:32:58 -04:00
: vm-version ( -- string ) \ vm-version get-global ;
: vm-git-label ( -- string ) \ vm-git-label get-global ;
: vm-git-ref ( -- string )
vm-git-label CHAR: - over last-index head ;
: vm-git-id ( -- string )
vm-git-label CHAR: - over last-index 1 + tail ;
: vm-compiler ( -- string ) \ vm-compiler get-global ;
: vm-compile-time ( -- string ) \ vm-compile-time get-global ;
<PRIVATE
CONSTANT: string>cpu-hash H{
{ "x86.32" x86.32 }
{ "x86.64" x86.64 }
{ "arm" arm }
{ "ppc.32" ppc.32 }
{ "ppc.64" ppc.64 }
}
CONSTANT: string>os-hash H{
{ "windows" windows }
{ "macosx" macosx }
{ "linux" linux }
}
: string>cpu ( str -- class )
string>cpu-hash at ;
: string>os ( str -- class )
string>os-hash at ;
PRIVATE>
: image-path ( -- path ) \ image-path get-global ;
2008-09-18 23:08:12 -04:00
: vm-path ( -- path ) \ vm-path get-global ;
2008-09-18 23:08:12 -04:00
: embedded? ( -- ? ) OBJ-EMBEDDED special-object ;
: version-info ( -- str )
! formatting vocab not available in this context.
[
"Factor " % vm-version %
" " % cpu name>> %
" (" % build # ", " %
vm-git-ref % "-" %
vm-git-id 10 short head % ", " %
vm-compile-time % ")\n[" %
vm-compiler % "] on " % os name>> %
] "" make ;
: exit ( n -- * )
[ do-shutdown-hooks (exit) ] ignore-errors
[ "Unexpected error during shutdown!" print ] ignore-errors
255 (exit) ;