44 libc standard library
The libc module exposes standard POSIX and C runtime system bindings via #foreign "c" declarations. It serves as the foundation for hosted I/O, process management, memory allocation, and networking.
#use libc44.1 System call catalog
44.1.1 File I/O and descriptors
libc::open(path: String, flags: Int) => Intlibc::close(fd: Int) => Intlibc::read(fd: Int, buf: Addr, count: Int) => Intlibc::write(fd: Int, buf: String, count: Int) => Intlibc::lseek(fd: Int, offset: Int, whence: Int) => Intlibc::ioctl(fd: Int, request: Int, arg: Int) => Intlibc::pipe(pipefd: Addr) => Int
44.1.2 Process execution and control
libc::posix_spawn(pid: Addr, path: String, acts: Addr, attr: Addr, argv: Addr, envp: Addr) => Intlibc::waitpid(pid: Int, status_ptr: Addr, options: Int) => Intlibc::exit(code: Int) => ()
44.1.3 Memory management
libc::malloc(size: Int) => Addrlibc::free(ptr: Addr) => ()libc::memset(ptr: Addr, val: Int, size: Int) => Addrlibc::memcpy(dest: Addr, src: Addr, n: Int) => Addrlibc::memmove(dest: Addr, src: Addr, n: Int) => Addrlibc::mmap(addr: Addr, len: Int, prot: Int, flags: Int, fd: Int, offset: Int) => Addrlibc::munmap(addr: Addr, len: Int) => Int
44.1.4 Sockets and networking
libc::socket(domain: Int, type: Int, protocol: Int) => Intlibc::bind(sockfd: Int, addr: Addr, addrlen: Int) => Intlibc::listen(sockfd: Int, backlog: Int) => Intlibc::accept(sockfd: Int, addr: Addr, addrlen_ptr: Addr) => Intlibc::connect(sockfd: Int, addr: Addr, addrlen: Int) => Intlibc::send(sockfd: Int, buf: String, len: Int, flags: Int) => Intlibc::recv(sockfd: Int, buf: Addr, len: Int, flags: Int) => Intlibc::setsockopt,libc::getsockopt,libc::getaddrinfo,libc::freeaddrinfo