Last active
August 19, 2020 22:38
-
-
Save bigs/80c78ff926e949c1f7ff673b25440f5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2/5: Building Libgit.FFI (src/Libgit/FFI.idr) | |
src/Libgit/FFI.idr:30:24--35:11:Can't marshal type for foreign call (Libgit.FFI.case block in byteLengthToType Libgit.FFI.prim_int_size_bytes) at: | |
30 byteLengthToType len = case len of | |
31 1 => Bits8 | |
32 2 => Bits16 | |
33 4 => Bits32 | |
34 8 => Bits64 | |
35 _ => Int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FFIExample | |
import System.FFI | |
-- System info helpers | |
export | |
%foreign "C:int_size_bytes,shim" | |
prim_int_size_bytes : Int | |
export | |
%foreign "C:size_t_size_bytes,shim" | |
prim_size_t_size_bytes : Int | |
-- I don't love this, but without providers I don't have a mechanism to fail at | |
-- compile time, so I'll default to Int which doesn't seem so harmful. Famous | |
-- last words? | |
byteLengthToType : Bits8 -> Type | |
byteLengthToType len = case len of | |
1 => Bits8 | |
2 => Bits16 | |
4 => Bits32 | |
8 => Bits64 | |
_ => Int | |
CUInt : Num a => (a : Type) | |
CUInt = byteLengthToType prim_int_size_bytes | |
CSizeT : Num a => (a : Type) | |
CSizeT = byteLengthToType prim_size_t_size_bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8_t int_size_bytes() { | |
return sizeof(int); | |
} | |
uint8_t size_t_size_bytes() { | |
return sizeof(size_t); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment