0 | ||| Miscellaneous functions for getting information about the system.
 1 | module System.Info
 2 |
 3 | %default total
 4 |
 5 | %extern prim__os : String
 6 | %extern prim__codegen : String
 7 |
 8 | ||| The current operating system.
 9 | export
10 | os : String
11 | os = prim__os
12 |
13 | ||| The codegen/backend used.
14 | export
15 | codegen : String
16 | codegen = prim__codegen
17 |
18 | ||| Whether we are running on MS Windows, either directly or with a compatibility
19 | ||| layer (e.g. cygwin).
20 | export
21 | isWindows : Bool
22 | isWindows = os `elem` ["windows", "mingw32", "cygwin32"]
23 |
24 | %foreign "C:idris2_getNProcessors, libidris2_support, idris_support.h"
25 |          "node:lambda:() => require('os').cpus().length"
26 | prim__getNProcessors : PrimIO Int
27 |
28 | ||| Get the number of processors on the system. Returns `Nothing` if we somehow
29 | ||| got 0 processors.
30 | export
31 | getNProcessors : IO (Maybe Nat)
32 | getNProcessors = do
33 |   i <- fromPrim prim__getNProcessors
34 |   pure (if i < 0 then Nothing else Just (integerToNat (cast i)))
35 |