Sys

Usage

use Sys;

Support for low-level programming and system calls.

This module is for low-level programming. It provides Chapel versions of many POSIX/Linux C library or system calls. For documentation on these system calls and constants, please see your system's manual pages.

Each of the functions in this file provides the same functionality as the corresponding function without the sys_ prefix, except that the sys_ versions all return an error code (of type err_t) and return any other values (such as how much was read) through an out argument.

For example, you can find more about the mmap call with:

man mmap

The call available here, sys_mmap, always returns an error code (or 0 for no error). The pointer value normally returned by mmap will be returned through the final ret_out argument.

const O_RDONLY: c_int
const O_WRONLY: c_int
const O_RDWR: c_int
const O_APPEND: c_int
const O_CREAT: c_int
const O_DSYNC: c_int
const O_EXCL: c_int
const O_NOCTTY: c_int
const O_NONBLOCK: c_int
const O_RSYNC: c_int
const O_SYNC: c_int
const O_TRUNC: c_int
const AF_UNIX: c_int
const AF_LOCAL: c_int
const AF_INET: c_int
const AF_INET6: c_int
const AF_IPX: c_int
const AF_X25: c_int
const AF_AX25: c_int
const AF_ATMPVC: c_int
const AF_APPLETALK: c_int
const AF_PACKET: c_int
const SOCK_STREAM: c_int
const SOCK_DGRAM: c_int
const SOCK_SEQPACKET: c_int
const SOCK_RAW: c_int
const SOCK_RDM: c_int
const SOCK_NONBLOCK: c_int
const SOCK_CLOEXEC: c_int
const MSG_CONFIRM: c_int
const MSG_DONTROUTE: c_int
const MSG_DONTWAIT: c_int
const MSG_EOR: c_int
const MSG_MORE: c_int
const MSG_NOSIGNAL: c_int
const MSG_OOB: c_int
const MSG_CMSG_CLOEXEC: c_int
const MSG_ERRQUEUE: c_int
const MSG_PEEK: c_int
const MSG_TRUNC: c_int
const MSG_WAITALL: c_int
const MSG_CTRUNC: c_int
const SHUT_RD: c_int
const SHUT_WR: c_int
const SHUT_RDWR: c_int
const IPPROTO_IP: c_int
const IPPROTO_IPV6: c_int
const IPPROTO_TCP: c_int
const IPPROTO_UDP: c_int
const IP_ADD_MEMBERSHIP: c_int
const IP_DROP_MEMBERSHIP: c_int
const IP_HDRINCL: c_int
const IP_MTU: c_int
const IP_MTU_DISCOVER: c_int
const IP_MULTICAST_IF: c_int
const IP_MULTICAST_LOOP: c_int
const IP_MULTICAST_TTL: c_int
const IP_OPTIONS: c_int
const IP_PKTINFO: c_int
const IP_RECVERR: c_int
const IP_RECVOPTS: c_int
const IP_RECVTOS: c_int
const IP_RECVTTL: c_int
const IP_RETOPTS: c_int
const IP_ROUTER_ALERT: c_int
const IP_TOS: c_int
const IP_TTL: c_int
const IPV6_ADDRFORM: c_int
const IPV6_ADD_MEMBERSHIP: c_int
const IPV6_DROP_MEMBERSHIP: c_int
const IPV6_MTU: c_int
const IPV6_MTU_DISCOVER: c_int
const IPV6_MULTICAST_HOPS: c_int
const IPV6_MULTICAST_IF: c_int
const IPV6_MULTICAST_LOOP: c_int
const IPV6_PKTINFO: c_int
const IPV6_RTHDR: c_int
const IPV6_AUTHHDR: c_int
const IPV6_DSTOPTS: c_int
const IPV6_HOPOPTS: c_int
const IPV6_HOPLIMIT: c_int
const IPV6_RECVERR: c_int
const IPV6_ROUTER_ALERT: c_int
const IPV6_UNICAST_HOPS: c_int
const IPV6_V6ONLY: c_int
const TCP_CORK: c_int
const TCP_DEFER_ACCEPT: c_int
const TCP_INFO: c_int
const TCP_KEEPCNT: c_int
const TCP_KEEPIDLE: c_int
const TCP_KEEPINTVL: c_int
const TCP_LINGER2: c_int
const TCP_MAXSEG: c_int
const TCP_NODELAY: c_int
const TCP_QUICKACK: c_int
const TCP_SYNCNT: c_int
const TCP_WINDOW_CLAMP: c_int
type sys_sockaddr_storage_t

