]> gitweb.factorcode.org Git - factor.git/blob - core/system/system.factor
Re-add Freebsd Support
[factor.git] / core / system / system.factor
1 ! Copyright (c) 2007, 2010 slava pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs continuations init io kernel
4 kernel.private make math.parser namespaces sequences splitting ;
5 IN: system
6
7 PRIMITIVE: (exit) ( n -- * )
8 PRIMITIVE: disable-ctrl-break ( -- )
9 PRIMITIVE: enable-ctrl-break ( -- )
10 PRIMITIVE: nano-count ( -- ns )
11
12 SINGLETONS: x86.32 x86.64 arm ppc.32 ppc.64 ;
13
14 UNION: x86 x86.32 x86.64 ;
15 UNION: ppc ppc.32 ppc.64 ;
16
17 : cpu ( -- class ) \ cpu get-global ; foldable
18
19 SINGLETONS: windows macosx linux freebsd ;
20
21 UNION: bsd freebsd ;
22 UNION: unix macosx linux freebsd bsd ;
23
24 : os ( -- class ) \ os get-global ; foldable
25
26 : vm-version ( -- string ) \ vm-version get-global ;
27
28 : vm-git-label ( -- string ) \ vm-git-label get-global ;
29
30 : vm-git-ref ( -- string )
31     vm-git-label "-" split1-last drop ;
32
33 : vm-git-id ( -- string )
34     vm-git-label "-" split1-last nip ;
35
36 : vm-compiler ( -- string ) \ vm-compiler get-global ;
37
38 : vm-compile-time ( -- string ) \ vm-compile-time get-global ;
39
40 <PRIVATE
41
42 CONSTANT: string>cpu-hash H{
43     { "x86.32" x86.32 }
44     { "x86.64" x86.64 }
45     { "arm" arm }
46     { "ppc.32" ppc.32 }
47     { "ppc.64" ppc.64 }
48 }
49
50 CONSTANT: string>os-hash H{
51     { "windows" windows }
52     { "macosx" macosx }
53     { "freebsd" freebsd }
54     { "linux" linux }
55 }
56
57 : string>cpu ( str -- class )
58     string>cpu-hash at ;
59
60 : string>os ( str -- class )
61     string>os-hash at ;
62
63 PRIVATE>
64
65 : image-path ( -- path ) \ image-path get-global ;
66
67 : vm-path ( -- path ) \ vm-path get-global ;
68
69 : embedded? ( -- ? ) OBJ-EMBEDDED special-object ;
70
71 : version-info ( -- str )
72     ! formatting vocab not available in this context.
73     [
74         "Factor " % vm-version %
75         " " % cpu name>> %
76         " (" % build # ", " %
77         vm-git-ref % "-" %
78         vm-git-id 10 short head % ", " %
79         vm-compile-time % ")\n[" %
80         vm-compiler % "] on " % os name>> %
81     ] "" make ;
82
83 : exit ( n -- * )
84     [ do-shutdown-hooks (exit) ] ignore-errors
85     [ "Unexpected error during shutdown!" print flush ] ignore-errors
86     255 (exit) ;