19 | import public System.FFI
22 | libxla : String -> String -> String
23 | libxla header fname = "C:\{fname},libc_xla,\{header}"
25 | ffi : String -> String
26 | ffi = libxla "c/ffi.h"
29 | onCollectAny' : HasIO io => AnyPtr -> (AnyPtr -> IO ()) -> io GCAnyPtr
30 | onCollectAny' x f = onCollectAny x f
33 | cIntToBool : Int -> Bool
34 | cIntToBool 0 = False
37 | let msg = "Internal error: expected 0 or 1 from XLA C API for boolean conversion, got " ++ show x
38 | in (assert_total idris_crash) msg
41 | boolToCInt : Bool -> Int
43 | boolToCInt False = 0
45 | %foreign (ffi "is_nullptr")
46 | prim__isNullPtr : AnyPtr -> Int
49 | isNullPtr : AnyPtr -> Bool
50 | isNullPtr ptr = cIntToBool $
prim__isNullPtr ptr