SOCKET STRUCTURE TYPES

record sys_sockaddr_t
var addr: sys_sockaddr_storage_t
var len: socklen_t
proc sys_sockaddr_t()
record sys_addrinfo_t
var ai_flags: c_int
var ai_family: c_int
var ai_socktype: c_int
var ai_protocol: c_int
type sys_addrinfo_ptr_t
proc sys_addrinfo_ptr_t.flags: c_int
proc sys_addrinfo_ptr_t.family: c_int
proc sys_addrinfo_ptr_t.socktype: c_int
proc sys_addrinfo_ptr_t.socktype: c_int
proc sys_addrinfo_ptr_t.addr: sys_sockaddr_t
proc sys_addrinfo_ptr_t.next: sys_addrinfo_ptr_t
proc sys_init_sys_sockaddr(ref addr: sys_sockaddr_t)
proc sys_strerror(error: err_t, ref string_out: c_string): err_t
proc sys_getenv(name: c_string, ref string_out: c_string): c_int
proc sys_open(pathname: c_string, flags: c_int, mode: mode_t, ref fd_out: fd_t): err_t
proc sys_close(fd: fd_t): err_t
proc sys_mmap(addr: c_void_ptr, length: size_t, prot: c_int, flags: c_int, fd: fd_t, offset: off_t, ref ret_out: c_void_ptr): err_t
proc sys_munmap(addr: c_void_ptr, length: size_t): err_t
proc sys_fcntl(fd: fd_t, cmd: c_int, ref ret_out: c_int): err_t
proc sys_fcntl_long(fd: fd_t, cmd: c_int, arg: c_long, ref ret_out: c_int): err_t
proc sys_fcntl_ptr(fd: fd_t, cmd: c_int, arg: c_void_ptr, ref ret_out: c_int): err_t
proc sys_dup(oldfd: fd_t, ref fd_out: fd_t): err_t
proc sys_dup2(oldfd: fd_t, newfd: fd_t, ref fd_out: fd_t): err_t
proc sys_pipe(ref read_fd_out: fd_t, ref write_fd_out: fd_t): err_t
proc sys_accept(sockfd: fd_t, ref add_out: sys_sockaddr_t, ref fd_out: fd_t): err_t
proc sys_bind(sockfd: fd_t, ref addr: sys_sockaddr_t): err_t
proc sys_connect(sockfd: fd_t, ref addr: sys_sockaddr_t): err_t
proc sys_getaddrinfo(node: c_string, service: c_string, ref hints: sys_addrinfo_t, ref res_out: sys_addrinfo_ptr_t): err_t
proc sys_getaddrinfo_flags(res: sys_addrinfo_ptr_t): c_int
proc sys_getaddrinfo_family(res: sys_addrinfo_ptr_t): c_int
proc sys_getaddrinfo_socktype(res: sys_addrinfo_ptr_t): c_int
proc sys_getaddrinfo_protocol(res: sys_addrinfo_ptr_t): c_int
proc sys_getaddrinfo_addr(res: sys_addrinfo_ptr_t): sys_sockaddr_t
proc sys_getaddrinfo_next(res: sys_addrinfo_ptr_t): sys_addrinfo_ptr_t
proc sys_freeaddrinfo(res: sys_addrinfo_ptr_t)
proc sys_getnameinfo(ref addr: sys_sockaddr_t, ref host_out: c_string, ref serv_outc_: c_string, flags: c_int): err_t
proc sys_getpeername(sockfd: fd_t, ref addr: sys_sockaddr_t): err_t
proc sys_getsockname(sockfd: fd_t, ref addr: sys_sockaddr_t): err_t
proc sys_getsockopt(sockfd: fd_t, level: c_int, optname: c_int, optval: c_void_ptr, ref optlen: socklen_t): err_t
proc sys_setsockopt(sockfd: fd_t, level: c_int, optname: c_int, optval: c_void_ptr, optlen: socklen_t): err_t
proc sys_listen(sockfd: fd_t, backlog: c_int): err_t
proc sys_shutdown(sockfd: fd_t, how: c_int): err_t
proc sys_socket(_domain: c_int, _type: c_int, protocol: c_int, ref sockfd_out: fd_t): err_t
proc sys_socketpair(_domain: c_int, _type: c_int, protocol: c_int, ref sockfd_out_a: fd_t, ref sockfd_out_b: fd_t): err_t