2021-10-29 19:58:29 +03:00
|
|
|
||| Miscellaneous functions for getting information about the system.
|
2020-05-18 15:59:07 +03:00
|
|
|
module System.Info
|
|
|
|
|
2021-06-09 01:05:10 +03:00
|
|
|
%default total
|
|
|
|
|
2020-05-18 15:59:07 +03:00
|
|
|
%extern prim__os : String
|
|
|
|
%extern prim__codegen : String
|
|
|
|
|
2021-10-29 19:58:29 +03:00
|
|
|
||| The current operating system.
|
2020-05-18 15:59:07 +03:00
|
|
|
export
|
|
|
|
os : String
|
|
|
|
os = prim__os
|
|
|
|
|
2021-10-29 19:58:29 +03:00
|
|
|
||| The codegen/backend used.
|
2020-05-18 15:59:07 +03:00
|
|
|
export
|
|
|
|
codegen : String
|
|
|
|
codegen = prim__codegen
|
2020-05-26 12:59:14 +03:00
|
|
|
|
2021-10-29 19:58:29 +03:00
|
|
|
||| Whether we are running on MS Windows, either directly or with a compability
|
|
|
|
||| layer (e.g. cygwin).
|
2020-05-26 12:59:14 +03:00
|
|
|
export
|
|
|
|
isWindows : Bool
|
2020-05-26 21:56:16 +03:00
|
|
|
isWindows = os `elem` ["windows", "mingw32", "cygwin32"]
|
2021-03-26 21:27:25 +03:00
|
|
|
|
2021-04-23 13:09:31 +03:00
|
|
|
%foreign "C:idris2_getNProcessors, libidris2_support, idris_support.h"
|
2021-03-26 21:27:25 +03:00
|
|
|
prim__getNProcessors : PrimIO Int
|
|
|
|
|
2021-10-29 19:58:29 +03:00
|
|
|
||| Get the number of processors on the system. Returns `Nothing` if we somehow
|
|
|
|
||| got 0 processors.
|
2021-03-26 21:27:25 +03:00
|
|
|
export
|
|
|
|
getNProcessors : IO (Maybe Nat)
|
|
|
|
getNProcessors = do
|
|
|
|
i <- fromPrim prim__getNProcessors
|
|
|
|
pure (if i < 0 then Nothing else Just (integerToNat (cast i)))
|