Contents
import Std.C
Types
String
type String =
ptr: Ptr Char
A C string is a pointer to a null-terminated character array.
This is meant to be used qualified as C.String
String.new
String.new (s: Std.Prelude.String): String
Copy a prelude string, append a ‘\0’, and return it as a new C.String
VoidPtr
type VoidPtr = Ptr U8
A convenience type for translating C APIs
File
type File =
f: Ptr Unit
FilePos
type FilePos =
f: Ptr Unit
Clock
type Clock =
sec: I64
nsec: I64
Functions
puts
puts: fn String -> I32 can Fs
putchar
putchar: fn Char -> Unit can Fs
getchar
getchar: fn Unit -> I32 can Fs
exit
exit: fn I32 -> Never
system
system: fn String -> I32 can IO
strlen
strlen: fn String -> Usz
malloc
malloc (size: Usz): Ptr a
calloc
calloc (items: Usz) (size: Usz): Ptr a
realloc
realloc (ptr: Ptr a) (size: Usz): Ptr a
free
free (ptr: Ptr a): Unit
memcpy
memcpy (dest: Ptr a) (src: Ptr b) (count: Usz): Ptr a
memcmp
memcmp (lhs: Ptr a) (rhs: Ptr b) (size: Usz): I32
fopen
fopen: fn String String -> File can Fs
fclose
fclose: fn File -> Unit can Fs
fputs
fputs: fn String File -> I32 can Fs
fputc
fputc: fn I32 File -> I32 can Fs
fwrite
fwrite: fn VoidPtr Usz Usz File -> Usz can Fs
fgetc
fgetc: fn File -> I32 can Fs
fgets
fgets: fn String I32 File -> String can Fs
ungetc
ungetc: fn I32 File -> I32 can Fs
fgetpos
fgetpos: fn File FilePos -> Unit can Fs
ftell
ftell: fn File -> I32 can Fs
fsetpos
fsetpos: fn File FilePos -> Unit can Fs
fseek
fseek: fn File I32 I32 -> I32 can Fs
feof
feof: fn File -> I32 can Fs
ferror
ferror: fn File -> I32 can Fs
clock_gettime
clock_gettime: fn I32 (Ptr Clock) -> I32 can Fs
nanosleep
nanosleep: fn (Ptr Clock) (Ptr Clock) -> I32 can Fs